}
scriptRunner.run( "pre-build script", basedir, preBuildHookScript, context, logger,
BuildJob.Result.FAILURE_PRE_HOOK, false );
final InvocationRequest request = new DefaultInvocationRequest();
request.setLocalRepositoryDirectory( localRepositoryPath );
request.setUserSettingsFile( settingsFile );
request.setInteractive( false );
request.setShowErrors( showErrors );
request.setDebug( debug );
request.setShowVersion( showVersion );
if ( logger != null )
{
request.setErrorHandler( logger );
request.setOutputHandler( logger );
}
if ( mavenHome != null )
{
invoker.setMavenHome( mavenHome );
request.addShellEnvironment( "M2_HOME", mavenHome.getAbsolutePath() );
}
if ( javaHome != null )
{
request.setJavaHome( javaHome );
}
for ( int invocationIndex = 1;; invocationIndex++ )
{
if ( invocationIndex > 1 && !invokerProperties.isInvocationDefined( invocationIndex ) )
{
break;
}
request.setBaseDirectory( basedir );
request.setPomFile( pomFile );
request.setGoals( goals );
request.setProfiles( profiles );
request.setMavenOpts( mavenOpts );
request.setOffline( false );
Properties systemProperties =
getSystemProperties( basedir, invokerProperties.getSystemPropertiesFile( invocationIndex ) );
request.setProperties( systemProperties );
invokerProperties.configureInvocation( request, invocationIndex );
if ( getLog().isDebugEnabled() )
{
try
{
getLog().debug( "Using MAVEN_OPTS: " + request.getMavenOpts() );
getLog().debug( "Executing: " + new MavenCommandLineBuilder().build( request ) );
}
catch ( CommandLineConfigurationException e )
{
getLog().debug( "Failed to display command line: " + e.getMessage() );