throws MavenExecutorException
{
Handler handler = new Handler( getLogger() );
LoggerBridge bridge = new LoggerBridge( getLogger() );
Invoker invoker =
new DefaultInvoker().setMavenHome( releaseEnvironment.getMavenHome() ).setLogger( bridge ).setOutputHandler(
handler ).setErrorHandler( handler );
InvocationRequest req =
new DefaultInvocationRequest().setDebug( getLogger().isDebugEnabled() ).setBaseDirectory(
workingDirectory ).setInteractive( interactive );
if ( pomFileName != null )
{
req.setPomFileName( pomFileName );
}
File settingsFile = null;
if ( releaseEnvironment.getSettings() != null )
{
// Have to serialize to a file as if Maven is embedded, there may not actually be a settings.xml on disk
try
{
settingsFile = File.createTempFile( "release-settings", ".xml" );
SettingsXpp3Writer writer = new SettingsXpp3Writer();
FileWriter fileWriter = null;
try
{
fileWriter = new FileWriter( settingsFile );
writer.write( fileWriter, releaseEnvironment.getSettings() );
}
finally
{
IOUtil.close( fileWriter );
}
req.setUserSettingsFile( settingsFile );
}
catch ( IOException e )
{
throw new MavenExecutorException( "Could not create temporary file for release settings.xml", e );
}
}
try
{
File localRepoDir = releaseEnvironment.getLocalRepositoryDirectory();
if ( localRepoDir != null )
{
req.setLocalRepositoryDirectory( localRepoDir );
}
setupRequest( req, bridge, additionalArguments );
if ( goals.trim().length() > 0 )
{
String[] rawGoals = goals.split( " " );
req.setGoals( Arrays.asList( rawGoals ) );
}
try
{
InvocationResult invocationResult = invoker.execute( req );
if ( invocationResult.getExecutionException() != null )
{
throw new MavenExecutorException( "Error executing Maven.",
invocationResult.getExecutionException() );