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
Date Fri, 25 Feb 2005 03:48:17 GMT
brett       2005/02/24 19:48:17

  Modified:    maven-core/src/main/java/org/apache/maven/cli MavenCli.java
               maven-core/src/main/java/org/apache/maven/execution
                        MavenReactorExecutionRequest.java
               maven-core/src/main/java/org/apache/maven DefaultMaven.java
  Log:
  bring back the reactor (instantiation still needs work - see comments)
  
  Revision  Changes    Path
  1.11      +3 -5      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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- MavenCli.java	16 Feb 2005 07:16:31 -0000	1.10
  +++ MavenCli.java	25 Feb 2005 03:48:17 -0000	1.11
  @@ -136,8 +136,6 @@
               request = new MavenInitializingExecutionRequest( localRepository, mavenProperties,
commandLine.getArgList() );
           }
   
  -        MavenExecutionResponse response = new MavenExecutionResponse();
  -
           // ----------------------------------------------------------------------
           // Now that we have everything that we need we will fire up plexus and
           // bring the maven component to life for use.
  @@ -158,9 +156,9 @@
           //
           // ----------------------------------------------------------------------
   
  -        response = maven.execute( request );
  +        MavenExecutionResponse response = maven.execute( request );
   
  -        if ( response.isExecutionFailure() )
  +        if ( response != null && response.isExecutionFailure() )
           {
               return 1;
           }
  
  
  
  1.2       +9 -5      maven-components/maven-core/src/main/java/org/apache/maven/execution/MavenReactorExecutionRequest.java
  
  Index: MavenReactorExecutionRequest.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/execution/MavenReactorExecutionRequest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MavenReactorExecutionRequest.java	16 Feb 2005 07:16:32 -0000	1.1
  +++ MavenReactorExecutionRequest.java	25 Feb 2005 03:48:17 -0000	1.2
  @@ -18,10 +18,11 @@
    */
   
   import org.apache.maven.artifact.repository.ArtifactRepository;
  -import org.apache.maven.execution.AbstractMavenExecutionRequest;
  +import org.apache.maven.project.MavenProject;
   import org.codehaus.plexus.util.FileUtils;
   
   import java.io.File;
  +import java.io.IOException;
   import java.util.List;
   import java.util.Properties;
   
  @@ -68,10 +69,13 @@
       }
   
       public List getProjectFiles()
  -        throws Exception
  +        throws IOException
       {
  -        List files = FileUtils.getFiles( new File( System.getProperty( "user.dir" ) ),
includes, excludes );
  +        return FileUtils.getFiles( new File( System.getProperty( "user.dir" ) ), includes,
excludes );
  +    }
   
  -        return files;
  +    public MavenProjectExecutionRequest createProjectExecutionRequest( MavenProject project
)
  +    {
  +        return new MavenProjectExecutionRequest( localRepository, parameters, goals, project.getFile()
);
       }
   }
  
  
  
  1.19      +34 -17    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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- DefaultMaven.java	25 Feb 2005 03:14:49 -0000	1.18
  +++ DefaultMaven.java	25 Feb 2005 03:48:17 -0000	1.19
  @@ -21,6 +21,7 @@
   import org.apache.maven.artifact.repository.ArtifactRepository;
   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.LifecycleExecutor;
  @@ -39,7 +40,6 @@
   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 java.io.File;
   import java.util.ArrayList;
  @@ -78,14 +78,18 @@
       public MavenExecutionResponse execute( MavenExecutionRequest request )
           throws GoalNotFoundException, Exception
       {
  -        MavenExecutionResponse response = new MavenExecutionResponse();
  -
  -        handleProject( request );
  -
  -        return response;
  +        // TODO: not happy about this:
  +        if ( request instanceof MavenReactorExecutionRequest )
  +        {
  +            return handleReactor( (MavenReactorExecutionRequest) request );
  +        }
  +        else
  +        {
  +            return handleProject( request );
  +        }
       }
   
  -    public void handleProject( MavenExecutionRequest request )
  +    public MavenExecutionResponse handleProject( MavenExecutionRequest request )
           throws Exception
       {
           MavenSession session = createSession( request );
  @@ -98,10 +102,13 @@
   
           MavenExecutionResponse response = lifecycleExecutor.execute( request.getGoals(),
session );
   
  +        // 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
  @@ -113,14 +120,15 @@
           {
               logSuccess( response );
           }
  +        return response;
       }
   
       // ----------------------------------------------------------------------
       // Reactor
       // ----------------------------------------------------------------------
   
  -    public void handleReactor( MavenExecutionRequest request, MavenExecutionResponse response
)
  -        throws Exception
  +    public MavenExecutionResponse handleReactor( MavenReactorExecutionRequest request )
  +        throws ReactorException
       {
           List projects = new ArrayList();
   
  @@ -128,9 +136,7 @@
   
           try
           {
  -            List files = FileUtils.getFiles( new File( System.getProperty( "user.dir" )
),
  -                                             ( (MavenReactorExecutionRequest) request ).getIncludes(),
  -                                             ( (MavenReactorExecutionRequest) request ).getExcludes()
);
  +            List files = request.getProjectFiles();
   
               for ( Iterator iterator = files.iterator(); iterator.hasNext(); )
               {
  @@ -169,15 +175,26 @@
   
               line();
   
  -            //MavenProjectExecutionRequest projectExecutionRequest = request.createProjectExecutionRequest(
project );
  +            MavenProjectExecutionRequest projectExecutionRequest = request.createProjectExecutionRequest(
project );
   
  -            //handleProject( projectExecutionRequest, response );
  +            try
  +            {
  +                MavenExecutionResponse response = handleProject( projectExecutionRequest
);
   
  -            if ( response.isExecutionFailure() )
  +                if ( response.isExecutionFailure() )
  +                {
  +                    return response;
  +                }
  +            }
  +            catch ( Exception e )
               {
  -                break;
  +                throw new ReactorException( "Error executing project within the reactor",
e );
               }
  +
           }
  +
  +        // TODO: not really satisfactory
  +        return null;
       }
   
       public MavenProject getProject( File pom, ArtifactRepository localRepository )
  
  
  

Mime
View raw message