maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject cvs commit: maven-components/maven-core/src/main/java/org/apache/maven/plugin PluginManager.java
Date Fri, 24 Dec 2004 20:51:46 GMT
jvanzyl     2004/12/24 12:51:45

  Modified:    maven-core/src/main/java/org/apache/maven/cli MavenCli.java
               maven-core/src/main/java/org/apache/maven/execution
                        AbstractMavenExecutionRequestHandler.java
                        MavenExecutionResponse.java
               maven-core/src/main/java/org/apache/maven/execution/project
                        MavenProjectExecutionRequestHandler.java
               maven-core/src/main/java/org/apache/maven/plugin
                        PluginManager.java
  Log:
  
  
  Revision  Changes    Path
  1.5       +22 -24    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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MavenCli.java	24 Dec 2004 17:29:41 -0000	1.4
  +++ MavenCli.java	24 Dec 2004 20:51:45 -0000	1.5
  @@ -28,6 +28,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.initialize.MavenInitializingExecutionRequest;
   import org.apache.maven.execution.project.MavenProjectExecutionRequest;
   import org.apache.maven.execution.reactor.MavenReactorExecutionRequest;
   import org.apache.maven.repository.RepositoryUtils;
  @@ -37,6 +38,7 @@
   import java.io.File;
   import java.io.FileInputStream;
   import java.util.Properties;
  +import java.util.Date;
   
   /**
    * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
  @@ -100,37 +102,33 @@
           }
   
           // ----------------------------------------------------------------------
  -        // Create the execution request/response
  +        // We will ultimately not require a flag to indicate the reactor as
  +        // we should take this from the execution context i.e. what the type
  +        // is stated as in the POM.
           // ----------------------------------------------------------------------
   
           MavenExecutionRequest request = null;
   
  -        if ( commandLine.hasOption( CLIManager.REACTOR ) )
  +        File projectFile = new File( userDir, POMv4 );
  +
  +        if ( projectFile.exists() )
           {
  -            String includes = System.getProperty( "maven.reactor.includes", "**/" + POMv4
);
  +            if ( commandLine.hasOption( CLIManager.REACTOR ) )
  +            {
  +                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,
  -                                                        commandLine.getArgList(),
  -                                                        includes,
  -                                                        excludes,
  -                                                        userDir );
  +                request = new MavenReactorExecutionRequest( localRepository, commandLine.getArgList(),
includes, excludes, userDir );
  +            }
  +            else
  +            {
  +                request = new MavenProjectExecutionRequest( localRepository, commandLine.getArgList(),
projectFile );
  +            }
           }
           else
           {
  -            File projectFile = new File( userDir, POMv4 );
  -
  -            if ( !projectFile.exists() )
  -            {
  -                    System.err.println( "Could not find a project descriptor." );
  -
  -                    return 1;
  -            }
  -
  -            request = new MavenProjectExecutionRequest( localRepository,
  -                                                        commandLine.getArgList(),
  -                                                        projectFile );
  +            request = new MavenInitializingExecutionRequest( localRepository, commandLine.getArgList()
);
           }
   
           MavenExecutionResponse response = new MavenExecutionResponse();
  @@ -337,13 +335,13 @@
           return mavenProperties;
       }
   
  -    protected static ArtifactRepository getLocalRepository( Properties mavenProperties,
File mavenHomeLocal )
  +    protected static ArtifactRepository getLocalRepository( Properties mavenProperties,
File userConfigurationDirectory )
       {
           String localRepository = mavenProperties.getProperty( MavenConstants.MAVEN_REPO_LOCAL
);
   
           if ( localRepository == null )
           {
  -            localRepository = new File( mavenHomeLocal, MavenConstants.MAVEN_REPOSITORY
).getAbsolutePath();
  +            localRepository = new File( userConfigurationDirectory, MavenConstants.MAVEN_REPOSITORY
).getAbsolutePath();
           }
   
           System.setProperty( MavenConstants.MAVEN_REPO_LOCAL, localRepository );
  
  
  
  1.3       +98 -1     maven-components/maven-core/src/main/java/org/apache/maven/execution/AbstractMavenExecutionRequestHandler.java
  
  Index: AbstractMavenExecutionRequestHandler.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/execution/AbstractMavenExecutionRequestHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractMavenExecutionRequestHandler.java	24 Dec 2004 17:29:41 -0000	1.2
  +++ AbstractMavenExecutionRequestHandler.java	24 Dec 2004 20:51:45 -0000	1.3
  @@ -13,6 +13,8 @@
   import org.codehaus.plexus.logging.AbstractLogEnabled;
   import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
   
  +import java.util.Date;
  +
   /**
    * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
    * @version $Id$
  @@ -61,5 +63,100 @@
       public void contextualize( Context context ) throws ContextException
       {
           container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
  +    }
  +
  +    // ----------------------------------------------------------------------
  +    // Reporting / Logging
  +    // ----------------------------------------------------------------------
  +
  +    protected void logError( MavenExecutionResponse r )
  +    {
  +        line();
  +
  +        getLogger().error( "BUILD ERROR" );
  +
  +        line();
  +
  +        getLogger().error( "Cause: ", r.getException() );
  +
  +        line();
  +
  +        stats( r.getStart(), r.getFinish() );
  +
  +        line();
  +    }
  +
  +    protected void logFailure( MavenExecutionResponse r )
  +    {
  +        line();
  +
  +        getLogger().info( "BUILD FAILURE" );
  +
  +        line();
  +
  +        getLogger().info( "Reason: " + r.getFailureResponse().shortMessage() );
  +
  +        line();
  +
  +        getLogger().info( r.getFailureResponse().longMessage() );
  +
  +        line();
  +
  +        stats( r.getStart(), r.getFinish() );
  +
  +        line();
  +    }
  +
  +    protected void logSuccess( MavenExecutionResponse r )
  +    {
  +        line();
  +
  +        getLogger().info( "BUILD SUCCESSFUL" );
  +
  +        line();
  +
  +        stats( r.getStart(), r.getFinish() );
  +
  +        line();
  +    }
  +
  +    protected void stats( Date start, Date finish )
  +    {
  +        long time = finish.getTime() - start.getTime();
  +
  +        getLogger().info( "Total time: " + formatTime( time ) );
  +
  +        getLogger().info( "Finished at: " + finish );
  +
  +        final long mb = 1024 * 1024;
  +
  +        System.gc();
  +
  +        Runtime r = Runtime.getRuntime();
  +
  +        getLogger().info( "Final Memory: " + ( ( r.totalMemory() - r.freeMemory() ) / mb
) + "M/" + ( r.totalMemory() / mb ) + "M" );
  +    }
  +
  +    protected void line()
  +    {
  +        getLogger().info( "----------------------------------------------------------------------------"
);
  +    }
  +
  +    protected static String formatTime( long ms )
  +    {
  +        long secs = ms / 1000;
  +
  +        long min = secs / 60;
  +
  +        secs = secs % 60;
  +
  +        if ( min > 0 )
  +        {
  +            return min + " minutes " + secs + " seconds";
  +        }
  +        else
  +        {
  +            return secs + " seconds";
  +        }
       }
   }
  
  
  
  1.2       +31 -1     maven-components/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionResponse.java
  
  Index: MavenExecutionResponse.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionResponse.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MavenExecutionResponse.java	23 Dec 2004 23:46:41 -0000	1.1
  +++ MavenExecutionResponse.java	24 Dec 2004 20:51:45 -0000	1.2
  @@ -18,6 +18,8 @@
   
   import org.apache.maven.plugin.FailureResponse;
   
  +import java.util.Date;
  +
   /**
    * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
    * @version $Id$
  @@ -30,6 +32,10 @@
   
       private Throwable exception;
   
  +    private Date start;
  +
  +    private Date finish;
  +
       // ----------------------------------------------------------------------
       // Execution failure
       // ----------------------------------------------------------------------
  @@ -78,5 +84,29 @@
       public void setException( Throwable exception )
       {
           this.exception = exception;
  +    }
  +
  +    // ----------------------------------------------------------------------
  +    // Timing
  +    // ----------------------------------------------------------------------
  +
  +    public Date getStart()
  +    {
  +        return start;
  +    }
  +
  +    public void setStart( Date start )
  +    {
  +        this.start = start;
  +    }
  +
  +    public Date getFinish()
  +    {
  +        return finish;
  +    }
  +
  +    public void setFinish( Date finish )
  +    {
  +        this.finish = finish;
       }
   }
  
  
  
  1.3       +18 -90    maven-components/maven-core/src/main/java/org/apache/maven/execution/project/MavenProjectExecutionRequestHandler.java
  
  Index: MavenProjectExecutionRequestHandler.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/execution/project/MavenProjectExecutionRequestHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MavenProjectExecutionRequestHandler.java	24 Dec 2004 17:29:41 -0000	1.2
  +++ MavenProjectExecutionRequestHandler.java	24 Dec 2004 20:51:45 -0000	1.3
  @@ -17,121 +17,49 @@
   public class MavenProjectExecutionRequestHandler
       extends AbstractMavenExecutionRequestHandler
   {
  -    private boolean logResults = true;
  -
       public void handle( MavenExecutionRequest request, MavenExecutionResponse response
)
           throws Exception
       {
  -        MavenProject project = getProject( ((MavenProjectExecutionRequest) request).getPom(),
request.getLocalRepository() );
  -
  -        Date fullStop;
  +        Date start = null;
   
  -        Date fullStart = new Date();
  +        Date finish = null;
   
           try
           {
  +            MavenProject project = getProject( ( (MavenProjectExecutionRequest) request
).getPom(), request.getLocalRepository() );
  +
  +            start = new Date();
  +
               response = lifecycleManager.execute( createSession( request, project ) );
           }
           catch ( Exception e )
           {
  -            response.setException( e );
  +            finish = new Date();
   
  -            if ( logResults )
  -            {
  -                line();
  -
  -                getLogger().error( "BUILD ERROR" );
  -
  -                line();
  -
  -                getLogger().error( "Cause: ", e );
  +            response.setException( e );
   
  -                line();
  +            response.setStart( start );
   
  -                stats( fullStart, new Date() );
  +            response.setFinish( finish );
   
  -                line();
  -            }
  +            logError( response );
   
               return;
           }
   
  -        fullStop = new Date();
  -
  -        if ( logResults )
  -        {
  -            if ( response.isExecutionFailure() )
  -            {
  -                line();
  -
  -                getLogger().info( "BUILD FAILURE" );
  -
  -                line();
  -
  -                getLogger().info( "Reason: " + response.getFailureResponse().shortMessage()
);
  -
  -                line();
  -
  -                getLogger().info( response.getFailureResponse().longMessage() );
  -
  -                line();
  -
  -                stats( fullStart, fullStop );
  -
  -                line();
  -            }
  -            else
  -            {
  -                line();
  -
  -                getLogger().info( "BUILD SUCCESSFUL" );
  -
  -                line();
  -
  -                stats( fullStart, fullStop );
  -
  -                line();
  -            }
  -        }
  -    }
  -
  -    protected void stats( Date fullStart, Date fullStop )
  -    {
  -        long fullDiff = fullStop.getTime() - fullStart.getTime();
  -
  -        getLogger().info( "Total time: " + formatTime( fullDiff ) );
  -
  -        getLogger().info( "Finished at: " + fullStop );
  -
  -        final long mb = 1024 * 1024;
  -
  -        System.gc();
  -
  -        Runtime r = Runtime.getRuntime();
  -
  -        getLogger().info( "Final Memory: " + ( ( r.totalMemory() - r.freeMemory() ) / mb
) + "M/" + ( r.totalMemory() / mb ) + "M" );
  -    }
  -
  -    protected void line()
  -    {
  -        getLogger().info( "----------------------------------------------------------------------------"
);
  -    }
  -
  -    protected static String formatTime( long ms )
  -    {
  -        long secs = ms / 1000;
  +        finish = new Date();
   
  -        long min = secs / 60;
  +        response.setStart( start );
   
  -        secs = secs % 60;
  +        response.setFinish( finish );
   
  -        if ( min > 0 )
  +        if ( response.isExecutionFailure() )
           {
  -            return min + " minutes " + secs + " seconds";
  +            logFailure( response );
           }
           else
           {
  -            return secs + " seconds";
  +            logSuccess( response );
           }
       }
   
  
  
  
  1.7       +4 -5      maven-components/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
  
  Index: PluginManager.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PluginManager.java	24 Dec 2004 17:29:41 -0000	1.6
  +++ PluginManager.java	24 Dec 2004 20:51:45 -0000	1.7
  @@ -16,11 +16,10 @@
    * limitations under the License.
    */
   
  -import java.util.Map;
  -
  -import org.apache.maven.artifact.repository.ArtifactRepository;
  -import org.apache.maven.plugin.descriptor.MojoDescriptor;
   import org.apache.maven.lifecycle.session.MavenSession;
  +import org.apache.maven.plugin.descriptor.MojoDescriptor;
  +
  +import java.util.Map;
   
   /**
    * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
  
  
  

Mime
View raw message