maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: maven-components/maven-core-it-verifier/src/main/java/org/apache/maven/it Verifier.java
Date Fri, 10 Sep 2004 23:43:35 GMT
brett       2004/09/10 16:43:35

  Modified:    maven-core/src/main/java/org/apache/maven MavenCli.java
               maven-core-it-verifier/src/main/java/org/apache/maven/it
                        Verifier.java
  Log:
  return exit code for goal failures
  
  Revision  Changes    Path
  1.5       +15 -5     maven-components/maven-core/src/main/java/org/apache/maven/MavenCli.java
  
  Index: MavenCli.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/MavenCli.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MavenCli.java	2 Sep 2004 12:34:17 -0000	1.4
  +++ MavenCli.java	10 Sep 2004 23:43:34 -0000	1.5
  @@ -45,7 +45,7 @@
   
       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 @@
           {
               cliManager.displayHelp();
   
  -            return;
  +            return 0;
           }
   
           if ( commandLine.hasOption( CLIManager.VERSION ) )
  @@ -100,7 +100,7 @@
               //  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 @@
                   System.out.println( "    " + goal.getId() );
               }
   
  -            return;
  +            return 0;
           }
   
           ExecutionResponse response = null;
  @@ -151,6 +151,16 @@
           else
           {
               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;
           }
       }
   
  
  
  
  1.14      +11 -3     maven-components/maven-core-it-verifier/src/main/java/org/apache/maven/it/Verifier.java
  
  Index: Verifier.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core-it-verifier/src/main/java/org/apache/maven/it/Verifier.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Verifier.java	9 Sep 2004 11:13:12 -0000	1.13
  +++ Verifier.java	10 Sep 2004 23:43:35 -0000	1.14
  @@ -301,6 +301,7 @@
           allGoals.add( "clean:clean" );
           allGoals.addAll( goals );
   
  +        int ret = 0;
           try 
           {
               String prevUserDir = System.getProperty( "user.dir" );
  @@ -309,13 +310,20 @@
               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();
           }
       }
   
  
  
  

Mime
View raw message