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/src/main/java/org/apache/maven DefaultMaven.java Maven.java
Date Tue, 15 Mar 2005 23:31:23 GMT
brett       2005/03/15 15:31:23

  Modified:    maven-core/src/main/java/org/apache/maven/execution
                        DefaultMavenExecutionRequest.java
                        MavenExecutionRequest.java
               maven-core/src/main/java/org/apache/maven DefaultMaven.java
                        Maven.java
  Log:
  PR: MNG-191
  collect proejcts and modules first, then execute reactor
  
  Revision  Changes    Path
  1.2       +1 -6      maven-components/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
  
  Index: DefaultMavenExecutionRequest.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultMavenExecutionRequest.java	11 Mar 2005 01:06:47 -0000	1.1
  +++ DefaultMavenExecutionRequest.java	15 Mar 2005 23:31:23 -0000	1.2
  @@ -96,11 +96,6 @@
           return session;
       }
   
  -    public List getProjectFiles()
  -    {
  -        return files;
  -    }
  -
       public void setSession( MavenSession session )
       {
           this.session = session;
  
  
  
  1.11      +2 -4      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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- MavenExecutionRequest.java	11 Mar 2005 01:06:47 -0000	1.10
  +++ MavenExecutionRequest.java	15 Mar 2005 23:31:23 -0000	1.11
  @@ -23,7 +23,6 @@
   import org.apache.maven.monitor.event.EventMonitor;
   import org.apache.maven.monitor.logging.Log;
   
  -import java.io.IOException;
   import java.util.List;
   
   /**
  @@ -40,8 +39,7 @@
   
       MavenSession getSession();
   
  -    List getProjectFiles()
  -        throws IOException;
  +    List getFiles();
   
       void setLog( Log log );
   
  
  
  
  1.30      +45 -53    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.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- DefaultMaven.java	15 Mar 2005 21:41:04 -0000	1.29
  +++ DefaultMaven.java	15 Mar 2005 23:31:23 -0000	1.30
  @@ -20,11 +20,9 @@
   import org.apache.maven.artifact.manager.WagonManager;
   import org.apache.maven.artifact.repository.ArtifactRepository;
   import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
  -import org.apache.maven.execution.DefaultMavenExecutionRequest;
   import org.apache.maven.execution.MavenExecutionRequest;
   import org.apache.maven.execution.MavenExecutionResponse;
   import org.apache.maven.execution.MavenSession;
  -import org.apache.maven.lifecycle.GoalNotFoundException;
   import org.apache.maven.lifecycle.LifecycleExecutor;
   import org.apache.maven.model.Repository;
   import org.apache.maven.model.user.ProxyProfile;
  @@ -78,7 +76,7 @@
       protected LifecycleExecutor lifecycleExecutor;
   
       protected PlexusContainer container;
  -    
  +
       protected ArtifactRepositoryFactory artifactRepositoryFactory;
   
       // ----------------------------------------------------------------------
  @@ -86,7 +84,7 @@
       // ----------------------------------------------------------------------
   
       public MavenExecutionResponse execute( MavenExecutionRequest request )
  -        throws GoalNotFoundException, Exception
  +        throws ReactorException
       {
           EventDispatcher dispatcher = request.getEventDispatcher();
           String event = MavenEvents.REACTOR_EXECUTION;
  @@ -95,20 +93,11 @@
           dispatcher.dispatchStart( event, request.getBaseDirectory() );
           try
           {
  -            List projects = new ArrayList();
  +            List projects;
   
               try
               {
  -                List files = request.getProjectFiles();
  -
  -                for ( Iterator iterator = files.iterator(); iterator.hasNext(); )
  -                {
  -                    File file = (File) iterator.next();
  -
  -                    MavenProject project = getProject( file, request.getLocalRepository()
);
  -
  -                    projects.add( project );
  -                }
  +                projects = collectProjects( request.getFiles(), request.getLocalRepository()
);
   
                   projects = projectBuilder.getSortedProjects( projects );
   
  @@ -142,49 +131,21 @@
   
                   try
                   {
  -                    boolean isPom = "pom".equals( project.getPackaging() );
  -                    if ( isPom )
  +                    List goals;
  +                    if ( "pom".equals( project.getPackaging() ) )
                       {
                           // TODO: not required if discovered and cached
  -                        MavenExecutionResponse response = processProject( request, project,
dispatcher,
  -                                                                          Collections.singletonList(
"pom:install" ) );
  -                        if ( response.isExecutionFailure() )
  -                        {
  -                            return response;
  -                        }
  +                        goals = Collections.singletonList( "pom:install" );
                       }
  -
  -                    if ( project.getModules() != null && !project.getModules().isEmpty()
)
  +                    else
                       {
  -                        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;
  -                        }
  +                        goals = request.getGoals();
                       }
   
  -                    if ( !isPom )
  +                    MavenExecutionResponse response = processProject( request, project,
dispatcher, goals );
  +                    if ( response.isExecutionFailure() )
                       {
  -                        MavenExecutionResponse response = processProject( request, project,
dispatcher,
  -                                                                          request.getGoals()
);
  -
  -                        if ( response.isExecutionFailure() )
  -                        {
  -                            return response;
  -                        }
  +                        return response;
                       }
                   }
                   catch ( Exception e )
  @@ -206,6 +167,37 @@
           }
       }
   
  +    private List collectProjects( List files, ArtifactRepository localRepository )
  +        throws ProjectBuildingException, ReactorException, IOException
  +    {
  +        List projects = new ArrayList( files.size() );
  +
  +        for ( Iterator iterator = files.iterator(); iterator.hasNext(); )
  +        {
  +            File file = (File) iterator.next();
  +
  +            MavenProject project = getProject( file, localRepository );
  +
  +            if ( project.getModules() != null && !project.getModules().isEmpty()
)
  +            {
  +                project.setPackaging( "pom" );
  +
  +                String includes = StringUtils.join( project.getModules().iterator(), "/pom.xml,"
) + "/pom.xml";
  +
  +                if ( includes.indexOf( ".." ) >= 0 )
  +                {
  +                    throw new ReactorException( "Modules may not include '..'" );
  +                }
  +
  +                List moduleFiles = FileUtils.getFiles( project.getFile().getParentFile(),
includes, null );
  +                projects.addAll( collectProjects( moduleFiles, localRepository ) );
  +            }
  +            projects.add( project );
  +        }
  +
  +        return projects;
  +    }
  +
       private MavenExecutionResponse processProject( MavenExecutionRequest request, MavenProject
project,
                                                      EventDispatcher dispatcher, List goals
)
           throws ComponentLookupException
  @@ -213,7 +205,7 @@
           MavenSession session = createSession( request );
   
           session.setProject( project );
  -        
  +
           session.setRemoteRepositories( getArtifactRepositories( project, request.getUserModel()
) );
   
           resolveParameters( request );
  
  
  
  1.13      +3 -3      maven-components/maven-core/src/main/java/org/apache/maven/Maven.java
  
  Index: Maven.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/Maven.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Maven.java	7 Mar 2005 19:03:19 -0000	1.12
  +++ Maven.java	15 Mar 2005 23:31:23 -0000	1.13
  @@ -18,7 +18,7 @@
   
   import org.apache.maven.execution.MavenExecutionRequest;
   import org.apache.maven.execution.MavenExecutionResponse;
  -import org.apache.maven.lifecycle.GoalNotFoundException;
  +import org.apache.maven.reactor.ReactorException;
   
   /**
    * @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
  @@ -28,5 +28,5 @@
   {
       static String ROLE = Maven.class.getName();
   
  -    MavenExecutionResponse execute( MavenExecutionRequest request ) throws GoalNotFoundException,
Exception;
  +    MavenExecutionResponse execute( MavenExecutionRequest request ) throws ReactorException;
   }
  \ No newline at end of file
  
  
  

Mime
View raw message