mirror of https://github.com/apache/maven.git
return exit code for goal failures
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163071 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1a509138ef
commit
182d817ff1
|
@ -301,6 +301,7 @@ public class Verifier
|
|||
allGoals.add( "clean:clean" );
|
||||
allGoals.addAll( goals );
|
||||
|
||||
int ret = 0;
|
||||
try
|
||||
{
|
||||
String prevUserDir = System.getProperty( "user.dir" );
|
||||
|
@ -309,14 +310,21 @@ public class Verifier
|
|||
URL classWorldsUrl = new URL( "file:" + mavenHome + "/core/classworlds-1.1-SNAPSHOT.jar" );
|
||||
ClassLoader cl = URLClassLoader.newInstance( new URL[] { classWorldsUrl } );
|
||||
Class c = Class.forName( "org.codehaus.classworlds.Launcher", true, cl );
|
||||
Method m = c.getMethod( "main", new Class[] { String[].class } );
|
||||
m.invoke( null, new Object[] { allGoals.toArray( new String[0] ) } );
|
||||
Method m = c.getMethod( "mainWithExitCode", new Class[] { String[].class } );
|
||||
Object o = m.invoke( null, new Object[] { allGoals.toArray( new String[0] ) } );
|
||||
System.setProperty( "user.dir", prevUserDir );
|
||||
ret = ( ( Integer ) o ).intValue();
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
throw new VerificationException( e );
|
||||
}
|
||||
|
||||
if ( ret > 0 )
|
||||
{
|
||||
System.err.println( "Exit code: " + ret );
|
||||
throw new VerificationException();
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
|
@ -45,7 +45,7 @@ public class MavenCli
|
|||
|
||||
public static final String POMv4 = "pom.xml";
|
||||
|
||||
public static void main( String[] args, ClassWorld classWorld )
|
||||
public static int main( String[] args, ClassWorld classWorld )
|
||||
throws Exception
|
||||
{
|
||||
CLIManager cliManager = new CLIManager();
|
||||
|
@ -85,7 +85,7 @@ public class MavenCli
|
|||
{
|
||||
cliManager.displayHelp();
|
||||
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( commandLine.hasOption( CLIManager.VERSION ) )
|
||||
|
@ -100,7 +100,7 @@ public class MavenCli
|
|||
// the manifest in plain text and read that back.
|
||||
System.out.println( "Maven version: " );
|
||||
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( commandLine.hasOption( CLIManager.LIST_GOALS ) )
|
||||
|
@ -116,7 +116,7 @@ public class MavenCli
|
|||
System.out.println( " " + goal.getId() );
|
||||
}
|
||||
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ExecutionResponse response = null;
|
||||
|
@ -152,6 +152,16 @@ public class MavenCli
|
|||
{
|
||||
response = maven.execute( projectFile, commandLine.getArgList() );
|
||||
}
|
||||
|
||||
// @todo we may wish for more types of error codes - perhaps letting the response define them?
|
||||
if ( response.isExecutionFailure() )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue