int ret;
try
{
Commandline cli = new Commandline();
cli.setWorkingDirectory( basedir );
String executable;
if ( mavenHome != null )
{
executable = mavenHome + "/bin/mvn";
}
else
{
executable = "mvn";
}
cli.setExecutable( executable );
for ( Iterator it = cliOptions.iterator(); it.hasNext(); )
{
String key = (String) it.next();
String resolvedArg = resolveCommandLineArg( key );
cli.createArgument().setLine( resolvedArg );
}
cli.createArgument().setValue( "-e" );
cli.createArgument().setValue( "--no-plugin-registry" );
cli.createArgument().setValue( "--batch-mode" );
for ( Iterator i = properties.keySet().iterator(); i.hasNext(); )
{
String key = (String) i.next();
cli.createArgument().setLine( "-D" + key + "=" + properties.getProperty( key ) );
}
boolean useMavenRepoLocal = Boolean.valueOf(
controlProperties.getProperty( "use.mavenRepoLocal", "true" ) ).booleanValue();
if ( useMavenRepoLocal )
{
// Note: Make sure that the repo is surrounded by quotes as it can possibly have
// spaces in its path.
cli.createArgument().setLine( "-Dmaven.repo.local=" + "\"" + localRepo + "\"" );
}
for ( Iterator i = allGoals.iterator(); i.hasNext(); )
{
cli.createArgument().setValue( (String) i.next() );
}
Writer logWriter = new FileWriter( new File( basedir, LOG_FILENAME ) );
StreamConsumer out = new WriterStreamConsumer( logWriter );
StreamConsumer err = new WriterStreamConsumer( logWriter );
System.out.println( "Command: " + Commandline.toString( cli.getCommandline() ) );
ret = CommandLineUtils.executeCommandLine( cli, out, err );
logWriter.close();
}