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/plugin OgnlProjectValueExtractorTest.java
Date Sun, 15 Aug 2004 15:01:52 GMT
jvanzyl     2004/08/15 08:01:52

  Modified:    maven-core/src/main/java/org/apache/maven DefaultMaven.java
                        Maven.java
               maven-core/src/main/java/org/apache/maven/lifecycle/session
                        DefaultMavenSessionPhaseManager.java
                        MavenSession.java MavenSessionPhaseManager.java
               maven-core/src/main/java/org/apache/maven/plugin
                        DefaultPluginManager.java
                        OgnlProjectValueExtractor.java
               maven-core/src/main/resources/META-INF/plexus components.xml
               maven-core/src/test/java/org/apache/maven MavenTestCase.java
               maven-core/src/test/java/org/apache/maven/lifecycle
                        MavenLifecycleManagerTest.java
               maven-core/src/test/java/org/apache/maven/plugin
                        OgnlProjectValueExtractorTest.java
  Added:       maven-core/src/main/java/org/apache/maven/lifecycle/goal
                        AbstractMavenGoalPhase.java
                        DefaultMavenGoalPhaseManager.java
                        GoalExecutionException.java
                        GoalNotFoundException.java
                        MavenGoalExecutionContext.java MavenGoalPhase.java
                        MavenGoalPhaseManager.java
               maven-core/src/main/java/org/apache/maven/lifecycle/goal/phase
                        DependencyDownloadPhase.java
                        DependencyResolutionPhase.java
                        GoalAttainmentPhase.java GoalDecorationPhase.java
                        GoalResolutionPhase.java PluginDownloadPhase.java
               maven-core/src/main/java/org/apache/maven/lifecycle/session/phase
                        GoalExecutionPhase.java
               maven-core/src/test/java/org/apache/maven/lifecycle/goal/phase
                        GoalResolutionPhaseTest.java
  Removed:     maven-core/src/main/java/org/apache/maven
                        GoalNotFoundException.java
               maven-core/src/main/java/org/apache/maven/lifecycle
                        AbstractMavenLifecyclePhase.java
                        DefaultMavenLifecycleManager.java
                        MavenGoalExecutionContext.java
                        MavenLifecycleManager.java MavenLifecyclePhase.java
               maven-core/src/main/java/org/apache/maven/lifecycle/phase
                        DependencyDownloadPhase.java
                        DependencyResolutionPhase.java
                        GoalAttainmentPhase.java GoalDecorationPhase.java
                        GoalResolutionPhase.java PluginDownloadPhase.java
               maven-core/src/test/java/org/apache/maven/lifecycle/phase
                        GoalDecorationPhaseTest.java
                        GoalResolutionPhaseTest.java
  Log:
  o more additions to the session code, not turned on yet but doing things in
    smaller batches.
  
  Revision  Changes    Path
  1.4       +8 -4      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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultMaven.java	12 Aug 2004 22:52:54 -0000	1.3
  +++ DefaultMaven.java	15 Aug 2004 15:01:50 -0000	1.4
  @@ -17,8 +17,11 @@
    */
   
   import org.apache.maven.artifact.repository.ArtifactRepository;
  -import org.apache.maven.lifecycle.MavenGoalExecutionContext;
  -import org.apache.maven.lifecycle.MavenLifecycleManager;
  +import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
  +import org.apache.maven.lifecycle.goal.MavenGoalPhaseManager;
  +import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
  +import org.apache.maven.lifecycle.goal.MavenGoalPhaseManager;
  +import org.apache.maven.lifecycle.goal.GoalNotFoundException;
   import org.apache.maven.lifecycle.session.MavenSession;
   import org.apache.maven.plugin.PluginManager;
   import org.apache.maven.plugin.descriptor.MojoDescriptor;
  @@ -61,7 +64,7 @@
   
       private PluginManager pluginManager;
   
  -    private MavenLifecycleManager lifecycleManager;
  +    private MavenGoalPhaseManager lifecycleManager;
   
       private MavenProjectBuilder projectBuilder;
   
  @@ -95,7 +98,8 @@
           MavenSession session = new MavenSession( container,
                                                    pluginManager,
                                                    project,
  -                                                 getLocalRepository() );
  +                                                 getLocalRepository(),
  +                                                 goals );
   
           for ( Iterator iterator = goals.iterator(); iterator.hasNext(); )
           {
  
  
  
  1.2       +2 -1      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Maven.java	9 Aug 2004 19:02:34 -0000	1.1
  +++ Maven.java	15 Aug 2004 15:01:50 -0000	1.2
  @@ -21,6 +21,7 @@
   import org.apache.maven.plugin.descriptor.PluginDescriptor;
   import org.apache.maven.project.MavenProject;
   import org.apache.maven.project.ProjectBuildingException;
  +import org.apache.maven.lifecycle.goal.GoalNotFoundException;
   
   import java.io.File;
   import java.util.List;
  
  
  
  1.1                  maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/goal/AbstractMavenGoalPhase.java
  
  Index: AbstractMavenGoalPhase.java
  ===================================================================
  package org.apache.maven.lifecycle.goal;
  
  /*
   * 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.codehaus.plexus.logging.AbstractLogEnabled;
  
  /**
   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
   * @version $Id: AbstractMavenGoalPhase.java,v 1.1 2004/08/15 15:01:50 jvanzyl Exp $
   */
  public abstract class AbstractMavenGoalPhase
      extends AbstractLogEnabled
      implements MavenGoalPhase
  {
      public abstract void execute( MavenGoalExecutionContext context )
          throws GoalExecutionException;
  }
  
  
  
  1.1                  maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/goal/DefaultMavenGoalPhaseManager.java
  
  Index: DefaultMavenGoalPhaseManager.java
  ===================================================================
  package org.apache.maven.lifecycle.goal;
  
  /*
   * 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.codehaus.plexus.logging.AbstractLogEnabled;
  
  import java.util.Iterator;
  import java.util.List;
  
  /**
   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
   * @version $Id: DefaultMavenGoalPhaseManager.java,v 1.1 2004/08/15 15:01:50 jvanzyl Exp $
   */
  public class DefaultMavenGoalPhaseManager
      extends AbstractLogEnabled
      implements MavenGoalPhaseManager
  {
      private List lifecyclePhases;
  
      public List getLifecyclePhases()
      {
          return lifecyclePhases;
      }
  
      public void execute( MavenGoalExecutionContext context )
          throws GoalExecutionException
      {
          for ( Iterator iterator = lifecyclePhases.iterator(); iterator.hasNext(); )
          {
              MavenGoalPhase phase = (MavenGoalPhase) iterator.next();
  
              phase.enableLogging( getLogger() );
  
              phase.execute( context );
  
              if ( context.isExecutionFailure() )
              {
                  break;
              }
          }
      }
  }
  
  
  
  1.1                  maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/goal/GoalExecutionException.java
  
  Index: GoalExecutionException.java
  ===================================================================
  package org.apache.maven.lifecycle.goal;
  
  /*
   * 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.
   */
  
  /**
   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
   * @version $Id: GoalExecutionException.java,v 1.1 2004/08/15 15:01:50 jvanzyl Exp $
   */
  public class GoalExecutionException
      extends Exception
  {
      public GoalExecutionException( String message )
      {
          super( message );
      }
  
      public GoalExecutionException( Throwable cause )
      {
          super( cause );
      }
  
      public GoalExecutionException( String message, Throwable cause )
      {
          super( message, cause );
      }
  }
  
  
  
  1.1                  maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/goal/GoalNotFoundException.java
  
  Index: GoalNotFoundException.java
  ===================================================================
  package org.apache.maven.lifecycle.goal;
  
  import org.apache.maven.lifecycle.goal.GoalExecutionException;
  
  /*
   * 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.
   */
  
  public class GoalNotFoundException
      extends GoalExecutionException
  {
      private String goalName;
  
      public GoalNotFoundException( String goal )
      {
          super( "Unknown goal \"" + goal + "\"" );
  
          this.goalName = goal;
      }
  
      public String getGoalName()
      {
          return this.goalName;
      }
  }
  
  
  
  1.1                  maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/goal/MavenGoalExecutionContext.java
  
  Index: MavenGoalExecutionContext.java
  ===================================================================
  package org.apache.maven.lifecycle.goal;
  
  import org.apache.maven.artifact.repository.ArtifactRepository;
  import org.apache.maven.decoration.GoalDecoratorBindings;
  import org.apache.maven.lifecycle.session.MavenSession;
  import org.apache.maven.plugin.FailureResponse;
  import org.apache.maven.plugin.descriptor.MojoDescriptor;
  import org.apache.maven.project.MavenProject;
  import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
  
  import java.util.List;
  import java.util.Set;
  
  /**
   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
   * @version $Id: MavenGoalExecutionContext.java,v 1.1 2004/08/15 15:01:50 jvanzyl Exp $
   */
  public class MavenGoalExecutionContext
  {
      private MavenSession session;
  
      private String failedGoal;
  
      private FailureResponse failureResponse;
  
      private MojoDescriptor mojoDescriptor;
  
      private List resolvedGoals;
  
      private GoalDecoratorBindings goalDecoratorBindings;
  
      private String goalName;
  
      public MavenGoalExecutionContext( MavenSession session, MojoDescriptor goal )
      {
          this.session  = session;
  
          this.mojoDescriptor = goal;
      }
  
      public MavenSession getSession()
      {
          return session;
      }
  
      // ----------------------------------------------------------------------
      // Delegation to the session
      // ----------------------------------------------------------------------
  
      public MavenProject getProject()
      {
          return session.getProject();
      }
  
      public ArtifactRepository getLocalRepository()
      {
          return session.getLocalRepository();
      }
  
      public Set getRemoteRepositories()
      {
          return session.getRemoteRepositories();
      }
  
      public Object lookup( String role )
          throws ComponentLookupException
      {
          return session.lookup( role );
      }
  
      public Object lookup( String role, String hint )
          throws ComponentLookupException
      {
          return session.lookup( role, hint );
      }
  
      public void release( Object component )
      {
          session.release( component );
      }
  
      // ----------------------------------------------------------------------
  
      public boolean requiresDependencyResolution()
      {
          return mojoDescriptor.requiresDependencyResolution();
      }
  
      public MojoDescriptor getMojoDescriptor()
      {
          return mojoDescriptor;
      }
  
      public void setMojoDescriptor( MojoDescriptor mojoDescriptor )
      {
          this.mojoDescriptor = mojoDescriptor;
      }
  
      public List getResolvedGoals()
      {
          return resolvedGoals;
      }
  
      public void setResolvedGoals( List resolvedGoals )
      {
          this.resolvedGoals = resolvedGoals;
      }
  
      public MojoDescriptor getMojoDescriptor( String mojoDescriptorName )
      {
          return session.getPluginManager().getMojoDescriptor( mojoDescriptorName );
      }
  
      public String getPluginId( MojoDescriptor mojoDescriptor )
      {
          return mojoDescriptor.getId();
      }
  
      public void setExecutionFailure( String failedGoal, FailureResponse response )
      {
          this.failedGoal = failedGoal;
  
          this.failureResponse = response;
      }
  
      public boolean isExecutionFailure()
      {
          return ( failedGoal != null );
      }
  
      public String getFailedGoal()
      {
          return failedGoal;
      }
  
      public void setFailedGoal( String failedGoal )
      {
          this.failedGoal = failedGoal;
      }
  
      public FailureResponse getFailureResponse()
      {
          return failureResponse;
      }
  
      public void setFailureResponse( FailureResponse failureResponse )
      {
          this.failureResponse = failureResponse;
      }
  
      public GoalDecoratorBindings getGoalDecoratorBindings()
      {
          return goalDecoratorBindings;
      }
  
      public void setGoalDecoratorBindings( GoalDecoratorBindings goalDecoratorBindings )
      {
          this.goalDecoratorBindings = goalDecoratorBindings;
      }
  
      public String getGoalName()
      {
          return goalName;
      }
  
      public void setGoalName( String goalName )
      {
          this.goalName = goalName;
      }
  }
  
  
  
  1.1                  maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/goal/MavenGoalPhase.java
  
  Index: MavenGoalPhase.java
  ===================================================================
  package org.apache.maven.lifecycle.goal;
  
  /*
   * 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.codehaus.plexus.logging.Logger;
  import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
  
  
  /**
   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
   * @version $Id: MavenGoalPhase.java,v 1.1 2004/08/15 15:01:50 jvanzyl Exp $
   */
  public interface MavenGoalPhase
  {
      String ROLE = MavenGoalPhase.class.getName();
  
      void execute( MavenGoalExecutionContext context )
          throws GoalExecutionException;
  
      void enableLogging( Logger logger );
  }
  
  
  
  1.1                  maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/goal/MavenGoalPhaseManager.java
  
  Index: MavenGoalPhaseManager.java
  ===================================================================
  package org.apache.maven.lifecycle.goal;
  
  /*
   * 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.lifecycle.goal.MavenGoalExecutionContext;
  
  import java.util.List;
  
  /**
   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
   * @version $Id: MavenGoalPhaseManager.java,v 1.1 2004/08/15 15:01:50 jvanzyl Exp $
   */
  public interface MavenGoalPhaseManager
  {
      String ROLE = MavenGoalPhaseManager.class.getName();
  
      void execute( MavenGoalExecutionContext context )
          throws GoalExecutionException;
  
      List getLifecyclePhases();
  }
  
  
  
  1.1                  maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/goal/phase/DependencyDownloadPhase.java
  
  Index: DependencyDownloadPhase.java
  ===================================================================
  package org.apache.maven.lifecycle.goal.phase;
  
  /*
   * 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.Artifact;
  import org.apache.maven.artifact.resolver.ArtifactResolutionException;
  import org.apache.maven.artifact.resolver.ArtifactResolver;
  import org.apache.maven.lifecycle.goal.AbstractMavenGoalPhase;
  import org.apache.maven.lifecycle.goal.GoalExecutionException;
  import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
  import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
  
  import java.util.Iterator;
  
  /**
   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
   * @version $Id: DependencyDownloadPhase.java,v 1.1 2004/08/15 15:01:51 jvanzyl Exp $
   */
  public class DependencyDownloadPhase
      extends AbstractMavenGoalPhase
  {
      public void execute( MavenGoalExecutionContext context )
          throws GoalExecutionException
      {
          ArtifactResolver artifactResolver = null;
  
          try
          {
              // Once this is a property component there will be an assembly phase for
              // this and we won't have to do this.
              artifactResolver = (ArtifactResolver) context.lookup( ArtifactResolver.ROLE );
  
              for ( Iterator it = context.getProject().getArtifacts().iterator(); it.hasNext(); )
              {
                  Artifact artifact = (Artifact) it.next();
  
                  artifactResolver.resolve( artifact,
                                            context.getRemoteRepositories(),
                                            context.getLocalRepository() );
              }
          }
          catch ( ComponentLookupException e )
          {
              throw new GoalExecutionException( "Can't lookup artifact resolver: ", e );
          }
          catch ( ArtifactResolutionException e )
          {
              throw new GoalExecutionException( "Can't resolve artifact: ", e );
          }
          finally
          {
              context.release( artifactResolver );
          }
      }
  }
  
  
  
  1.1                  maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/goal/phase/DependencyResolutionPhase.java
  
  Index: DependencyResolutionPhase.java
  ===================================================================
  package org.apache.maven.lifecycle.goal.phase;
  
  /*
   * 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.MavenMetadataSource;
  import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
  import org.apache.maven.artifact.resolver.ArtifactResolver;
  import org.apache.maven.lifecycle.goal.AbstractMavenGoalPhase;
  import org.apache.maven.lifecycle.goal.GoalExecutionException;
  import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
  import org.apache.maven.project.MavenProject;
  
  import java.util.Iterator;
  
  /**
   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
   * @version $Id: DependencyResolutionPhase.java,v 1.1 2004/08/15 15:01:51 jvanzyl Exp $
   */
  public class DependencyResolutionPhase
      extends AbstractMavenGoalPhase
  {
      public void execute( MavenGoalExecutionContext context )
          throws GoalExecutionException
      {
          for ( Iterator iterator = context.getResolvedGoals().iterator(); iterator.hasNext(); )
          {
              String goalName = (String) iterator.next();
  
              if ( context.getMojoDescriptor( goalName ).requiresDependencyResolution() )
              {
                  try
                  {
                      resolveTransitiveDependencies( context );
                  }
                  catch ( Exception e )
                  {
                      throw new GoalExecutionException( "Can't resolve transitive dependencies: ", e );
                  }
  
                  break;
              }
          }
      }
  
      private void resolveTransitiveDependencies( MavenGoalExecutionContext context )
          throws Exception
      {
          ArtifactResolver artifactResolver = null;
  
          try
          {
              MavenProject project = context.getProject();
  
              artifactResolver = (ArtifactResolver) context.lookup( ArtifactResolver.ROLE );
  
              MavenMetadataSource sourceReader = new MavenMetadataSource( context.getRemoteRepositories(),
                                                                          context.getLocalRepository(),
                                                                          artifactResolver );
  
              ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getArtifacts(),
                                                                                      context.getRemoteRepositories(),
                                                                                      context.getLocalRepository(),
                                                                                      sourceReader );
  
              project.getArtifacts().addAll( result.getArtifacts().values() );
          }
          finally
          {
              context.release( artifactResolver );
          }
      }
  }
  
  
  
  1.1                  maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/goal/phase/GoalAttainmentPhase.java
  
  Index: GoalAttainmentPhase.java
  ===================================================================
  package org.apache.maven.lifecycle.goal.phase;
  
  /*
   * 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.lifecycle.goal.AbstractMavenGoalPhase;
  import org.apache.maven.lifecycle.goal.GoalExecutionException;
  import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
  import org.apache.maven.plugin.OgnlProjectValueExtractor;
  import org.apache.maven.plugin.Plugin;
  import org.apache.maven.plugin.PluginExecutionRequest;
  import org.apache.maven.plugin.PluginExecutionResponse;
  import org.apache.maven.plugin.descriptor.MojoDescriptor;
  import org.apache.maven.plugin.descriptor.Parameter;
  import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
  
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Map;
  
  /**
   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
   * @version $Id: GoalAttainmentPhase.java,v 1.1 2004/08/15 15:01:51 jvanzyl Exp $
   */
  public class GoalAttainmentPhase
      extends AbstractMavenGoalPhase
  {
      public void execute( MavenGoalExecutionContext context )
          throws GoalExecutionException
      {
          PluginExecutionResponse response;
  
          PluginExecutionRequest request;
  
          for ( Iterator it = context.getResolvedGoals().iterator(); it.hasNext(); )
          {
              String goalName = (String) it.next();
  
              MojoDescriptor mojoDescriptor = context.getMojoDescriptor( goalName );
  
              getLogger().info( "[" + mojoDescriptor.getId() + "]" );
  
              request = new PluginExecutionRequest( createParameters( mojoDescriptor, context ) );
  
              response = new PluginExecutionResponse();
  
              Plugin plugin = null;
  
              try
              {
                  String roleHint = context.getPluginId( mojoDescriptor );
  
                  plugin = (Plugin) context.lookup( Plugin.ROLE, roleHint );
  
                  plugin.execute( request, response );
  
                  if ( response.isExecutionFailure() )
                  {
                      context.setExecutionFailure( mojoDescriptor.getId(), response.getFailureResponse() );
  
                      break;
                  }
              }
              catch ( ComponentLookupException e )
              {
                  throw new GoalExecutionException( "Error looking up plugin: ", e );
              }
              catch ( Exception e )
              {
                  throw new GoalExecutionException( "Error executing plugin: ", e );
              }
              finally
              {
                  releaseComponents( mojoDescriptor, request, context );
  
                  context.release( plugin );
              }
          }
      }
  
      private Map createParameters( MojoDescriptor goal, MavenGoalExecutionContext context )
      {
          Map map = null;
  
          List parameters = goal.getParameters();
  
          if ( parameters != null )
          {
              map = new HashMap();
  
              for ( int i = 0; i < parameters.size(); i++ )
              {
                  Parameter parameter = (Parameter) parameters.get( i );
  
                  String key = parameter.getName();
  
                  String expression = parameter.getExpression();
  
                  Object value = OgnlProjectValueExtractor.evaluate( expression, context );
  
                  //@todo: mojo parameter validation
                  // This is the place where parameter validation should be performed.
                  //if ( value == null && parameter.isRequired() )
                  //{
                  //}
  
                  map.put( key, value );
              }
          }
  
          return map;
      }
  
      private void releaseComponents( MojoDescriptor goal, PluginExecutionRequest request, MavenGoalExecutionContext context )
      {
          if ( request != null && request.getParameters() != null )
          {
              for ( Iterator iterator = goal.getParameters().iterator(); iterator.hasNext(); )
              {
                  Parameter parameter = (Parameter) iterator.next();
  
                  String key = parameter.getName();
  
                  String expression = parameter.getExpression();
  
                  if ( expression != null & expression.startsWith( "#component" ) )
                  {
                      Object component = request.getParameter( key );
  
                      context.release( component );
                  }
              }
          }
      }
  }
  
  
  
  1.1                  maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/goal/phase/GoalDecorationPhase.java
  
  Index: GoalDecorationPhase.java
  ===================================================================
  package org.apache.maven.lifecycle.goal.phase;
  
  
  /*
   * 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.decoration.GoalDecorationParser;
  import org.apache.maven.decoration.GoalDecoratorBindings;
  import org.apache.maven.lifecycle.goal.AbstractMavenGoalPhase;
  import org.apache.maven.lifecycle.goal.GoalExecutionException;
  import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
  import org.apache.maven.project.MavenProject;
  import org.xmlpull.v1.XmlPullParserException;
  
  import java.io.BufferedReader;
  import java.io.File;
  import java.io.FileReader;
  import java.io.IOException;
  
  /**
   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
   * @author <a href="mailto:jdcasey@commonjava.org">John Casey</a>
   * @version $Id: GoalDecorationPhase.java,v 1.1 2004/08/15 15:01:51 jvanzyl Exp $
   */
  public class GoalDecorationPhase extends AbstractMavenGoalPhase
  {
      public static final String MAVEN_XML_DEFAULT_NAMESPACE = "mavenxml";
      public static final String MAVEN_SCRIPT = "decorators.xml";
      private GoalDecoratorBindings decorators;
      private boolean decoratorsInitialized = false;
  
      public void execute( MavenGoalExecutionContext context )
          throws GoalExecutionException
      {
          synchronized ( this )
          {
              if ( !decoratorsInitialized )
              {
                  try
                  {
                      initializeDecorators( context );
                  }
                  catch ( XmlPullParserException e )
                  {
                      throw new GoalExecutionException( "Error parsing decorators.xml: ", e );
                  }
                  catch ( IOException e )
                  {
                      throw new GoalExecutionException( "Error reading decorators.xml file: ", e );
                  }
              }
          }
  
          context.setGoalDecoratorBindings( decorators );
      }
  
      private void initializeDecorators( MavenGoalExecutionContext context )
          throws XmlPullParserException, IOException
      {
          MavenProject project = context.getProject();
  
          File pom = project.getFile();
  
          File dir = pom.getParentFile();
  
          File scriptFile = new File( dir, MAVEN_SCRIPT );
  
          if ( scriptFile.exists() )
          {
              BufferedReader reader = null;
  
              try
              {
                  reader = new BufferedReader( new FileReader( scriptFile ) );
  
                  GoalDecorationParser parser = new GoalDecorationParser();
                  this.decorators = parser.parse( reader );
              }
              finally
              {
                  if ( reader != null )
                  {
                      try
                      {
                          reader.close();
                      }
                      catch ( IOException e )
                      {
                      }
                  }
              }
          }
  
          decoratorsInitialized = true;
      }
  }
  
  
  
  1.1                  maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/goal/phase/GoalResolutionPhase.java
  
  Index: GoalResolutionPhase.java
  ===================================================================
  package org.apache.maven.lifecycle.goal.phase;
  
  
  /*
   * 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.lifecycle.goal.GoalNotFoundException;
  import org.apache.maven.decoration.GoalDecorator;
  import org.apache.maven.decoration.GoalDecoratorBindings;
  import org.apache.maven.lifecycle.goal.AbstractMavenGoalPhase;
  import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
  import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
  import org.apache.maven.lifecycle.goal.GoalExecutionException;
  import org.apache.maven.plugin.PluginManager;
  import org.apache.maven.plugin.descriptor.MojoDescriptor;
  
  import java.util.Collections;
  import java.util.HashSet;
  import java.util.Iterator;
  import java.util.LinkedList;
  import java.util.List;
  import java.util.Set;
  
  /**
   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
   * @version $Id: GoalResolutionPhase.java,v 1.1 2004/08/15 15:01:51 jvanzyl Exp $
   */
  public class GoalResolutionPhase extends AbstractMavenGoalPhase
  {
      public void execute( MavenGoalExecutionContext context )
          throws GoalExecutionException
      {
          PluginManager pluginManager = context.getSession().getPluginManager();
  
          try
          {
              // First, start by retrieving the currently-requested goal.
              MojoDescriptor goalDescriptor = context.getMojoDescriptor();
  
              if ( goalDescriptor == null )
              {
                  throw new GoalNotFoundException( context.getGoalName() );
              }
  
              String goal = goalDescriptor.getId();
  
              List resolvedGoals = resolveTopLevel( goal, new HashSet(), new LinkedList(), context, pluginManager );
  
              context.setResolvedGoals( resolvedGoals );
          }
          finally
          {
              context.release( pluginManager );
          }
      }
  
      private List resolveTopLevel( String goal, Set includedGoals, List results, MavenGoalExecutionContext context, PluginManager pluginManager )
      {
  
          // Retrieve the prereqs-driven execution path for this goal, using the DAG.
          List work = pluginManager.getGoals( goal );
  
          // Reverse the original goals list to preserve encapsulation while decorating.
          Collections.reverse( work );
  
          return resolveWithPrereqs( work, includedGoals, results, context, pluginManager );
      }
  
      private List resolveWithPrereqs( List work, Set includedGoals, List results, MavenGoalExecutionContext context, PluginManager pluginManager )
      {
          if ( !work.isEmpty() )
          {
              String goal = (String) work.remove( 0 );
  
              MojoDescriptor descriptor = context.getMojoDescriptor( goal );
  
              if ( descriptor.alwaysExecute() || !includedGoals.contains( goal ) )
              {
                  GoalDecoratorBindings bindings = context.getGoalDecoratorBindings();
                  if ( bindings != null )
                  {
                      List preGoals = bindings.getPreGoals( goal );
  
                      results = resolveGoalDecorators( preGoals, includedGoals, results, context, pluginManager );
                  }
  
                  results = resolveWithPrereqs( work, includedGoals, results, context, pluginManager );
                  includedGoals.add( goal );
                  results.add( goal );
  
                  if ( bindings != null )
                  {
                      List postGoals = bindings.getPostGoals( goal );
                      results = resolveGoalDecorators( postGoals, includedGoals, results, context, pluginManager );
                  }
              }
          }
          return results;
      }
  
      private List resolveGoalDecorators( List preGoals, Set includedGoals, List results, MavenGoalExecutionContext context, PluginManager pluginManager )
      {
          for ( Iterator it = preGoals.iterator(); it.hasNext(); )
          {
              GoalDecorator decorator = (GoalDecorator) it.next();
              String goal = decorator.getDecoratorGoal();
              resolveTopLevel( goal, includedGoals, results, context, pluginManager );
          }
  
          return results;
      }
  
  }
  
  
  
  1.1                  maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/goal/phase/PluginDownloadPhase.java
  
  Index: PluginDownloadPhase.java
  ===================================================================
  package org.apache.maven.lifecycle.goal.phase;
  
  /*
   * 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.lifecycle.goal.AbstractMavenGoalPhase;
  import org.apache.maven.lifecycle.goal.GoalExecutionException;
  import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
  import org.apache.maven.plugin.PluginManager;
  import org.apache.maven.plugin.descriptor.MojoDescriptor;
  import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
  
  /**
   * From the name of the goal we can determine the plugin that houses the
   * goal. The goal will be in the form pluginId:goalName so we take the pluginId
   * portion of the name and with that we can determine if the plugin is installed
   * or not. If the plugin is not installed then we can use the pluginId to retrieve
   * the plugin and install it for use.
   *
   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
   * @version $Id: PluginDownloadPhase.java,v 1.1 2004/08/15 15:01:51 jvanzyl Exp $
   */
  public class PluginDownloadPhase
      extends AbstractMavenGoalPhase
  {
      public void execute( MavenGoalExecutionContext context )
          throws GoalExecutionException
      {
          PluginManager pluginManager = null;
          try
          {
              pluginManager = (PluginManager) context.lookup( PluginManager.ROLE );
          }
          catch ( ComponentLookupException e )
          {
              throw new GoalExecutionException( "Error looking up plugin manager: ", e );
          }
  
          String goalName = context.getGoalName();
  
          // m2 install
  
          // install the install plugin
  
          // if this is a dispatcher goal then turn install in to type:install
  
          // then the appropriate prereqs will be called
  
          // would be good to let the plugin manager deal with all of this
  
          try
          {
              pluginManager.verifyPluginForGoal( goalName );
          }
          catch ( Exception e )
          {
              throw new GoalExecutionException( "Error verifying plugin: ", e );
          }
  
          if ( goalName.indexOf( ":" ) < 0 )
          {
              goalName = context.getProject().getType() + ":" + goalName;
          }
  
          MojoDescriptor md = pluginManager.getMojoDescriptor( goalName );
  
          context.setMojoDescriptor( md );
      }
  }
  
  
  
  1.2       +4 -12     maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/session/DefaultMavenSessionPhaseManager.java
  
  Index: DefaultMavenSessionPhaseManager.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/session/DefaultMavenSessionPhaseManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultMavenSessionPhaseManager.java	12 Aug 2004 22:52:54 -0000	1.1
  +++ DefaultMavenSessionPhaseManager.java	15 Aug 2004 15:01:51 -0000	1.2
  @@ -17,9 +17,6 @@
    */
   
   import org.codehaus.plexus.logging.AbstractLogEnabled;
  -import org.apache.maven.lifecycle.MavenLifecycleManager;
  -import org.apache.maven.lifecycle.MavenGoalExecutionContext;
  -import org.apache.maven.lifecycle.MavenLifecyclePhase;
   
   import java.util.Iterator;
   import java.util.List;
  @@ -30,7 +27,7 @@
    */
   public class DefaultMavenSessionPhaseManager
       extends AbstractLogEnabled
  -    implements MavenLifecycleManager
  +    implements MavenSessionPhaseManager
   {
       private List lifecyclePhases;
   
  @@ -39,21 +36,16 @@
           return lifecyclePhases;
       }
   
  -    public void execute( MavenGoalExecutionContext context )
  +    public void execute( MavenSession context )
           throws Exception
       {
           for ( Iterator iterator = lifecyclePhases.iterator(); iterator.hasNext(); )
           {
  -            MavenLifecyclePhase phase = (MavenLifecyclePhase) iterator.next();
  +            MavenSessionPhase phase = (MavenSessionPhase) iterator.next();
   
               phase.enableLogging( getLogger() );
   
               phase.execute( context );
  -
  -            if ( context.isExecutionFailure() )
  -            {
  -                break;
  -            }
           }
       }
   }
  
  
  
  1.2       +13 -2     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MavenSession.java	12 Aug 2004 22:52:54 -0000	1.1
  +++ MavenSession.java	15 Aug 2004 15:01:51 -0000	1.2
  @@ -8,6 +8,7 @@
   import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
   
   import java.util.Set;
  +import java.util.List;
   
   /*
    * Copyright 2001-2004 The Apache Software Foundation.
  @@ -41,10 +42,13 @@
   
       private Set remoteRepositories;
   
  +    private List goals;
  +
       public MavenSession( PlexusContainer container,
                            PluginManager pluginManager,
                            MavenProject project,
  -                         ArtifactRepository localRepository )
  +                         ArtifactRepository localRepository,
  +                         List goals )
       {
           this.container = container;
   
  @@ -53,6 +57,8 @@
           this.project = project;
   
           this.localRepository = localRepository;
  +
  +        this.goals = goals;
       }
   
       public PlexusContainer getContainer()
  @@ -83,6 +89,11 @@
           }
   
           return remoteRepositories;
  +    }
  +
  +    public List getGoals()
  +    {
  +        return goals;
       }
   
       // ----------------------------------------------------------------------
  
  
  
  1.2       +2 -5      maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/session/MavenSessionPhaseManager.java
  
  Index: MavenSessionPhaseManager.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/session/MavenSessionPhaseManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MavenSessionPhaseManager.java	12 Aug 2004 22:52:54 -0000	1.1
  +++ MavenSessionPhaseManager.java	15 Aug 2004 15:01:51 -0000	1.2
  @@ -16,9 +16,6 @@
    * limitations under the License.
    */
   
  -import org.apache.maven.lifecycle.MavenLifecycleManager;
  -import org.apache.maven.lifecycle.MavenGoalExecutionContext;
  -
   import java.util.List;
   
   /**
  @@ -29,7 +26,7 @@
   {
       String ROLE = MavenSessionPhaseManager.class.getName();
   
  -    void execute( MavenGoalExecutionContext context )
  +    void execute( MavenSession session )
           throws Exception;
   
       List getLifecyclePhases();
  
  
  
  1.1                  maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/session/phase/GoalExecutionPhase.java
  
  Index: GoalExecutionPhase.java
  ===================================================================
  package org.apache.maven.lifecycle.session.phase;
  
  /*
   * 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.ExecutionResponse;
  import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
  import org.apache.maven.lifecycle.goal.MavenGoalPhaseManager;
  import org.apache.maven.lifecycle.session.AbstractMavenSessionPhase;
  import org.apache.maven.lifecycle.session.MavenSession;
  
  import java.util.Iterator;
  
  /**
   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
   * @version $Id: GoalExecutionPhase.java,v 1.1 2004/08/15 15:01:51 jvanzyl Exp $
   */
  public class GoalExecutionPhase
      extends AbstractMavenSessionPhase
  {
      public void execute( MavenSession session )
          throws Exception
      {
          MavenGoalPhaseManager lifecycleManager = (MavenGoalPhaseManager) session.lookup( MavenGoalPhaseManager.ROLE );
  
          ExecutionResponse response = new ExecutionResponse();
  
          for ( Iterator iterator = session.getGoals().iterator(); iterator.hasNext(); )
          {
              String goal = (String) iterator.next();
  
              MavenGoalExecutionContext context;
  
              context = new MavenGoalExecutionContext( session, session.getPluginManager().getMojoDescriptor( goal ) );
  
              context.setGoalName( goal );
  
              lifecycleManager.execute( context );
  
              if ( context.isExecutionFailure() )
              {
                  response.setExecutionFailure( context.getMojoDescriptor().getId(), context.getFailureResponse() );
  
                  break;
              }
          }
      }
  }
  
  
  
  1.2       +0 -4      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultPluginManager.java	9 Aug 2004 19:02:36 -0000	1.1
  +++ DefaultPluginManager.java	15 Aug 2004 15:01:51 -0000	1.2
  @@ -233,8 +233,6 @@
   
           if ( !isPluginInstalled( pluginId ) )
           {
  -            System.out.println( pluginId + " is not installed. Now installing into " + localRepository.getBasedir() + " ..." );
  -
               //!! This is entirely crappy. We need a better naming for plugin artifact ids and
               //   we definitely need better version extraction support.
   
  @@ -251,8 +249,6 @@
       public void addPlugin( Artifact pluginArtifact )
           throws Exception
       {
  -        System.out.println( "adding plugin " + pluginArtifact );
  -
           artifactResolver = (ArtifactResolver) container.lookup( ArtifactResolver.ROLE );
   
           MavenMetadataSource sr = new MavenMetadataSource( remotePluginRepositories,
  
  
  
  1.3       +2 -2      maven-components/maven-core/src/main/java/org/apache/maven/plugin/OgnlProjectValueExtractor.java
  
  Index: OgnlProjectValueExtractor.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/OgnlProjectValueExtractor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- OgnlProjectValueExtractor.java	12 Aug 2004 18:41:15 -0000	1.2
  +++ OgnlProjectValueExtractor.java	15 Aug 2004 15:01:51 -0000	1.3
  @@ -18,7 +18,7 @@
   
   import ognl.Ognl;
   import ognl.OgnlException;
  -import org.apache.maven.lifecycle.MavenGoalExecutionContext;
  +import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
   import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
   
   /**
  
  
  
  1.2       +23 -9     maven-components/maven-core/src/main/resources/META-INF/plexus/components.xml
  
  Index: components.xml
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/resources/META-INF/plexus/components.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- components.xml	9 Aug 2004 19:02:37 -0000	1.1
  +++ components.xml	15 Aug 2004 15:01:51 -0000	1.2
  @@ -14,7 +14,7 @@
             <role>org.codehaus.plexus.i18n.I18N</role>
           </requirement>
           <requirement>
  -          <role>org.apache.maven.lifecycle.MavenLifecycleManager</role>
  +          <role>org.apache.maven.lifecycle.goal.MavenGoalPhaseManager</role>
           </requirement>
         </requirements>
       </component>
  @@ -26,16 +26,30 @@
         </configuration>
       </component>
       <component>
  -      <role>org.apache.maven.lifecycle.MavenLifecycleManager</role>
  -      <implementation>org.apache.maven.lifecycle.DefaultMavenLifecycleManager</implementation>
  +      <role>org.apache.maven.lifecycle.session.MavenSessionPhaseManager</role>
  +      <implementation>org.apache.maven.lifecycle.session.DefaultMavenSessionPhaseManager</implementation>
         <configuration>
           <lifecycle-phases>
  -          <lifecycle-phase implementation="org.apache.maven.lifecycle.phase.PluginDownloadPhase"/>
  -          <lifecycle-phase implementation="org.apache.maven.lifecycle.phase.GoalDecorationPhase"/>
  -          <lifecycle-phase implementation="org.apache.maven.lifecycle.phase.GoalResolutionPhase"/>
  -          <lifecycle-phase implementation="org.apache.maven.lifecycle.phase.DependencyResolutionPhase"/>
  -          <lifecycle-phase implementation="org.apache.maven.lifecycle.phase.DependencyDownloadPhase"/>
  -          <lifecycle-phase implementation="org.apache.maven.lifecycle.phase.GoalAttainmentPhase"/>
  +          <lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.PluginDownloadPhase"/>
  +          <lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.GoalDecorationPhase"/>
  +          <lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.GoalResolutionPhase"/>
  +          <lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.DependencyResolutionPhase"/>
  +          <lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.DependencyDownloadPhase"/>
  +          <lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.GoalAttainmentPhase"/>
  +        </lifecycle-phases>
  +      </configuration>
  +    </component>
  +    <component>
  +      <role>org.apache.maven.lifecycle.goal.MavenGoalPhaseManager</role>
  +      <implementation>org.apache.maven.lifecycle.goal.DefaultMavenGoalPhaseManager</implementation>
  +      <configuration>
  +        <lifecycle-phases>
  +          <lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.PluginDownloadPhase"/>
  +          <lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.GoalDecorationPhase"/>
  +          <lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.GoalResolutionPhase"/>
  +          <lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.DependencyResolutionPhase"/>
  +          <lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.DependencyDownloadPhase"/>
  +          <lifecycle-phase implementation="org.apache.maven.lifecycle.goal.phase.GoalAttainmentPhase"/>
           </lifecycle-phases>
         </configuration>
       </component>
  
  
  
  1.3       +7 -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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MavenTestCase.java	12 Aug 2004 22:52:55 -0000	1.2
  +++ MavenTestCase.java	15 Aug 2004 15:01:51 -0000	1.3
  @@ -17,7 +17,7 @@
    */
   
   import org.apache.maven.artifact.repository.ArtifactRepository;
  -import org.apache.maven.lifecycle.MavenGoalExecutionContext;
  +import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
   import org.apache.maven.lifecycle.session.MavenSession;
   import org.apache.maven.plugin.PluginManager;
   import org.apache.maven.plugin.descriptor.MojoDescriptor;
  @@ -28,6 +28,8 @@
   import org.codehaus.plexus.PlexusTestCase;
   
   import java.io.File;
  +import java.util.ArrayList;
  +import java.util.List;
   
   /**
    * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
  @@ -102,7 +104,9 @@
   
           project.setProperty( "foo", "bar" );
   
  -        MavenSession session = new MavenSession( getContainer(), pluginManager, project, localRepository );
  +        List goals = new ArrayList();
  +
  +        MavenSession session = new MavenSession( getContainer(), pluginManager, project, localRepository, goals );
   
           MojoDescriptor descriptor;
   
  
  
  
  1.2       +3 -2      maven-components/maven-core/src/test/java/org/apache/maven/lifecycle/MavenLifecycleManagerTest.java
  
  Index: MavenLifecycleManagerTest.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/test/java/org/apache/maven/lifecycle/MavenLifecycleManagerTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MavenLifecycleManagerTest.java	9 Aug 2004 19:02:38 -0000	1.1
  +++ MavenLifecycleManagerTest.java	15 Aug 2004 15:01:51 -0000	1.2
  @@ -1,6 +1,7 @@
   package org.apache.maven.lifecycle;
   
   import org.apache.maven.MavenTestCase;
  +import org.apache.maven.lifecycle.goal.MavenGoalPhaseManager;
   
   import java.util.List;
   
  @@ -14,7 +15,7 @@
       public void testMavenLifecycleManager()
           throws Exception
       {
  -        MavenLifecycleManager mlm = (MavenLifecycleManager) lookup( MavenLifecycleManager.ROLE );
  +        MavenGoalPhaseManager mlm = (MavenGoalPhaseManager) lookup( MavenGoalPhaseManager.ROLE );
   
           List lifecyclePhases = mlm.getLifecyclePhases();
   
  
  
  
  1.1                  maven-components/maven-core/src/test/java/org/apache/maven/lifecycle/goal/phase/GoalResolutionPhaseTest.java
  
  Index: GoalResolutionPhaseTest.java
  ===================================================================
  /* Created on Jul 14, 2004 */
  package org.apache.maven.lifecycle.goal.phase;
  
  import org.apache.maven.decoration.DefaultGoalDecorator;
  import org.apache.maven.decoration.GoalDecoratorBindings;
  import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
  import org.apache.maven.MavenTestCase;
  
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Map;
  import java.util.TreeMap;
  
  /**
   * @author jdcasey
   */
  public class GoalResolutionPhaseTest
      extends MavenTestCase
  {
      /*
      <!-- Test main with preGoal and postGoal -->
      <mojo>
        <id>t1:preGoal</id>
        <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
        <instantiationStrategy>singleton</instantiationStrategy>
      </mojo>
      <mojo>
        <id>t1:main</id>
        <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
        <instantiationStrategy>singleton</instantiationStrategy>
      </mojo>
      <mojo>
        <id>t1:postGoal</id>
        <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
        <instantiationStrategy>singleton</instantiationStrategy>
      </mojo>
      <!-- End of test -->
      */
      public void testT1_ShouldFind_PreGoal_MainGoal_PostGoal()
          throws Exception
      {
          String mainGoal = "t1:main";
          String preGoal = "t1:preGoal";
          String postGoal = "t1:postGoal";
  
          GoalDecoratorBindings bindings = new GoalDecoratorBindings();
  
          bindings.addPreGoal( new DefaultGoalDecorator( mainGoal, preGoal ) );
          bindings.addPostGoal( new DefaultGoalDecorator( mainGoal, postGoal ) );
  
          Map messages = new TreeMap();
  
          messages.put( mainGoal, "Main goal is missing." );
          messages.put( preGoal, "preGoal is missing" );
          messages.put( postGoal, "postGoal is missing" );
  
          List order = new ArrayList();
  
          order.add( preGoal );
          order.add( mainGoal );
          order.add( postGoal );
  
          runTest( mainGoal, bindings, order, messages );
      }
  
      /*
      <!-- Test main with prereq -->
      <mojo>
        <id>t2:prereq</id>
        <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
        <instantiationStrategy>singleton</instantiationStrategy>
      </mojo>
      <mojo>
        <id>t2:main</id>
        <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
        <instantiationStrategy>singleton</instantiationStrategy>
        <prereqs>
          <prereq>t2:prereq</prereq>
        </prereqs>
      </mojo>
      <!-- End of test -->
      */
      public void testT2_ShouldFind_Prereq_MainGoal()
          throws Exception
      {
          String mainGoal = "t2:main";
          String prereq = "t2:prereq";
  
          GoalDecoratorBindings bindings = new GoalDecoratorBindings();
  
          Map messages = new TreeMap();
  
          messages.put( mainGoal, "Main goal is missing." );
          messages.put( prereq, "prereq is missing" );
  
          List order = new ArrayList();
  
          order.add( prereq );
          order.add( mainGoal );
  
          runTest( mainGoal, bindings, order, messages );
      }
  
      /*
      <!-- Test main with prereq, preGoal and postGoal -->
      <mojo>
        <id>t3:preGoal</id>
        <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
        <instantiationStrategy>singleton</instantiationStrategy>
      </mojo>
      <mojo>
        <id>t3:prereq</id>
        <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
        <instantiationStrategy>singleton</instantiationStrategy>
      </mojo>
      <mojo>
        <id>t3:main</id>
        <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
        <instantiationStrategy>singleton</instantiationStrategy>
        <prereqs>
          <prereq>t3:prereq</prereq>
        </prereqs>
      </mojo>
      <mojo>
        <id>t3:postGoal</id>
        <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
        <instantiationStrategy>singleton</instantiationStrategy>
      </mojo>
      <!-- End of test -->
      */
      public void testT3_ShouldFind_PreGoal_Prereq_MainGoal_PostGoal()
          throws Exception
      {
          String mainGoal = "t3:main";
          String prereq = "t3:prereq";
          String preGoal = "t3:preGoal";
          String postGoal = "t3:postGoal";
  
          GoalDecoratorBindings bindings = new GoalDecoratorBindings();
  
          bindings.addPreGoal( new DefaultGoalDecorator( mainGoal, preGoal ) );
          bindings.addPostGoal( new DefaultGoalDecorator( mainGoal, postGoal ) );
  
          Map messages = new TreeMap();
  
          messages.put( mainGoal, "Main goal is missing." );
          messages.put( prereq, "prereq is missing" );
          messages.put( preGoal, "preGoal is missing" );
          messages.put( postGoal, "postGoal is missing" );
  
          List order = new ArrayList();
  
          order.add( preGoal );
          order.add( prereq );
          order.add( mainGoal );
          order.add( postGoal );
  
          runTest( mainGoal, bindings, order, messages );
      }
  
      /*
      <!-- Test main with prereq which has preGoal and postGoal -->
      <mojo>
        <id>t4:prereq-preGoal</id>
        <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
        <instantiationStrategy>singleton</instantiationStrategy>
      </mojo>
      <mojo>
        <id>t4:prereq</id>
        <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
        <instantiationStrategy>singleton</instantiationStrategy>
      </mojo>
      <mojo>
        <id>t4:main</id>
        <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
        <instantiationStrategy>singleton</instantiationStrategy>
        <prereqs>
          <prereq>t4:prereq</prereq>
        </prereqs>
      </mojo>
      <mojo>
        <id>t4:prereq-postGoal</id>
        <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
        <instantiationStrategy>singleton</instantiationStrategy>
      </mojo>
      <!-- End of test -->
      */
      public void testT4_ShouldFind_PreGoal_Prereq_PostGoal_MainGoal()
          throws Exception
      {
          String mainGoal = "t4:main";
          String prereq = "t4:prereq";
          String preGoal = "t4:prereq-preGoal";
          String postGoal = "t4:prereq-postGoal";
  
          GoalDecoratorBindings bindings = new GoalDecoratorBindings();
  
          bindings.addPreGoal( new DefaultGoalDecorator( prereq, preGoal ) );
          bindings.addPostGoal( new DefaultGoalDecorator( prereq, postGoal ) );
  
          Map messages = new TreeMap();
  
          messages.put( mainGoal, "Main goal is missing." );
          messages.put( prereq, "prereq is missing" );
          messages.put( preGoal, "preGoal is missing" );
          messages.put( postGoal, "postGoal is missing" );
  
          List order = new ArrayList();
  
          order.add( preGoal );
          order.add( prereq );
          order.add( postGoal );
          order.add( mainGoal );
  
          runTest( mainGoal, bindings, order, messages );
      }
  
      /*
      <!-- Test main with prereq and preGoal which has the same prereq -->
      <mojo>
        <id>t5:prereq</id>
        <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
        <instantiationStrategy>singleton</instantiationStrategy>
      </mojo>
      <mojo>
        <id>t5:preGoal</id>
        <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
        <instantiationStrategy>singleton</instantiationStrategy>
        <prereqs>
          <prereq>t5:prereq</prereq>
        </prereqs>
      </mojo>
      <mojo>
        <id>t5:main</id>
        <implementation>org.apache.maven.plugin.GoalDecorationAndResolutionTestPlugin</implementation>
        <instantiationStrategy>singleton</instantiationStrategy>
        <prereqs>
          <prereq>t5:prereq</prereq>
        </prereqs>
      </mojo>
      <!-- End of test -->
      */
      public void testT5_ShouldFind_Prereq_PreGoal_MainGoal()
          throws Exception
      {
          String mainGoal = "t5:main";
          String prereq = "t5:prereq";
          String preGoal = "t5:preGoal";
  
          GoalDecoratorBindings bindings = new GoalDecoratorBindings();
  
          bindings.addPreGoal( new DefaultGoalDecorator( mainGoal, preGoal ) );
  
          Map messages = new TreeMap();
  
          messages.put( mainGoal, "Main goal is missing." );
          messages.put( prereq, "prereq is missing" );
          messages.put( preGoal, "preGoal is missing" );
  
          List order = new ArrayList();
  
          order.add( prereq );
          order.add( preGoal );
          order.add( mainGoal );
  
          runTest( mainGoal, bindings, order, messages );
      }
  
      private void runTest( String mainGoal, GoalDecoratorBindings bindings,
                            List expectedOrder, Map messages )
          throws Exception
      {
          MavenGoalExecutionContext context = createGoalExecutionContext( mainGoal );
  
          context.setGoalDecoratorBindings( bindings );
  
          GoalResolutionPhase phase = new GoalResolutionPhase();
  
          phase.execute( context );
  
          List goals = context.getResolvedGoals();
  
          System.out.println( "Resolved goals: " + goals );
  
          assertNotNull( goals );
  
          assertEquals( expectedOrder.size(), goals.size() );
  
          int index = 0;
  
          for ( Iterator it = expectedOrder.iterator(); it.hasNext(); )
          {
              String goal = (String) it.next();
  
              String failureMessage = (String) messages.get( goal );
  
              String resolvedGoal = (String) goals.get( index++ );
  
              assertEquals( failureMessage, goal, resolvedGoal );
          }
      }
  }
  
  
  
  1.4       +2 -2      maven-components/maven-core/src/test/java/org/apache/maven/plugin/OgnlProjectValueExtractorTest.java
  
  Index: OgnlProjectValueExtractorTest.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/test/java/org/apache/maven/plugin/OgnlProjectValueExtractorTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- OgnlProjectValueExtractorTest.java	12 Aug 2004 22:52:55 -0000	1.3
  +++ OgnlProjectValueExtractorTest.java	15 Aug 2004 15:01:52 -0000	1.4
  @@ -2,7 +2,7 @@
   
   import org.apache.maven.MavenTestCase;
   import org.apache.maven.artifact.repository.ArtifactRepository;
  -import org.apache.maven.lifecycle.MavenGoalExecutionContext;
  +import org.apache.maven.lifecycle.goal.MavenGoalExecutionContext;
   import org.apache.maven.project.MavenProject;
   import org.apache.maven.project.MavenProjectBuilder;
   
  
  
  

Mime
View raw message