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/sandbox/pom-pre-alpha-converter/src/main/java/org/apache/maven/tools/converter Main.java
Date Fri, 11 Mar 2005 01:06:48 GMT
brett       2005/03/10 17:06:48

  Modified:    maven-model maven.mdo
               maven-core/src/main/java/org/apache/maven/cli MavenCli.java
               maven-core/src/main/java/org/apache/maven/execution
                        MavenExecutionRequest.java
               maven-core/src/main/java/org/apache/maven/project
                        DefaultMavenProjectBuilder.java MavenProject.java
               maven-core/src/main/java/org/apache/maven DefaultMaven.java
               sandbox/pom-pre-alpha-converter/src/main/java/org/apache/maven/tools/converter
                        Main.java
  Added:       maven-core/src/main/java/org/apache/maven/execution
                        DefaultMavenExecutionRequest.java
  Removed:     maven-core/src/main/java/org/apache/maven/execution
                        AbstractMavenExecutionRequest.java
                        MavenInitializingExecutionRequest.java
                        MavenProjectExecutionRequest.java
                        MavenReactorExecutionRequest.java
  Log:
  multi-module support
  
  Revision  Changes    Path
  1.85      +9 -3      maven-components/maven-model/maven.mdo
  
  Index: maven.mdo
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-model/maven.mdo,v
  retrieving revision 1.84
  retrieving revision 1.85
  diff -u -r1.84 -r1.85
  --- maven.mdo	10 Mar 2005 23:01:35 -0000	1.84
  +++ maven.mdo	11 Mar 2005 01:06:47 -0000	1.85
  @@ -10,9 +10,6 @@
    | o i18n: would be good to be able to have names/descriptions/specifications
    |   in as many languages as possible.
    |
  - | o versioning of individual elements on the class level and the field level so that
  - |   different versions of the model can be output.
  - |
    | o annotation mechanism so that changes to the model can be accurately tracked.
    |
    | o need to clean up all the descriptions, matching anything to the current project-descriptor.xml
file and
  @@ -99,6 +96,15 @@
             <defaultValue>jar</defaultValue>
           </field>
           <field>
  +          <name>modules</name>
  +          <version>4.0.0</version>
  +          <description>The modules to build in addition to the current project</description>
  +          <association>
  +            <type>String</type>
  +            <multiplicity>*</multiplicity>
  +          </association>
  +        </field>
  +        <field>
             <name>name</name>
             <version>3.0.0+</version>
             <required>true</required>
  
  
  
  1.18      +56 -55    maven-components/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
  
  Index: MavenCli.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- MavenCli.java	10 Mar 2005 16:35:04 -0000	1.17
  +++ MavenCli.java	11 Mar 2005 01:06:47 -0000	1.18
  @@ -28,11 +28,9 @@
   import org.apache.maven.MavenConstants;
   import org.apache.maven.artifact.manager.WagonManager;
   import org.apache.maven.artifact.repository.ArtifactRepository;
  +import org.apache.maven.execution.DefaultMavenExecutionRequest;
   import org.apache.maven.execution.MavenExecutionRequest;
   import org.apache.maven.execution.MavenExecutionResponse;
  -import org.apache.maven.execution.MavenInitializingExecutionRequest;
  -import org.apache.maven.execution.MavenProjectExecutionRequest;
  -import org.apache.maven.execution.MavenReactorExecutionRequest;
   import org.apache.maven.model.user.MavenProfile;
   import org.apache.maven.model.user.UserModel;
   import org.apache.maven.monitor.event.DefaultEventDispatcher;
  @@ -45,10 +43,13 @@
   import org.codehaus.plexus.embed.ArtifactEnabledEmbedder;
   import org.codehaus.plexus.logging.Logger;
   import org.codehaus.plexus.logging.LoggerManager;
  +import org.codehaus.plexus.util.FileUtils;
   
   import java.io.File;
   import java.io.FileInputStream;
   import java.io.IOException;
  +import java.util.Collections;
  +import java.util.List;
   import java.util.Properties;
   
   /**
  @@ -63,7 +64,8 @@
   
       public static File userDir = new File( System.getProperty( "user.dir" ) );
   
  -    public static int main( String[] args, ClassWorld classWorld ) throws Exception
  +    public static int main( String[] args, ClassWorld classWorld )
  +        throws Exception
       {
           // ----------------------------------------------------------------------
           // Setup the command line parser
  @@ -122,27 +124,26 @@
   
           UserModel userModel = UserModelUtils.getUserModel();
   
  -        if ( projectFile.exists() )
  +        if ( commandLine.hasOption( CLIManager.REACTOR ) )
           {
  -            if ( commandLine.hasOption( CLIManager.REACTOR ) )
  -            {
  -                String includes = System.getProperty( "maven.reactor.includes", "**/" +
