You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jv...@apache.org on 2004/05/07 19:59:46 UTC

cvs commit: maven-components/maven-core/src/main/java/org/apache/maven MavenCli.java

jvanzyl     2004/05/07 10:59:46

  Modified:    maven-core/src/main/java/org/apache/maven MavenCli.java
  Log:
  o maven2 can now run along side maven1 without any difficulty so i'm adding a search for a project2.xml file so that v3 and v4 POMs can sit next to one another for people currently experimenting.
  o adding a hook for the reactor which i will try with the new IDEA plugin today.
  
  Revision  Changes    Path
  1.3       +37 -45    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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MavenCli.java	23 Apr 2004 23:01:40 -0000	1.2
  +++ MavenCli.java	7 May 2004 17:59:46 -0000	1.3
  @@ -16,10 +16,6 @@
    * limitations under the License.
    */
   
  -import java.io.File;
  -import java.util.Iterator;
  -import java.util.TreeMap;
  -
   import org.apache.commons.cli.CommandLine;
   import org.apache.commons.cli.CommandLineParser;
   import org.apache.commons.cli.HelpFormatter;
  @@ -27,10 +23,13 @@
   import org.apache.commons.cli.Options;
   import org.apache.commons.cli.ParseException;
   import org.apache.commons.cli.PosixParser;
  -import org.apache.maven.plugin.descriptor.GoalDescriptor;
  -
   import org.codehaus.classworlds.ClassWorld;
   
  +import java.io.File;
  +import java.io.FileInputStream;
  +import java.util.Iterator;
  +import java.util.Properties;
  +
   /**
    * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
    * @version $Id$
  @@ -39,18 +38,16 @@
   {
       public static final String POM_FILE_NAME = "project.xml";
   
  +    public static final String POM_VERSION_4_FILE_NAME = "project2.xml";
  +
       private static final String WORK_OFFLINE = "o";
   
  +    private static final String REACTOR = "r";
  +
       private static final String SET_SYSTEM_PROPERTY = "D";
   
       private static final String DEBUG = "X";
   
  -    private static final String HELP = "h";
  -
  -    private static final String VERSION = "v";
  -
  -    private static final String LIST_GOALS = "g";
  -
       public static void main( String[] args, ClassWorld classWorld )
           throws Exception
       {
  @@ -60,41 +57,30 @@
   
           initializeSystemProperties( commandLine );
   
  -        Maven maven = new Maven( System.getProperty( "maven.home" ), classWorld );
  +        String mavenHome = System.getProperty( "maven.home" );
   
  -        File projectFile = new File( System.getProperty( "user.dir" ), POM_FILE_NAME );
  +        Maven maven = new Maven( mavenHome, classWorld );
   
  -        if ( commandLine.hasOption( HELP ) )
  -        {
  -            cliManager.displayHelp();
  +        // ----------------------------------------------------------------------
  +        // We will look for project2.xml files for a while so that folks can
  +        // try out m2 without screwing up other developers using m1. m1 and m2
  +        // can co-exist happily together so this just makes it easy to use both
  +        // the v3 and v4 of the POM.
  +        // ----------------------------------------------------------------------
   
  -            return;
  -        }
  +        File projectFile;
   
  -        if ( commandLine.hasOption( VERSION ) )
  -        {
  -            // TODO: create some sane output.
  -            System.out.println( "foo version" );
  -
  -            return;
  -        }
  +        projectFile = new File( System.getProperty( "user.dir" ), POM_VERSION_4_FILE_NAME );
   
  -        if ( commandLine.hasOption( LIST_GOALS ) )
  +        if ( !projectFile.exists() )
           {
  -            Iterator goals = new TreeMap( maven.getGoalDescriptors() ).values().iterator();
  -
  -            System.out.println( "Goals: " );
  -
  -            while ( goals.hasNext() )
  -            {
  -                GoalDescriptor goal = (GoalDescriptor)goals.next();
  -
  -                System.out.println( "    " + goal.getName() );
  -            }
  -
  -            return;
  +            projectFile = new File( System.getProperty( "user.dir" ), POM_FILE_NAME );
           }
   
  +        // ----------------------------------------------------------------------
  +        // Execute the goals
  +        // ----------------------------------------------------------------------
  +
           for ( Iterator i = commandLine.getArgList().iterator(); i.hasNext(); )
           {
               maven.execute( projectFile, (String) i.next() );
  @@ -177,7 +163,7 @@
                                  .withLongOpt( "define" )
                                  .hasArg()
                                  .withDescription( "Define a system property" )
  -                               .create( SET_SYSTEM_PROPERTY ) );
  +                               .create( 'D' ) );
   
               options.addOption( OptionBuilder
                                  .withLongOpt( "dir" )
  @@ -193,27 +179,32 @@
               options.addOption( OptionBuilder
                                  .withLongOpt( "goalDescriptors" )
                                  .withDescription( "Display available goalDescriptors" )
  -                               .create( LIST_GOALS ) );
  +                               .create( 'g' ) );
   
               options.addOption( OptionBuilder
                                  .withLongOpt( "help" )
                                  .withDescription( "Display help information" )
  -                               .create( HELP ) );
  +                               .create( 'h' ) );
   
               options.addOption( OptionBuilder
                                  .withLongOpt( "offline" )
                                  .withDescription( "Build is happening offline" )
  -                               .create( WORK_OFFLINE ) );
  +                               .create( 'o' ) );
   
               options.addOption( OptionBuilder
                                  .withLongOpt( "version" )
                                  .withDescription( "Display version information" )
  -                               .create( VERSION ) );
  +                               .create( 'v' ) );
   
               options.addOption( OptionBuilder
                                  .withLongOpt( "debug" )
                                  .withDescription( "Produce execution debug output" )
  -                               .create( DEBUG ) );
  +                               .create( 'X' ) );
  +
  +            options.addOption( OptionBuilder
  +                               .withLongOpt( "reactor" )
  +                               .withDescription( "Execute goals for project found in the reactor" )
  +                               .create( 'r' ) );
           }
   
           public CommandLine parse( String[] args ) throws ParseException
  @@ -228,6 +219,7 @@
               HelpFormatter formatter = new HelpFormatter();
   
               formatter.printHelp( "maven [options] [goal [goal2 [goal3] ...]]", "\nOptions:", options, "\n" );
  +
           }
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org