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/test/java/org/apache/maven MavenTestCase.java
Date Fri, 24 Dec 2004 17:29:42 GMT
jvanzyl     2004/12/24 09:29:42

  Modified:    maven-core/src/main/java/org/apache/maven/cli MavenCli.java
               maven-core/src/main/java/org/apache/maven/execution
                        AbstractMavenExecutionRequestHandler.java
               maven-core/src/main/java/org/apache/maven/execution/project
                        MavenProjectExecutionRequestHandler.java
               maven-core/src/main/java/org/apache/maven/execution/reactor
                        MavenReactorExecutionRequestHandler.java
               maven-core/src/main/java/org/apache/maven/lifecycle/goal/phase
                        PluginResolutionPhase.java
               maven-core/src/main/java/org/apache/maven/lifecycle/session
                        MavenSession.java
               maven-core/src/main/java/org/apache/maven/plugin
                        DefaultPluginManager.java PluginManager.java
               maven-core/src/test/java/org/apache/maven MavenTestCase.java
  Added:       maven-core/src/main/java/org/apache/maven/execution/initialize
                        MavenInitializingExecutionRequest.java
                        MavenInitializingExecutionRequestHandler.java
  Log:
  o move some shared execution request handling code to the super class
  o cleanup the plugin manager interface, we don't need to set the local
    repository as that information is in the request and session.
  
  Revision  Changes    Path
  1.4       +2 -2      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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MavenCli.java	24 Dec 2004 03:20:02 -0000	1.3
  +++ MavenCli.java	24 Dec 2004 17:29:41 -0000	1.4
  @@ -123,7 +123,7 @@
   
               if ( !projectFile.exists() )
               {
  -                    System.err.println( "Could not find either a project descriptor." );
  +                    System.err.println( "Could not find a project descriptor." );
   
                       return 1;
               }
  
  
  
  1.2       +55 -2     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractMavenExecutionRequestHandler.java	23 Dec 2004 23:46:41 -0000	1.1
  +++ AbstractMavenExecutionRequestHandler.java	24 Dec 2004 17:29:41 -0000	1.2
  @@ -1,12 +1,65 @@
   package org.apache.maven.execution;
   
  +import org.apache.maven.lifecycle.session.MavenSession;
  +import org.apache.maven.lifecycle.session.MavenSessionPhaseManager;
  +import org.apache.maven.plugin.PluginManager;
  +import org.apache.maven.project.MavenProject;
  +import org.apache.maven.project.MavenProjectBuilder;
  +import org.codehaus.plexus.PlexusConstants;
  +import org.codehaus.plexus.PlexusContainer;
  +import org.codehaus.plexus.context.Context;
  +import org.codehaus.plexus.context.ContextException;
  +import org.codehaus.plexus.i18n.I18N;
   import org.codehaus.plexus.logging.AbstractLogEnabled;
  +import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
   
   /**
    * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
    * @version $Id$
    */
  -public class AbstractMavenExecutionRequestHandler
  +public abstract class AbstractMavenExecutionRequestHandler
       extends AbstractLogEnabled
  +    implements MavenExecutionRequestHandler, Contextualizable
   {
  +    // ----------------------------------------------------------------------
  +    // Components
  +    // ----------------------------------------------------------------------
  +
  +    protected MavenProjectBuilder projectBuilder;
  +
  +    protected PluginManager pluginManager;
  +
  +    protected PlexusContainer container;
  +
  +    protected MavenSessionPhaseManager lifecycleManager;
  +
  +    protected I18N i18n;
  +
  +    // ----------------------------------------------------------------------
  +    // Methods used by all execution request handlers
  +    // ----------------------------------------------------------------------
  +
  +    //!! We should probably have the execution request handler create the session as
  +    // the session type would be specific to the request i.e. having a project
  +    // or not.
  +
  +    protected MavenSession createSession( MavenExecutionRequest request, MavenProject project
)
  +    {
  +        MavenSession session = new MavenSession( container,
  +                                                 pluginManager,
  +                                                 project,
  +                                                 request.getLocalRepository(),
  +                                                 request.getGoals() );
  +
  +        return session;
  +    }
  +
  +    // ----------------------------------------------------------------------
  +    // Lifecylce Management
  +    // ----------------------------------------------------------------------
  +
  +    public void contextualize( Context context ) throws ContextException
  +    {
  +        container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
  +    }
   }
  
  
  
  1.1                  maven-components/maven-core/src/main/java/org/apache/maven/execution/initialize/MavenInitializingExecutionRequest.java
  
  Index: MavenInitializingExecutionRequest.java
  ===================================================================
  package org.apache.maven.execution.initialize;
  
  import org.apache.maven.artifact.repository.ArtifactRepository;
  import org.apache.maven.execution.AbstractMavenExecutionRequest;
  
  import java.io.File;
  import java.util.List;
  
  /**
   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
   * @version $Id: MavenInitializingExecutionRequest.java,v 1.1 2004/12/24 17:29:41 jvanzyl
Exp $
   */
  public class MavenInitializingExecutionRequest
      extends AbstractMavenExecutionRequest
  {
      public MavenInitializingExecutionRequest( ArtifactRepository localRepository, List goals
)
      {
          super( localRepository, goals );
  
          type = "initializing";               
      }
  }
  
  
  
  1.1                  maven-components/maven-core/src/main/java/org/apache/maven/execution/initialize/MavenInitializingExecutionRequestHandler.java
  
  Index: MavenInitializingExecutionRequestHandler.java
  ===================================================================
  package org.apache.maven.execution.initialize;
  
  import org.apache.maven.project.MavenProject;
  import org.apache.maven.reactor.ReactorException;
  import org.apache.maven.execution.reactor.MavenReactorExecutionRequest;
  import org.apache.maven.execution.project.MavenProjectExecutionRequestHandler;
  import org.apache.maven.execution.MavenExecutionRequestHandler;
  import org.apache.maven.execution.MavenExecutionRequest;
  import org.apache.maven.execution.MavenExecutionResponse;
  import org.codehaus.plexus.util.FileUtils;
  
  import java.io.File;
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.List;
  
  /**
   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
   * @version $Id: MavenInitializingExecutionRequestHandler.java,v 1.1 2004/12/24 17:29:41
jvanzyl Exp $
   */
  public class MavenInitializingExecutionRequestHandler
      extends MavenProjectExecutionRequestHandler
      implements MavenExecutionRequestHandler
  {
      public void handle( MavenExecutionRequest request, MavenExecutionResponse response )
          throws Exception
      {
              super.handle( null, null );
      }
  }
  
  
  
  1.2       +4 -45     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MavenProjectExecutionRequestHandler.java	23 Dec 2004 23:46:41 -0000	1.1
  +++ MavenProjectExecutionRequestHandler.java	24 Dec 2004 17:29:41 -0000	1.2
  @@ -1,24 +1,11 @@
   package org.apache.maven.execution.project;
   
  -import org.apache.maven.lifecycle.session.MavenSession;
  -import org.apache.maven.lifecycle.session.MavenSessionPhaseManager;
  -import org.apache.maven.plugin.PluginManager;
  -import org.apache.maven.project.MavenProject;
  -import org.apache.maven.project.MavenProjectBuilder;
  -import org.apache.maven.project.ProjectBuildingException;
   import org.apache.maven.artifact.repository.ArtifactRepository;
  -import org.apache.maven.execution.project.MavenProjectExecutionRequest;
   import org.apache.maven.execution.AbstractMavenExecutionRequestHandler;
  -import org.apache.maven.execution.MavenExecutionRequestHandler;
   import org.apache.maven.execution.MavenExecutionRequest;
   import org.apache.maven.execution.MavenExecutionResponse;
  -import org.codehaus.plexus.ArtifactEnabledContainer;
  -import org.codehaus.plexus.PlexusConstants;
  -import org.codehaus.plexus.PlexusContainer;
  -import org.codehaus.plexus.i18n.I18N;
  -import org.codehaus.plexus.context.Context;
  -import org.codehaus.plexus.context.ContextException;
  -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
  +import org.apache.maven.project.MavenProject;
  +import org.apache.maven.project.ProjectBuildingException;
   
   import java.io.File;
   import java.util.Date;
  @@ -29,20 +16,9 @@
    */
   public class MavenProjectExecutionRequestHandler
       extends AbstractMavenExecutionRequestHandler
  -    implements MavenExecutionRequestHandler, Contextualizable
   {
       private boolean logResults = true;
   
  -    protected MavenProjectBuilder projectBuilder;
  -
  -    protected PluginManager pluginManager;
  -
  -    protected PlexusContainer container;
  -
  -    protected MavenSessionPhaseManager lifecycleManager;
  -
  -    protected I18N i18n;
  -
       public void handle( MavenExecutionRequest request, MavenExecutionResponse response
)
           throws Exception
       {
  @@ -52,17 +28,9 @@
   
           Date fullStart = new Date();
   
  -        pluginManager.setLocalRepository( request.getLocalRepository() );
  -
  -        MavenSession session = new MavenSession( container,
  -                                                 pluginManager,
  -                                                 project,
  -                                                 request.getLocalRepository(),
  -                                                 request.getGoals() );
  -
           try
           {
  -            response = lifecycleManager.execute( session );
  +            response = lifecycleManager.execute( createSession( request, project ) );
           }
           catch ( Exception e )
           {
  @@ -183,14 +151,5 @@
           }
   
           return projectBuilder.build( pom, localRepository );
  -    }
  -
  -    // ----------------------------------------------------------------------
  -    // Lifecylce Management
  -    // ----------------------------------------------------------------------
  -
  -    public void contextualize( Context context ) throws ContextException
  -    {
  -        container = (ArtifactEnabledContainer) context.get( PlexusConstants.PLEXUS_KEY
);
       }
   }
  
  
  
  1.2       +10 -13    maven-components/maven-core/src/main/java/org/apache/maven/execution/reactor/MavenReactorExecutionRequestHandler.java
  
  Index: MavenReactorExecutionRequestHandler.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/execution/reactor/MavenReactorExecutionRequestHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MavenReactorExecutionRequestHandler.java	23 Dec 2004 23:46:41 -0000	1.1
  +++ MavenReactorExecutionRequestHandler.java	24 Dec 2004 17:29:41 -0000	1.2
  @@ -1,12 +1,11 @@
   package org.apache.maven.execution.reactor;
   
  -import org.apache.maven.project.MavenProject;
  -import org.apache.maven.reactor.ReactorException;
  -import org.apache.maven.execution.reactor.MavenReactorExecutionRequest;
  -import org.apache.maven.execution.project.MavenProjectExecutionRequestHandler;
  -import org.apache.maven.execution.MavenExecutionRequestHandler;
   import org.apache.maven.execution.MavenExecutionRequest;
   import org.apache.maven.execution.MavenExecutionResponse;
  +import org.apache.maven.execution.project.MavenProjectExecutionRequest;
  +import org.apache.maven.execution.project.MavenProjectExecutionRequestHandler;
  +import org.apache.maven.project.MavenProject;
  +import org.apache.maven.reactor.ReactorException;
   import org.codehaus.plexus.util.FileUtils;
   
   import java.io.File;
  @@ -20,7 +19,6 @@
    */
   public class MavenReactorExecutionRequestHandler
       extends MavenProjectExecutionRequestHandler
  -    implements MavenExecutionRequestHandler
   {
       public void handle( MavenExecutionRequest request, MavenExecutionResponse response
)
           throws Exception
  @@ -32,8 +30,8 @@
           try
           {
               List files = FileUtils.getFiles( new File( System.getProperty( "user.dir" )
),
  -                                             ((MavenReactorExecutionRequest)request).getIncludes(),
  -                                             ((MavenReactorExecutionRequest)request).getExcludes()
);
  +                                             ( (MavenReactorExecutionRequest) request ).getIncludes(),
  +                                             ( (MavenReactorExecutionRequest) request ).getExcludes()
);
   
               for ( Iterator iterator = files.iterator(); iterator.hasNext(); )
               {
  @@ -72,11 +70,10 @@
   
               line();
   
  -            //MavenProjectExecutionRequest r = new MavenProjectExecutionRequest();
  -
  -            super.handle( null, null );
  +            MavenProjectExecutionRequest projectExecutionRequest =
  +                new MavenProjectExecutionRequest( request.getLocalRepository(), request.getGoals(),
project.getFile() );
   
  -            //response = execute( new MavenProjectExecutionRequest( request.getLocalRepository(),
request.getGoals(), project ) );
  +            super.handle( projectExecutionRequest, response );
   
               if ( response.isExecutionFailure() )
               {
  
  
  
  1.4       +1 -1      maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/goal/phase/PluginResolutionPhase.java
  
  Index: PluginResolutionPhase.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/goal/phase/PluginResolutionPhase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PluginResolutionPhase.java	5 Dec 2004 04:16:03 -0000	1.3
  +++ PluginResolutionPhase.java	24 Dec 2004 17:29:41 -0000	1.4
  @@ -66,7 +66,7 @@
           {
               try
               {
  -                pluginManager.verifyPluginForGoal( goal );
  +                pluginManager.verifyPluginForGoal( goal, session );
               }
               catch ( Exception e )
               {
  
  
  
  1.7       +12 -4     maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/session/MavenSession.java
  
  Index: MavenSession.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/session/MavenSession.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- MavenSession.java	5 Dec 2004 04:16:04 -0000	1.6
  +++ MavenSession.java	24 Dec 2004 17:29:41 -0000	1.7
  @@ -60,8 +60,11 @@
   
       private Map postGoalMappings;
   
  -    public MavenSession( PlexusContainer container, PluginManager pluginManager, MavenProject
project,
  -        ArtifactRepository localRepository, List goals )
  +    public MavenSession( PlexusContainer container,
  +                         PluginManager pluginManager,
  +                         MavenProject project,
  +                         ArtifactRepository localRepository,
  +                         List goals )
       {
           this.container = container;
   
  @@ -161,14 +164,17 @@
       private void initGoalDecoratorMappings()
       {
           List allPreGoals = project.getPreGoals();
  +
           for ( Iterator it = allPreGoals.iterator(); it.hasNext(); )
           {
               PreGoal preGoal = (PreGoal) it.next();
   
               List preGoalList = (List) preGoalMappings.get( preGoal.getName() );
  +
               if ( preGoalList == null )
               {
                   preGoalList = new LinkedList();
  +
                   preGoalMappings.put( preGoal.getName(), preGoalList );
               }
   
  @@ -176,14 +182,17 @@
           }
   
           List allPostGoals = project.getPostGoals();
  +
           for ( Iterator it = allPostGoals.iterator(); it.hasNext(); )
           {
               PostGoal postGoal = (PostGoal) it.next();
   
               List postGoalList = (List) postGoalMappings.get( postGoal.getName() );
  +
               if ( postGoalList == null )
               {
                   postGoalList = new LinkedList();
  +
                   postGoalMappings.put( postGoal.getName(), postGoalList );
               }
   
  @@ -213,5 +222,4 @@
           
           return chainToHere;
       }
  -
   }
  
  
  
  1.21      +8 -20     maven-components/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
  
  Index: DefaultPluginManager.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- DefaultPluginManager.java	5 Dec 2004 21:45:35 -0000	1.20
  +++ DefaultPluginManager.java	24 Dec 2004 17:29:41 -0000	1.21
  @@ -22,6 +22,7 @@
   import org.apache.maven.plugin.descriptor.MojoDescriptor;
   import org.apache.maven.plugin.descriptor.PluginDescriptor;
   import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder;
  +import org.apache.maven.lifecycle.session.MavenSession;
   import org.codehaus.plexus.ArtifactEnabledContainer;
   import org.codehaus.plexus.PlexusConstants;
   import org.codehaus.plexus.PlexusContainer;
  @@ -62,8 +63,6 @@
   
       protected Set remotePluginRepositories;
   
  -    protected ArtifactRepository localRepository;
  -
       protected ArtifactFilter artifactFilter;
   
       public DefaultPluginManager()
  @@ -163,7 +162,8 @@
           return goalName;
       }
   
  -    public void verifyPluginForGoal( String goalName ) throws Exception
  +    public void verifyPluginForGoal( String goalName, MavenSession session )
  +        throws Exception
       {
           String pluginId = getPluginId( goalName );
   
  @@ -179,7 +179,7 @@
   
               Artifact pluginArtifact = new DefaultArtifact( "maven", artifactId, version,
"plugin", "jar" );
   
  -            addPlugin( pluginArtifact );
  +            addPlugin( pluginArtifact, session );
   
               // Now, we need to resolve the plugins for this goal's prereqs.
               MojoDescriptor mojoDescriptor = getMojoDescriptor( goalName );
  @@ -192,25 +192,25 @@
                   {
                       String prereq = (String) it.next();
   
  -                    verifyPluginForGoal( prereq );
  +                    verifyPluginForGoal( prereq, session );
                   }
               }
           }
       }
   
  -    public void addPlugin( Artifact pluginArtifact )
  +    protected void addPlugin( Artifact pluginArtifact, MavenSession session )
           throws Exception
       {
           artifactResolver = (ArtifactResolver) container.lookup( ArtifactResolver.ROLE );
   
           MavenMetadataSource metadataSource = new MavenMetadataSource( remotePluginRepositories,

  -                                                                      localRepository,
  +                                                                      session.getLocalRepository(),
                                                                         artifactResolver
);
   
           ( (ArtifactEnabledContainer) container ).addComponent( pluginArtifact,
                                                                  artifactResolver,
                                                                  remotePluginRepositories,
  -                                                               localRepository,
  +                                                               session.getLocalRepository(),
                                                                  metadataSource,
                                                                  artifactFilter );
       }
  @@ -242,18 +242,6 @@
   
           // TODO: needs to be configured from the POM element
           remotePluginRepositories.add( new ArtifactRepository( "plugin-repository", "http://repo1.maven.org"
) );
  -    }
  -
  -    // TODO: is this needed or can it be found from the session?
  -    public ArtifactRepository getLocalRepository()
  -    {
  -        return localRepository;
  -    }
  -
  -    // TODO: is this needed or can it be found from the session? It is currently set from