POMv4 );
  +            String includes = System.getProperty( "maven.reactor.includes", "**/" + POMv4
);
   
  -                String excludes = System.getProperty( "maven.reactor.excludes", POMv4 );
  +            String excludes = System.getProperty( "maven.reactor.excludes", POMv4 );
   
  -                request = new MavenReactorExecutionRequest( localRepository, userModel,
eventDispatcher,
  -                                                            commandLine.getArgList(), includes,
excludes, userDir );
  -            }
  -            else
  -            {
  -                request = new MavenProjectExecutionRequest( localRepository, userModel,
eventDispatcher,
  -                                                            commandLine.getArgList(), projectFile
);
  -            }
  +            request =
  +                new DefaultMavenExecutionRequest( localRepository, userModel, eventDispatcher,
  +                                                  commandLine.getArgList(),
  +                                                  FileUtils.getFiles( userDir, includes,
excludes ), userDir.getPath() );
           }
           else
           {
  -            request = new MavenInitializingExecutionRequest( localRepository, userModel,
eventDispatcher,
  -                                                             commandLine.getArgList() );
  +            List files = Collections.EMPTY_LIST;
  +            if ( projectFile.exists() )
  +            {
  +                files = Collections.singletonList( projectFile );
  +            }
  +            request = new DefaultMavenExecutionRequest( localRepository, userModel, eventDispatcher,
  +                                                        commandLine.getArgList(), files,
userDir.getPath() );
           }
   
           // ----------------------------------------------------------------------
  @@ -191,9 +192,9 @@
           }
       }
   
  -    // ----------------------------------------------------------------------
  -    // System properties handling
  -    // ----------------------------------------------------------------------
  +// ----------------------------------------------------------------------
  +// System properties handling
  +// ----------------------------------------------------------------------
   
       private static void initializeSystemProperties( CommandLine commandLine )
       {
  @@ -237,9 +238,9 @@
           System.setProperty( name, value );
       }
   
  -    // ----------------------------------------------------------------------
  -    // Command line manager
  -    // ----------------------------------------------------------------------
  +// ----------------------------------------------------------------------
  +// Command line manager
  +// ----------------------------------------------------------------------
   
       static class CLIManager
       {
  @@ -264,30 +265,28 @@
           public CLIManager()
           {
               options = new Options();
  -            options.addOption( OptionBuilder.withLongOpt( "nobanner" ).withDescription(
"Suppress logo banner" )
  -                                            .create( NO_BANNER ) );
  -            options
  -                   .addOption( OptionBuilder.withLongOpt( "define" ).hasArg()
  -                                            .withDescription( "Define a system property"
).create( SET_SYSTEM_PROPERTY ) );
  -            options.addOption( OptionBuilder.withLongOpt( "offline" ).hasArg().withDescription(
"Work offline" )
  -                                            .create( WORK_OFFLINE ) );
  -            options
  -                   .addOption( OptionBuilder.withLongOpt( "mojoDescriptors" )
  -                                            .withDescription( "Display available mojoDescriptors"
).create( LIST_GOALS ) );
  -            options.addOption( OptionBuilder.withLongOpt( "help" ).withDescription( "Display
help information" )
  -                                            .create( HELP ) );
  -            options.addOption( OptionBuilder.withLongOpt( "offline" ).withDescription(
"Build is happening offline" )
  -                                            .create( WORK_OFFLINE ) );
  -            options.addOption( OptionBuilder.withLongOpt( "version" ).withDescription(
"Display version information" )
  -                                            .create( VERSION ) );
  -            options.addOption( OptionBuilder.withLongOpt( "debug" ).withDescription( "Produce
execution debug output" )
  -                                            .create( DEBUG ) );
  -            options.addOption( OptionBuilder.withLongOpt( "reactor" )
  -                                            .withDescription( "Execute goals for project
found in the reactor" )
  -                                            .create( REACTOR ) );
  +            options.addOption( OptionBuilder.withLongOpt( "nobanner" ).withDescription(
"Suppress logo banner" ).create(
  +                NO_BANNER ) );
  +            options.addOption( OptionBuilder.withLongOpt( "define" ).hasArg().withDescription(
  +                "Define a system property" ).create( SET_SYSTEM_PROPERTY ) );
  +            options.addOption( OptionBuilder.withLongOpt( "offline" ).hasArg().withDescription(
"Work offline" ).create(
  +                WORK_OFFLINE ) );
  +            options.addOption( OptionBuilder.withLongOpt( "mojoDescriptors" ).withDescription(
  +                "Display available mojoDescriptors" ).create( LIST_GOALS ) );
  +            options.addOption( OptionBuilder.withLongOpt( "help" ).withDescription( "Display
help information" ).create(
  +                HELP ) );
  +            options.addOption( OptionBuilder.withLongOpt( "offline" ).withDescription(
"Build is happening offline" ).create(
  +                WORK_OFFLINE ) );
  +            options.addOption( OptionBuilder.withLongOpt( "version" ).withDescription(
"Display version information" ).create(
  +                VERSION ) );
  +            options.addOption( OptionBuilder.withLongOpt( "debug" ).withDescription( "Produce
execution debug output" ).create(
  +                DEBUG ) );
  +            options.addOption( OptionBuilder.withLongOpt( "reactor" ).withDescription(
  +                "Execute goals for project found in the reactor" ).create( REACTOR ) );
           }
   
  -        public CommandLine parse( String[] args ) throws ParseException
  +        public CommandLine parse( String[] args )
  +            throws ParseException
           {
               CommandLineParser parser = new PosixParser();
               return parser.parse( options, args );
  @@ -300,9 +299,9 @@
           }
       }
   
  -    // ----------------------------------------------------------------------
  -    //
  -    // ----------------------------------------------------------------------
  +// ----------------------------------------------------------------------
  +//
  +// ----------------------------------------------------------------------
   
       protected static File getUserConfigurationDirectory()
       {
  @@ -311,7 +310,7 @@
           {
               if ( !mavenUserConfigurationDirectory.mkdirs() )
               {
  -                //throw a configuration exception
  +//throw a configuration exception
               }
           }
           return mavenUserConfigurationDirectory;
  @@ -332,7 +331,8 @@
           return mavenProperties;
       }
   
  -    protected static ArtifactRepository getLocalRepository() throws Exception
  +    protected static ArtifactRepository getLocalRepository()
  +        throws Exception
       {
           UserModel userModel = UserModelUtils.getUserModel();
           MavenProfile mavenProfile = UserModelUtils.getActiveMavenProfile( userModel );
  @@ -346,10 +346,11 @@
           if ( localRepository == null )
           {
               String userConfigurationDirectory = System.getProperty( "user.home" ) + "/.m2";
  -            localRepository = new File( userConfigurationDirectory, MavenConstants.MAVEN_REPOSITORY
).getAbsolutePath();
  +            localRepository =
  +                new File( userConfigurationDirectory, MavenConstants.MAVEN_REPOSITORY ).getAbsolutePath();
           }
   
  -        // TODO [BP]: this should not be necessary - grep for and remove
  +// TODO [BP]: this should not be necessary - grep for and remove
           System.setProperty( MavenConstants.MAVEN_REPO_LOCAL, localRepository );
           return new ArtifactRepository( "local", "file://" + localRepository );
       }
  
  
  
  1.10      +8 -7      maven-components/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java
  
  Index: MavenExecutionRequest.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- MavenExecutionRequest.java	9 Mar 2005 22:13:05 -0000	1.9
  +++ MavenExecutionRequest.java	11 Mar 2005 01:06:47 -0000	1.10
  @@ -36,21 +36,22 @@
   
       List getGoals();
   
  -    String getType();
  -
       void setSession( MavenSession session );
   
       MavenSession getSession();
   
  -    List getProjectFiles() throws IOException;
  +    List getProjectFiles()
  +        throws IOException;
   
       void setLog( Log log );
  -    
  +
       Log getLog();
   
       void addEventMonitor( EventMonitor monitor );
  -    
  +
       EventDispatcher getEventDispatcher();
  -    
  +
       UserModel getUserModel();
  +
  +    String getBaseDirectory();
   }
  
  
  
  1.1                  maven-components/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
  
  Index: DefaultMavenExecutionRequest.java
  ===================================================================
  package org.apache.maven.execution;
  
  /* ====================================================================
   *   Copyright 2001-2004 The Apache Software Foundation.
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *   limitations under the License.
   * ====================================================================
   */
  
  import org.apache.maven.artifact.repository.ArtifactRepository;
  import org.apache.maven.model.user.UserModel;
  import org.apache.maven.monitor.event.EventDispatcher;
  import org.apache.maven.monitor.event.EventMonitor;
  import org.apache.maven.monitor.logging.Log;
  
  import java.util.List;
  
  /**
   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
   * @version $Id: DefaultMavenExecutionRequest.java,v 1.1 2005/03/11 01:06:47 brett Exp $
   */
  public class DefaultMavenExecutionRequest
      implements MavenExecutionRequest
  {
      /**
       * @todo [BP] is this required? This hands off to MavenSession, but could be passed
through the handler.handle function (+ createSession).
       */
      private final ArtifactRepository localRepository;
  
      private final List goals;
  
      private final List files;
  
      protected MavenSession session;
  
      private Log log;
  
      private final EventDispatcher eventDispatcher;
  
      private final UserModel userModel;
  
      private final String baseDirectory;
  
      public DefaultMavenExecutionRequest( ArtifactRepository localRepository, UserModel userModel,
                                           EventDispatcher eventDispatcher, List goals, List
files, String baseDirectory )
      {
          this.localRepository = localRepository;
  
          this.userModel = userModel;
  
          this.goals = goals;
  
          this.eventDispatcher = eventDispatcher;
  
          this.files = files;
  
          this.baseDirectory = baseDirectory;
      }
  
      public UserModel getUserModel()
      {
          return userModel;
      }
  
      public String getBaseDirectory()
      {
          return baseDirectory;
      }
  
      public ArtifactRepository getLocalRepository()
      {
          return localRepository;
      }
  
      public List getGoals()
      {
          return goals;
      }
  
      // ----------------------------------------------------------------------
      // Putting the session here but it can probably be folded right in here.
      // ----------------------------------------------------------------------
  
      public MavenSession getSession()
      {
          return session;
      }
  
      public List getProjectFiles()
      {
          return files;
      }
  
      public void setSession( MavenSession session )
      {
          this.session = session;
      }
  
      public void setLog( Log log )
      {
          this.log = log;
      }
  
      public Log getLog()
      {
          return log;
      }
  
      public void addEventMonitor( EventMonitor monitor )
      {
          eventDispatcher.addEventMonitor( monitor );
      }
  
      public EventDispatcher getEventDispatcher()
      {
          return eventDispatcher;
      }
  
      public List getFiles()
      {
          return files;
      }
  }
  
  
  
  1.42      +19 -15    maven-components/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
  
  Index: DefaultMavenProjectBuilder.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- DefaultMavenProjectBuilder.java	10 Mar 2005 23:01:35 -0000	1.41
  +++ DefaultMavenProjectBuilder.java	11 Mar 2005 01:06:47 -0000	1.42
  @@ -119,10 +119,11 @@
                   previous = current;
               }
   
  +            pathTranslator.alignToBaseDirectory( project.getModel(), projectDescriptor
);
  +
               project = processProjectLogic( project, localRepository, resolveDependencies
);
   
               project.setFile( projectDescriptor );
  -            pathTranslator.alignToBaseDirectory( project.getModel(), projectDescriptor
);
   
               return project;
           }
  @@ -133,7 +134,7 @@
       }
   
       private MavenProject processProjectLogic( MavenProject project, ArtifactRepository
localRepository,
  -                                             boolean resolveDependencies )
  +                                              boolean resolveDependencies )
           throws ProjectBuildingException, ModelInterpolationException, ArtifactResolutionException
       {
           Model model = modelInterpolator.interpolate( project.getModel() );
  @@ -186,7 +187,7 @@
       }
   
       private MavenProject assembleLineage( File projectDescriptor, ArtifactRepository localRepository,
  -                                         LinkedList lineage, List aggregatedRemoteWagonRepositories
)
  +                                          LinkedList lineage, List aggregatedRemoteWagonRepositories
)
           throws ProjectBuildingException
       {
           Model model = readModel( projectDescriptor );
  @@ -253,7 +254,8 @@
           return repos;
       }
   
  -    private Model readModel( File file ) throws ProjectBuildingException
  +    private Model readModel( File file )
  +        throws ProjectBuildingException
       {
           try
           {
  @@ -266,12 +268,12 @@
           catch ( Exception e )
           {
               throw new ProjectBuildingException(
  -                                                "Error while reading model from file '"
+ file.getAbsolutePath() + "'.",
  -                                                e );
  +                "Error while reading model from file '" + file.getAbsolutePath() + "'.",
e );
           }
       }
   
  -    private Model readModel( URL url ) throws ProjectBuildingException
  +    private Model readModel( URL url )
  +        throws ProjectBuildingException
       {
           try
           {
  @@ -300,8 +302,8 @@
           catch ( ArtifactResolutionException e )
           {
               // @todo use parent.toString() if modello could generate it, or specify in
a code segment
  -            throw new ProjectBuildingException( "Missing parent POM: " + parent.getGroupId()
+ ":"
  -                + parent.getArtifactId() + "-" + parent.getVersion(), e );
  +            throw new ProjectBuildingException( "Missing parent POM: " + parent.getGroupId()
+ ":" +
  +                                                parent.getArtifactId() + "-" + parent.getVersion(),
e );
           }
   
           return artifact.getFile();
  @@ -318,7 +320,8 @@
        * <li>do a topo sort on the graph that remains.</li>
        * </ul>
        */
  -    public List getSortedProjects( List projects ) throws CycleDetectedException
  +    public List getSortedProjects( List projects )
  +        throws CycleDetectedException
       {
           DAG dag = new DAG();
   
  @@ -367,11 +370,11 @@
       }
   
       public MavenProject buildSuperProject( ArtifactRepository localRepository )
  -    throws ProjectBuildingException
  +        throws ProjectBuildingException
       {
  -            return buildSuperProject( localRepository, false );
  +        return buildSuperProject( localRepository, false );
       }
  -    
  +
       public MavenProject buildSuperProject( ArtifactRepository localRepository, boolean
resolveDependencies )
           throws ProjectBuildingException
       {
  @@ -380,7 +383,7 @@
           try
           {
               project = processProjectLogic( project, localRepository, resolveDependencies
);
  -            
  +
               File projectFile = new File( ".", "pom.xml" );
               project.setFile( projectFile );
               pathTranslator.alignToBaseDirectory( project.getModel(), projectFile );
  @@ -401,7 +404,8 @@
       //
       // ----------------------------------------------------------------------
   
  -    private Model getSuperModel() throws ProjectBuildingException
  +    private Model getSuperModel()
  +        throws ProjectBuildingException
       {
           URL url = DefaultMavenProjectBuilder.class.getResource( "pom-" + MavenConstants.MAVEN_MODEL_VERSION
+ ".xml" );
   
  
  
  
  1.27      +5 -0      maven-components/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
  
  Index: MavenProject.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/project/MavenProject.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- MavenProject.java	10 Mar 2005 23:01:35 -0000	1.26
  +++ MavenProject.java	11 Mar 2005 01:06:47 -0000	1.27
  @@ -525,6 +525,11 @@
           return model.getBuild().getPlugins();
       }
   
  +    public List getModules()
  +    {
  +        return model.getModules();
  +    }
  +
       public PluginManagement getPluginManagement()
       {
           PluginManagement pluginMgmt = null;
  
  
  
  1.27      +113 -115  maven-components/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
  
  Index: DefaultMaven.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/DefaultMaven.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- DefaultMaven.java	10 Mar 2005 23:01:38 -0000	1.26
  +++ DefaultMaven.java	11 Mar 2005 01:06:48 -0000	1.27
  @@ -19,10 +19,9 @@
   
   import org.apache.maven.artifact.manager.WagonManager;
   import org.apache.maven.artifact.repository.ArtifactRepository;
  +import org.apache.maven.execution.DefaultMavenExecutionRequest;
   import org.apache.maven.execution.MavenExecutionRequest;
   import org.apache.maven.execution.MavenExecutionResponse;
  -import org.apache.maven.execution.MavenProjectExecutionRequest;
  -import org.apache.maven.execution.MavenReactorExecutionRequest;
   import org.apache.maven.execution.MavenSession;
   import org.apache.maven.lifecycle.GoalNotFoundException;
   import org.apache.maven.lifecycle.LifecycleExecutor;
  @@ -44,11 +43,14 @@
   import org.codehaus.plexus.i18n.I18N;
   import org.codehaus.plexus.logging.AbstractLogEnabled;
   import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
  +import org.codehaus.plexus.util.FileUtils;
  +import org.codehaus.plexus.util.StringUtils;
   import org.codehaus.plexus.util.dag.CycleDetectedException;
   
   import java.io.File;
   import java.io.IOException;
   import java.util.ArrayList;
  +import java.util.Collections;
   import java.util.Date;
   import java.util.Iterator;
   import java.util.List;
  @@ -79,100 +81,18 @@
       // Project execution
       // ----------------------------------------------------------------------
   
  -    public MavenExecutionResponse execute( MavenExecutionRequest request ) throws GoalNotFoundException,
Exception
  -    {
  -        // TODO: not happy about this:
  -        if ( request instanceof MavenReactorExecutionRequest )
  -        {
  -            return handleReactor( (MavenReactorExecutionRequest) request );
  -        }
  -        else
  -        {
  -            return handleProject( request );
  -        }
  -    }
  -
  -    // TODO: don't throw generic exception
  -    public MavenExecutionResponse handleProject( MavenExecutionRequest request ) throws
Exception
  -    {
  -        MavenSession session = createSession( request );
  -
  -        List projectFiles = request.getProjectFiles();
  -        
  -        MavenProject project = null;
  -        if(projectFiles != null && !projectFiles.isEmpty())
  -        {
  -            project = getProject( (File) request.getProjectFiles().get( 0 ), request.getLocalRepository()
);
  -        }
  -        else
  -        {
  -            project = projectBuilder.buildSuperProject( request.getLocalRepository() );
  -        }
  -
  -        session.setProject( project );
  -
  -        resolveParameters( request );
  -
  -        // !! This is ripe for refactoring to an aspect.
  -        // Event monitoring.
  -        EventDispatcher dispatcher = request.getEventDispatcher();
  -        String event = MavenEvents.PROJECT_EXECUTION;
  -
  -        dispatcher.dispatchStart( event, project.getId() );
  -
  -        MavenExecutionResponse response = null;
  -        try
  -        {
  -            // Actual meat of the code.
  -            response = lifecycleExecutor.execute( request.getGoals(), session );
  -
  -            dispatcher.dispatchEnd( event, project.getId() );
  -        }
  -        catch ( Exception e )
  -        {
  -            dispatcher.dispatchError( event, project.getId(), e );
  -        }
  -        // End event monitoring.
  -
  -        // TODO: is this perhaps more appropriate in the CLI?
  -        if ( response.isExecutionFailure() )
  -        {
  -            if ( response.getException() != null )
  -            {
  -                // TODO: this should be a "FATAL" exception, reported to the
  -                // developers - however currently a LOT of
  -                // "user" errors fall through the cracks (like invalid POMs, as
  -                // one example)
  -                logError( response );
  -            }
  -            else
  -            {
  -                logFailure( response );
  -            }
  -        }
  -        else
  -        {
  -            logSuccess( response );
  -        }
  -        return response;
  -    }
  -
  -    // ----------------------------------------------------------------------
  -    // Reactor
  -    // ----------------------------------------------------------------------
  -
  -    public MavenExecutionResponse handleReactor( MavenReactorExecutionRequest request )
throws ReactorException
  +    public MavenExecutionResponse execute( MavenExecutionRequest request )
  +        throws GoalNotFoundException, Exception
       {
           EventDispatcher dispatcher = request.getEventDispatcher();
           String event = MavenEvents.REACTOR_EXECUTION;
   
  -        dispatcher.dispatchStart( event, request.getBaseDirectory().getPath() );
  +        // TODO: goals are outer loop
  +        dispatcher.dispatchStart( event, request.getBaseDirectory() );
           try
           {
               List projects = new ArrayList();
   
  -            getLogger().info( "Starting the reactor..." );
  -
               try
               {
                   List files = request.getProjectFiles();
  @@ -188,6 +108,10 @@
   
                   projects = projectBuilder.getSortedProjects( projects );
   
  +                if ( projects.isEmpty() )
  +                {
  +                    projects.add( projectBuilder.buildSuperProject( request.getLocalRepository()
) );
  +                }
               }
               catch ( IOException e )
               {
  @@ -202,59 +126,131 @@
                   throw new ReactorException( "Error processing projects for the reactor:
", e );
               }
   
  -            getLogger().info( "Our processing order:" );
  -
  -            for ( Iterator iterator = projects.iterator(); iterator.hasNext(); )
  -            {
  -                MavenProject project = (MavenProject) iterator.next();
  -
  -                getLogger().info( project.getName() );
  -            }
  -
               for ( Iterator iterator = projects.iterator(); iterator.hasNext(); )
               {
                   MavenProject project = (MavenProject) iterator.next();
   
  -                System.out.println( "\n\n\n" );
  -
                   line();
   
                   getLogger().info( "Building " + project.getName() );
   
                   line();
   
  -                MavenProjectExecutionRequest projectExecutionRequest = request.createProjectExecutionRequest(
project );
  -
                   try
                   {
  -                    MavenExecutionResponse response = handleProject( projectExecutionRequest
);
  +                    boolean isPom = "pom".equals( project.getPackaging() );
  +                    if ( isPom )
  +                    {
  +                        // TODO: not required if discovered and cached
  +                        MavenExecutionResponse response = processProject( request, project,
dispatcher,
  +                                                                          Collections.singletonList(
"pom:install" ) );
  +                        if ( response.isExecutionFailure() )
  +                        {
  +                            return response;
  +                        }
  +                    }
  +
  +                    if ( project.getModules() != null && !project.getModules().isEmpty()
)
  +                    {
  +                        String includes = StringUtils.join( project.getModules().iterator(),
"/pom.xml," ) +
  +                            "/pom.xml";
  +                        File baseDir = project.getFile().getParentFile();
  +                        MavenExecutionRequest reactorRequest = new DefaultMavenExecutionRequest(
  +                            request.getLocalRepository(), request.getUserModel(), request.getEventDispatcher(),
  +                            request.getGoals(), FileUtils.getFiles( baseDir, includes,
null ), baseDir.getPath() );
  +                        MavenExecutionResponse response = execute( reactorRequest );
  +                        if ( response != null && response.isExecutionFailure()
)
  +                        {
  +                            return response;
  +                        }
  +
  +                    }
   
  -                    if ( response.isExecutionFailure() )
  +                    if ( !isPom )
                       {
  -                        return response;
  +                        MavenExecutionResponse response = processProject( request, project,
dispatcher,
  +                                                                          request.getGoals()
);
  +
  +                        if ( response.isExecutionFailure() )
  +                        {
  +                            return response;
  +                        }
                       }
                   }
                   catch ( Exception e )
                   {
                       throw new ReactorException( "Error executing project within the reactor",
e );
                   }
  -
               }
   
  -            dispatcher.dispatchEnd( event, request.getBaseDirectory().getPath() );
  +            dispatcher.dispatchEnd( event, request.getBaseDirectory() );
   
               // TODO: not really satisfactory
               return null;
           }
           catch ( ReactorException e )
           {
  -            dispatcher.dispatchError( event, request.getBaseDirectory().getPath(), e );
  +            dispatcher.dispatchError( event, request.getBaseDirectory(), e );
   
               throw e;
           }
       }
   
  -    public MavenProject getProject( File pom, ArtifactRepository localRepository ) throws
ProjectBuildingException
  +    private MavenExecutionResponse processProject( MavenExecutionRequest request, MavenProject
project,
  +                                                   EventDispatcher dispatcher, List goals
)
  +        throws ComponentLookupException
  +    {
  +        MavenSession session = createSession( request );
  +
  +        session.setProject( project );
  +
  +        resolveParameters( request );
  +
  +        // !! This is ripe for refactoring to an aspect.
  +        // Event monitoring.
  +        String event = MavenEvents.PROJECT_EXECUTION;
  +
  +        dispatcher.dispatchStart( event, project.getId() );
  +
  +        MavenExecutionResponse response = null;
  +        try
  +        {
  +            // Actual meat of the code.
  +            response = lifecycleExecutor.execute( goals, session );
  +
  +            dispatcher.dispatchEnd( event, project.getId() );
  +        }
  +        catch ( Exception e )
  +        {
  +            dispatcher.dispatchError( event, project.getId(), e );
  +        }
  +        // End event monitoring.
  +
  +        // TODO: is this perhaps more appropriate in the CLI?
  +        if ( response.isExecutionFailure() )
  +        {
  +            if ( response.getException() != null )
  +            {
  +                // TODO: this should be a "FATAL" exception, reported to the
  +                // developers - however currently a LOT of
  +                // "user" errors fall through the cracks (like invalid POMs, as
  +                // one example)
  +                logError( response );
  +            }
  +            else
  +            {
  +                logFailure( response );
  +            }
  +        }
  +        else
  +        {
  +            logSuccess( response );
  +        }
  +        return response;
  +    }
  +
  +    public MavenProject getProject( File pom, ArtifactRepository localRepository )
  +        throws ProjectBuildingException
       {
           if ( pom.exists() )
           {
  @@ -284,9 +280,10 @@
   
       /**
        * @todo [BP] this might not be required if there is a better way to pass
  -     *       them in. It doesn't feel quite right.
  +     * them in. It doesn't feel quite right.
        */
  -    private void resolveParameters( MavenExecutionRequest request ) throws ComponentLookupException
  +    private void resolveParameters( MavenExecutionRequest request )
  +        throws ComponentLookupException
       {
           WagonManager wagonManager = (WagonManager) container.lookup( WagonManager.ROLE
);
   
  @@ -307,7 +304,8 @@
       // Lifecylce Management
       // ----------------------------------------------------------------------
   
  -    public void contextualize( Context context ) throws ContextException
  +    public void contextualize( Context context )
  +        throws ContextException
       {
           container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
       }
  @@ -381,9 +379,8 @@
   
           Runtime r = Runtime.getRuntime();
   
  -        getLogger().info(
  -                          "Final Memory: " + ( ( r.totalMemory() - r.freeMemory() ) / mb
) + "M/"
  -                              + ( r.totalMemory() / mb ) + "M" );
  +        getLogger().info( "Final Memory: " + ( ( r.totalMemory() - r.freeMemory() ) / mb
) + "M/" +
  +                          ( r.totalMemory() / mb ) + "M" );
       }
   
       protected void line()
  @@ -417,7 +414,8 @@
       // Reactor
       // ----------------------------------------------------------------------
   
  -    public List getSortedProjects( List projects ) throws CycleDetectedException
  +    public List getSortedProjects( List projects )
  +        throws CycleDetectedException
       {
           return projectBuilder.getSortedProjects( projects );
       }
  
  
  
  1.8       +7 -4      maven-components/sandbox/pom-pre-alpha-converter/src/main/java/org/apache/maven/tools/converter/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/maven-components/sandbox/pom-pre-alpha-converter/src/main/java/org/apache/maven/tools/converter/Main.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Main.java	10 Mar 2005 18:36:35 -0000	1.7
  +++ Main.java	11 Mar 2005 01:06:48 -0000	1.8
  @@ -104,7 +104,9 @@
   
                       org.apache.maven.model.Model newModel = new org.apache.maven.model.Model();
                       newModel.setArtifactId( model.getArtifactId() );
  -                    newModel.setBuild( convertBuild( model.getBuild(), convertPlugins(
model.getPlugins() ) ) );
  +                    newModel.setBuild(
  +                        convertBuild( model.getBuild(), convertPlugins( model.getPlugins()
),
  +                                      convertPluginManagement( model.getPluginManagement()
) ) );
                       newModel.setCiManagement( convertCiManagement( model.getCiManagement()
) );
                       newModel.setContributors( convertContributors( model.getContributors()
) );
                       newModel.setDependencies( convertDependencies( model.getDependencies()
) );
  @@ -124,7 +126,6 @@
                       newModel.setOrganization( convertOrganization( model.getOrganization()
) );
                       newModel.setPackaging( model.getType() );
                       newModel.setParent( convertParent( model.getParent() ) );
  -                    newModel.setPluginManagement( convertPluginManagement( model.getPluginManagement()
) );
                       newModel.setPluginRepositories( convertRepositories( model.getPluginRepositories()
) );
                       newModel.setReports( convertReports( model.getReports() ) );
                       newModel.setRepositories( convertRepositories( model.getRepositories()
) );
  @@ -464,7 +465,8 @@
           return newPlugins;
       }
   
  -    private static org.apache.maven.model.Build convertBuild( Build build, Map plugins
)
  +    private static org.apache.maven.model.Build convertBuild( Build build, Map plugins,
  +                                                              org.apache.maven.model.PluginManagement
pluginManagement )
       {
           if ( build == null && plugins.isEmpty() )
           {
  @@ -490,6 +492,7 @@
           newBuild.setTestOutputDirectory( build.getTestOutput() );
           newBuild.setTestSourceDirectory( build.getUnitTestSourceDirectory() );
           newBuild.setResources( convertResources( build.getResources() ) );
  +        newBuild.setPluginManagement( pluginManagement );
   
           if ( build.getUnitTest() != null )
           {
  
  
  

Mime
View raw message