the session
  -    public void setLocalRepository( ArtifactRepository localRepository )
  -    {
  -        this.localRepository = localRepository;
       }
   }
   
  
  
  
  1.6       +3 -20     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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PluginManager.java	5 Dec 2004 04:16:04 -0000	1.5
  +++ PluginManager.java	24 Dec 2004 17:29:41 -0000	1.6
  @@ -20,6 +20,7 @@
   
   import org.apache.maven.artifact.repository.ArtifactRepository;
   import org.apache.maven.plugin.descriptor.MojoDescriptor;
  +import org.apache.maven.lifecycle.session.MavenSession;
   
   /**
    * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
  @@ -29,31 +30,13 @@
   {
       String ROLE = PluginManager.class.getName();
   
  -    // ----------------------------------------------------------------------
  -    // Plugin processing
  -    // ----------------------------------------------------------------------
  -
       void processPluginDescriptor( MavenPluginDescriptor pluginDescriptor )
           throws Exception;
   
  -    // ----------------------------------------------------------------------
  -    //  Mojo descriptors
  -    // ----------------------------------------------------------------------
  -
       Map getMojoDescriptors();
   
       MojoDescriptor getMojoDescriptor( String goalId );
   
  -    // ----------------------------------------------------------------------
  -    //
  -    // ----------------------------------------------------------------------
  -
  -    // ----------------------------------------------------------------------
  -    //
  -    // ----------------------------------------------------------------------
  -
  -    void verifyPluginForGoal( String pluginId )
  +    void verifyPluginForGoal( String pluginId, MavenSession session )
           throws Exception;
  -
  -    void setLocalRepository( ArtifactRepository localRepository );
   }
  
  
  
  1.12      +1 -3      maven-components/maven-core/src/test/java/org/apache/maven/MavenTestCase.java
  
  Index: MavenTestCase.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/test/java/org/apache/maven/MavenTestCase.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- MavenTestCase.java	23 Dec 2004 23:46:42 -0000	1.11
  +++ MavenTestCase.java	24 Dec 2004 17:29:42 -0000	1.12
  @@ -130,8 +130,6 @@
   
           MavenSession session = new MavenSession( getContainer(), pluginManager, project,
localRepository, goals );
   
  -        pluginManager.setLocalRepository( localRepository );
  -
           MavenGoalExecutionContext context = new MavenGoalExecutionContext( session, goal
);
   
           return context;
  
  
  

Mime
View raw message