You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2005/06/20 09:17:34 UTC

svn commit: r191413 - in /maven/components/trunk: maven-core/src/main/java/org/apache/maven/ maven-core/src/main/java/org/apache/maven/execution/ maven-core/src/main/java/org/apache/maven/lifecycle/ maven-core/src/main/java/org/apache/maven/plugin/ mav...

Author: brett
Date: Mon Jun 20 00:17:32 2005
New Revision: 191413

URL: http://svn.apache.org/viewcvs?rev=191413&view=rev
Log:
PR: MNG-471, MNG-489
- refactor project out of MavenSession so that it can be cloned
- refactor lifecycle construction out so we can clone the existing one and pass it into a new execution
- only resolve plugins that are executed (MNG-489)


Modified:
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
    maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java
    maven/components/trunk/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java?rev=191413&r1=191412&r2=191413&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java Mon Jun 20 00:17:32 2005
@@ -253,7 +253,7 @@
         try
         {
             // Actual meat of the code.
-            response = lifecycleExecutor.execute( goals, session );
+            response = lifecycleExecutor.execute( goals, session, project );
 
             dispatcher.dispatchEnd( event, project.getId() );
         }

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java?rev=191413&r1=191412&r2=191413&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java Mon Jun 20 00:17:32 2005
@@ -85,11 +85,6 @@
         return container;
     }
 
-    public MavenProject getProject()
-    {
-        return project;
-    }
-
     public ArtifactRepository getLocalRepository()
     {
         return localRepository;

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=191413&r1=191412&r2=191413&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java Mon Jun 20 00:17:32 2005
@@ -80,8 +80,9 @@
      *
      * @param tasks
      * @param session
+     * @param project
      */
-    public MavenExecutionResponse execute( List tasks, MavenSession session )
+    public MavenExecutionResponse execute( List tasks, MavenSession session, MavenProject project )
         throws LifecycleExecutionException
     {
         MavenExecutionResponse response = new MavenExecutionResponse();
@@ -93,7 +94,7 @@
             for ( Iterator i = tasks.iterator(); i.hasNext(); )
             {
                 String task = (String) i.next();
-                executeGoal( task, session );
+                executeGoal( task, session, project );
             }
         }
         catch ( MojoExecutionException e )
@@ -112,46 +113,41 @@
         return response;
     }
 
-    private void executeGoal( String task, MavenSession session )
+    private void executeGoal( String task, MavenSession session, MavenProject project )
         throws LifecycleExecutionException, PluginNotFoundException, MojoExecutionException, ArtifactResolutionException
     {
         Map phaseMap = new HashMap();
 
-        String selectedPhase = null;
-
         for ( Iterator i = phases.iterator(); i.hasNext(); )
         {
             String p = (String) i.next();
 
             // Make a copy of the phase as we will modify it
             phaseMap.put( p, new ArrayList() );
-
-            if ( task.equals( p ) )
-            {
-                selectedPhase = p;
-            }
         }
 
-        List goals;
-
-        // Need to verify all the plugins up front, as standalone goals should use the version from the POM.
-        for ( Iterator i = session.getProject().getBuildPlugins().iterator(); i.hasNext(); )
+        if ( phaseMap.containsKey( task ) )
         {
-            Plugin plugin = (Plugin) i.next();
-
-            verifyPlugin( plugin, session );
+            // we have a lifecycle phase, so lets bind all the necessary goals
+            constructLifecyclePhaseMap( session, phaseMap, task, project );
         }
 
-        if ( selectedPhase != null )
-        {
-            // we have a lifecycle phase, so lets bind all the necessary goals
-            constructLifecyclePhaseMap( session, phaseMap, selectedPhase );
+        executeGoalWithLifecycle( task, session, phaseMap, project );
+    }
 
-            goals = processGoalChain( selectedPhase, phaseMap );
+    private void executeGoalWithLifecycle( String task, MavenSession session, Map lifecycleMappings,
+                                           MavenProject project )
+        throws ArtifactResolutionException, LifecycleExecutionException, MojoExecutionException
+    {
+        List goals;
+
+        if ( lifecycleMappings.containsKey( task ) )
+        {
+            goals = processGoalChain( task, lifecycleMappings );
         }
         else
         {
-            MojoDescriptor mojoDescriptor = getMojoDescriptor( task, session );
+            MojoDescriptor mojoDescriptor = getMojoDescriptor( task, session, project );
             goals = Collections.singletonList( new MojoExecution( mojoDescriptor ) );
         }
 
@@ -159,17 +155,18 @@
         {
             MojoExecution mojoExecution = (MojoExecution) i.next();
 
-            String executePhase = mojoExecution.getMojoDescriptor().getExecutePhase();
+            MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
+            String executePhase = mojoDescriptor.getExecutePhase();
 
             if ( executePhase != null )
             {
-                // TODO: with introduction of cloned lifecyle, we want to avoid reconstructing some things - narrow
-                executeGoal( executePhase, session );
+                forkLifecycle( executePhase, mojoDescriptor.getExecuteLifecycle(), session, lifecycleMappings,
+                               project );
             }
 
             try
             {
-                pluginManager.executeMojo( mojoExecution, session );
+                pluginManager.executeMojo( project, mojoExecution, session );
             }
             catch ( PluginManagerException e )
             {
@@ -178,26 +175,50 @@
         }
     }
 
-    private void constructLifecyclePhaseMap( MavenSession session, Map phaseMap, String selectedPhase )
+    private void forkLifecycle( String executePhase, String executeLifecycle, MavenSession session,
+                                Map lifecycleMappings, MavenProject project )
+        throws LifecycleExecutionException, MojoExecutionException, ArtifactResolutionException
+    {
+        // Deep copy of the lifecycle
+        Map phaseMap = new HashMap();
+        for ( Iterator i = lifecycleMappings.keySet().iterator(); i.hasNext(); )
+        {
+            String phase = (String) i.next();
+            List mappings = (List) lifecycleMappings.get( phase );
+            phaseMap.put( phase, new ArrayList( mappings ) );
+        }
+
+        if ( executeLifecycle != null )
+        {
+            // TODO: overlay new lifecycle
+        }
+
+        // TODO: clone project
+        executeGoalWithLifecycle( executePhase, session, phaseMap, project );
+    }
+
+    private void constructLifecyclePhaseMap( MavenSession session, Map phaseMap, String selectedPhase,
+                                             MavenProject project )
         throws ArtifactResolutionException, LifecycleExecutionException
     {
         // first, bind those associated with the packaging
-        bindLifecycleForPackaging( session, phaseMap, selectedPhase );
+        bindLifecycleForPackaging( session, phaseMap, selectedPhase, project );
 
         // next, loop over plugins and for any that have a phase, bind it
-        for ( Iterator i = session.getProject().getBuildPlugins().iterator(); i.hasNext(); )
+        for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); )
         {
             Plugin plugin = (Plugin) i.next();
 
-            bindPluginToLifecycle( plugin, session, phaseMap );
+            bindPluginToLifecycle( plugin, session, phaseMap, project );
         }
     }
 
-    private void bindLifecycleForPackaging( MavenSession session, Map phaseMap, String selectedPhase )
+    private void bindLifecycleForPackaging( MavenSession session, Map phaseMap, String selectedPhase,
+                                            MavenProject project )
         throws ArtifactResolutionException, LifecycleExecutionException
     {
         Map mappings;
-        String packaging = session.getProject().getPackaging();
+        String packaging = project.getPackaging();
         try
         {
             LifecycleMapping m = (LifecycleMapping) session.lookup( LifecycleMapping.ROLE, packaging );
@@ -222,7 +243,7 @@
                 {
                     String goal = tok.nextToken().trim();
 
-                    MojoDescriptor mojoDescriptor = getMojoDescriptor( goal, session );
+                    MojoDescriptor mojoDescriptor = getMojoDescriptor( goal, session, project );
                     addToPhaseMap( phaseMap, phase, new MojoExecution( mojoDescriptor ), session.getSettings() );
                 }
             }
@@ -239,9 +260,10 @@
      * phase in the lifecycle and if it does place it at the end of the list of goals
      * to execute for that given phase.
      *
+     * @param project
      * @param session
      */
-    private void bindPluginToLifecycle( Plugin plugin, MavenSession session, Map phaseMap )
+    private void bindPluginToLifecycle( Plugin plugin, MavenSession session, Map phaseMap, MavenProject project )
         throws LifecycleExecutionException, ArtifactResolutionException
     {
         if ( plugin.getGoals() != null && !plugin.getGoals().isEmpty() )
@@ -253,7 +275,7 @@
         PluginDescriptor pluginDescriptor;
         Settings settings = session.getSettings();
 
-        pluginDescriptor = verifyPlugin( plugin, session );
+        pluginDescriptor = verifyPlugin( plugin, session, project );
 
         if ( pluginDescriptor.getMojos() != null && !pluginDescriptor.getMojos().isEmpty() )
         {
@@ -277,7 +299,7 @@
         }
     }
 
-    private PluginDescriptor verifyPlugin( Plugin plugin, MavenSession session )
+    private PluginDescriptor verifyPlugin( Plugin plugin, MavenSession session, MavenProject project )
         throws ArtifactResolutionException, LifecycleExecutionException
     {
         String groupId = plugin.getGroupId();
@@ -289,7 +311,6 @@
         PluginDescriptor pluginDescriptor;
         try
         {
-            MavenProject project = session.getProject();
             ArtifactRepository localRepository = session.getLocalRepository();
             pluginDescriptor = pluginManager.verifyPlugin( groupId, artifactId, version, project, session.getSettings(),
                                                            localRepository );
@@ -408,7 +429,7 @@
         return goals;
     }
 
-    private MojoDescriptor getMojoDescriptor( String task, MavenSession session )
+    private MojoDescriptor getMojoDescriptor( String task, MavenSession session, MavenProject project )
         throws ArtifactResolutionException, LifecycleExecutionException
     {
         String groupId = null;
@@ -425,13 +446,31 @@
             String prefix = tok.nextToken();
             goal = tok.nextToken();
 
-            pluginDescriptor = pluginManager.verifyPlugin( prefix );
+            String id = pluginManager.getPluginIdFromPrefix( prefix );
 
-            if ( pluginDescriptor == null )
+            if ( id == null )
             {
                 groupId = PluginDescriptor.getDefaultPluginGroupId();
                 artifactId = PluginDescriptor.getDefaultPluginArtifactId( prefix );
             }
+            else
+            {
+                tok = new StringTokenizer( id, ":" );
+                groupId = tok.nextToken();
+                artifactId = tok.nextToken();
+                version = tok.nextToken();
+            }
+
+            for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); )
+            {
+                Plugin plugin = (Plugin) i.next();
+
+                if ( plugin.getGroupId().equals( groupId ) && plugin.getArtifactId().equals( artifactId ) )
+                {
+                    version = plugin.getVersion();
+                    break;
+                }
+            }
         }
         else if ( numTokens == 4 )
         {
@@ -447,7 +486,6 @@
             throw new LifecycleExecutionException( message );
         }
 
-        MavenProject project = session.getProject();
         if ( pluginDescriptor == null )
         {
             try

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java?rev=191413&r1=191412&r2=191413&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java Mon Jun 20 00:17:32 2005
@@ -18,6 +18,7 @@
 
 import org.apache.maven.execution.MavenExecutionResponse;
 import org.apache.maven.execution.MavenSession;
+import org.apache.maven.project.MavenProject;
 
 import java.util.List;
 
@@ -29,7 +30,7 @@
 {
     String ROLE = LifecycleExecutor.class.getName();
 
-    MavenExecutionResponse execute( List tasks, MavenSession session )
+    MavenExecutionResponse execute( List tasks, MavenSession session, MavenProject project )
         throws LifecycleExecutionException;
 
 }

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=191413&r1=191412&r2=191413&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java Mon Jun 20 00:17:32 2005
@@ -82,7 +82,7 @@
 {
     protected Map pluginDescriptors;
 
-    protected Map pluginDescriptorsByPrefix;
+    protected Map pluginIdsByPrefix;
 
     protected PlexusContainer container;
 
@@ -100,7 +100,7 @@
     {
         pluginDescriptors = new HashMap();
 
-        pluginDescriptorsByPrefix = new HashMap();
+        pluginIdsByPrefix = new HashMap();
 
         pluginDescriptorBuilder = new PluginDescriptorBuilder();
     }
@@ -128,9 +128,10 @@
                 pluginDescriptors.put( key, pluginDescriptor );
 
                 // TODO: throw an (not runtime) exception if there is a prefix overlap - means doing so elsewhere
-                if ( !pluginDescriptorsByPrefix.containsKey( pluginDescriptor.getGoalPrefix() ) )
+                // we also need to deal with multiple versions somehow - currently, first wins
+                if ( !pluginIdsByPrefix.containsKey( pluginDescriptor.getGoalPrefix() ) )
                 {
-                    pluginDescriptorsByPrefix.put( pluginDescriptor.getGoalPrefix(), pluginDescriptor );
+                    pluginIdsByPrefix.put( pluginDescriptor.getGoalPrefix(), pluginDescriptor.getId() );
                 }
             }
         }
@@ -150,11 +151,6 @@
         return (PluginDescriptor) pluginDescriptors.get( key );
     }
 
-    private PluginDescriptor getPluginDescriptor( String prefix )
-    {
-        return (PluginDescriptor) pluginDescriptorsByPrefix.get( prefix );
-    }
-
     private boolean isPluginInstalled( String pluginKey )
     {
         //        String key = PluginDescriptor.constructPluginKey( groupId, artifactId, version );
@@ -164,16 +160,16 @@
 
     private boolean isPluginInstalledForPrefix( String prefix )
     {
-        return pluginDescriptorsByPrefix.containsKey( prefix );
+        return pluginIdsByPrefix.containsKey( prefix );
     }
 
-    public PluginDescriptor verifyPlugin( String prefix )
+    public String getPluginIdFromPrefix( String prefix )
     {
         if ( !isPluginInstalledForPrefix( prefix ) )
         {
             // TODO: lookup remotely
         }
-        return getPluginDescriptor( prefix );
+        return (String) pluginIdsByPrefix.get( prefix );
     }
 
     public PluginDescriptor verifyPlugin( String groupId, String artifactId, String version, MavenProject project,
@@ -347,7 +343,7 @@
     // Mojo execution
     // ----------------------------------------------------------------------
 
-    public void executeMojo( MojoExecution mojoExecution, MavenSession session )
+    public void executeMojo( MavenProject project, MojoExecution mojoExecution, MavenSession session )
         throws ArtifactResolutionException, PluginManagerException, MojoExecutionException
     {
         MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
@@ -366,8 +362,8 @@
                 artifactFactory = (ArtifactFactory) container.lookup( ArtifactFactory.ROLE );
 
                 resolveTransitiveDependencies( session, artifactResolver, mavenProjectBuilder, mojoDescriptor
-                    .isDependencyResolutionRequired(), artifactFactory );
-                downloadDependencies( session, artifactResolver );
+                    .isDependencyResolutionRequired(), artifactFactory, project );
+                downloadDependencies( project, session, artifactResolver );
             }
             catch ( ComponentLookupException e )
             {
@@ -403,11 +399,11 @@
             String groupId = pluginDescriptor.getGroupId();
             String artifactId = pluginDescriptor.getArtifactId();
             String executionId = mojoExecution.getExecutionId();
-            Xpp3Dom dom = session.getProject().getGoalConfiguration( groupId, artifactId, executionId, goalId );
-            Xpp3Dom reportDom = session.getProject().getReportConfiguration( groupId, artifactId, executionId );
+            Xpp3Dom dom = project.getGoalConfiguration( groupId, artifactId, executionId, goalId );
+            Xpp3Dom reportDom = project.getReportConfiguration( groupId, artifactId, executionId );
             dom = Xpp3Dom.mergeXpp3Dom( dom, reportDom );
 
-            plugin = getConfiguredMojo( pluginContainer, mojoDescriptor, session, dom );
+            plugin = getConfiguredMojo( pluginContainer, mojoDescriptor, session, dom, project );
         }
         catch ( PluginConfigurationException e )
         {
@@ -461,7 +457,7 @@
     }
 
     public List getReports( String groupId, String artifactId, String version, ReportSet reportSet,
-                            MavenSession session )
+                            MavenSession session, MavenProject project )
         throws PluginManagerException, PluginVersionResolutionException, PluginConfigurationException
     {
         PluginDescriptor pluginDescriptor = getPluginDescriptor( groupId, artifactId, version );
@@ -488,9 +484,9 @@
                     MojoExecution mojoExecution = new MojoExecution( mojoDescriptor, id );
 
                     String executionId = mojoExecution.getExecutionId();
-                    Xpp3Dom dom = session.getProject().getReportConfiguration( groupId, artifactId, executionId );
+                    Xpp3Dom dom = project.getReportConfiguration( groupId, artifactId, executionId );
 
-                    reports.add( getConfiguredMojo( pluginContainer, mojoDescriptor, session, dom ) );
+                    reports.add( getConfiguredMojo( pluginContainer, mojoDescriptor, session, dom, project ) );
                 }
                 catch ( ComponentLookupException e )
                 {
@@ -516,7 +512,7 @@
     }
 
     private Mojo getConfiguredMojo( PlexusContainer pluginContainer, MojoDescriptor mojoDescriptor,
-                                    MavenSession session, Xpp3Dom dom )
+                                    MavenSession session, Xpp3Dom dom, MavenProject project )
         throws ComponentLookupException, PluginConfigurationException
     {
         Mojo plugin = (Mojo) pluginContainer.lookup( Mojo.ROLE, mojoDescriptor.getRoleHint() );
@@ -546,7 +542,8 @@
         //                                                                          mojoDescriptor.getConfiguration() );
 
         ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, pluginDescriptor,
-                                                                                          pathTranslator, getLogger() );
+                                                                                          pathTranslator, getLogger(),
+                                                                                          project );
 
         checkRequiredParameters( mojoDescriptor, mergedConfiguration, expressionEvaluator, plugin );
 
@@ -882,11 +879,9 @@
 
     private void resolveTransitiveDependencies( MavenSession context, ArtifactResolver artifactResolver,
                                                 MavenProjectBuilder mavenProjectBuilder, String scope,
-                                                ArtifactFactory artifactFactory )
+                                                ArtifactFactory artifactFactory, MavenProject project )
         throws ArtifactResolutionException
     {
-        MavenProject project = context.getProject();
-
         MavenMetadataSource sourceReader = new MavenMetadataSource( artifactResolver, mavenProjectBuilder,
                                                                     artifactFactory );
 
@@ -904,10 +899,10 @@
     // Artifact downloading
     // ----------------------------------------------------------------------
 
-    private void downloadDependencies( MavenSession context, ArtifactResolver artifactResolver )
+    private void downloadDependencies( MavenProject project, MavenSession context, ArtifactResolver artifactResolver )
         throws ArtifactResolutionException
     {
-        for ( Iterator it = context.getProject().getArtifacts().iterator(); it.hasNext(); )
+        for ( Iterator it = project.getArtifacts().iterator(); it.hasNext(); )
         {
             Artifact artifact = (Artifact) it.next();
 
@@ -916,7 +911,7 @@
         }
 
         Set pluginArtifacts = new HashSet();
-        for ( Iterator it = context.getProject().getPluginArtifacts().iterator(); it.hasNext(); )
+        for ( Iterator it = project.getPluginArtifacts().iterator(); it.hasNext(); )
         {
             Artifact artifact = (Artifact) it.next();
 
@@ -924,9 +919,9 @@
 
             pluginArtifacts.add( artifact );
         }
-        context.getProject().setPluginArtifacts( pluginArtifacts );
+        project.setPluginArtifacts( pluginArtifacts );
 
-        artifactResolver.resolve( context.getProject().getParentArtifact(), context.getRemoteRepositories(), context
+        artifactResolver.resolve( project.getParentArtifact(), context.getRemoteRepositories(), context
             .getLocalRepository() );
     }
 

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java?rev=191413&r1=191412&r2=191413&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java Mon Jun 20 00:17:32 2005
@@ -36,15 +36,16 @@
 {
     String ROLE = PluginManager.class.getName();
 
-    void executeMojo( MojoExecution execution, MavenSession session )
+    void executeMojo( MavenProject project, MojoExecution execution, MavenSession session )
         throws MojoExecutionException, PluginManagerException, ArtifactResolutionException;
 
-    PluginDescriptor verifyPlugin( String prefix );
+    String getPluginIdFromPrefix( String prefix );
 
     PluginDescriptor verifyPlugin( String groupId, String artifactId, String version, MavenProject project,
                                    Settings settings, ArtifactRepository localRepository )
         throws ArtifactResolutionException, PluginManagerException, PluginVersionResolutionException;
 
-    List getReports( String groupId, String artifactId, String version, ReportSet reportSet, MavenSession session )
+    List getReports( String groupId, String artifactId, String version, ReportSet reportSet, MavenSession session,
+                     MavenProject project )
         throws PluginManagerException, PluginVersionResolutionException, PluginConfigurationException;
 }

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java?rev=191413&r1=191412&r2=191413&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java Mon Jun 20 00:17:32 2005
@@ -18,6 +18,7 @@
 
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.path.PathTranslator;
 import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
 import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
@@ -42,12 +43,16 @@
 
     private final PluginDescriptor pluginDescriptor;
 
-    public PluginParameterExpressionEvaluator( MavenSession context, PluginDescriptor pluginDescriptor, PathTranslator pathTranslator, Logger logger )
+    private final MavenProject project;
+
+    public PluginParameterExpressionEvaluator( MavenSession context, PluginDescriptor pluginDescriptor,
+                                               PathTranslator pathTranslator, Logger logger, MavenProject project )
     {
         this.context = context;
         this.pluginDescriptor = pluginDescriptor;
         this.pathTranslator = pathTranslator;
         this.logger = logger;
+        this.project = project;
     }
 
     public Object evaluate( String expr )
@@ -90,7 +95,7 @@
         }
         else if ( expression.equals( "project" ) )
         {
-            value = context.getProject();
+            value = project;
         }
         else if ( expression.startsWith( "project" ) )
         {
@@ -101,12 +106,12 @@
                 if ( pathSeparator > 0 )
                 {
                     String pathExpression = expression.substring( 1, pathSeparator );
-                    value = ReflectionValueExtractor.evaluate( pathExpression, context.getProject() );
+                    value = ReflectionValueExtractor.evaluate( pathExpression, project );
                     value = value + expression.substring( pathSeparator );
                 }
                 else
                 {
-                    value = ReflectionValueExtractor.evaluate( expression.substring( 1 ), context.getProject() );
+                    value = ReflectionValueExtractor.evaluate( expression.substring( 1 ), project );
                 }
             }
             catch ( Exception e )
@@ -170,7 +175,7 @@
         }
         else if ( expression.equals( "basedir" ) )
         {
-            value = context.getProject().getBasedir().getAbsolutePath();
+            value = project.getBasedir().getAbsolutePath();
         }
         else if ( expression.startsWith( "basedir" ) )
         {
@@ -178,8 +183,7 @@
 
             if ( pathSeparator > 0 )
             {
-                value = context.getProject().getFile().getParentFile().getAbsolutePath() +
-                    expression.substring( pathSeparator );
+                value = project.getFile().getParentFile().getAbsolutePath() + expression.substring( pathSeparator );
             }
             else
             {
@@ -188,15 +192,15 @@
         }
         else
         {
-            // Check properties that have been injected via profiles before we default over to 
+            // Check properties that have been injected via profiles before we default over to
             // system properties.
-            
-            if( context.getProject().getProfileProperties() != null )
+
+            if ( project.getProfileProperties() != null )
             {
-                value = context.getProject().getProfileProperties().getProperty( expression );
+                value = project.getProfileProperties().getProperty( expression );
             }
 
-            if( value == null )
+            if ( value == null )
             {
                 // We will attempt to get nab a system property as a way to specify a
                 // parameter to a plugins. My particular case here is allowing the surefire
@@ -243,16 +247,16 @@
     public File alignToBaseDirectory( File file )
     {
         File basedir = null;
-        
-        if ( context != null && context.getProject() != null && context.getProject().getFile() != null )
+
+        if ( project != null && project.getFile() != null )
         {
-            basedir = context.getProject().getFile().getParentFile();
+            basedir = project.getFile().getParentFile();
         }
         else
         {
             basedir = new File( "." ).getAbsoluteFile().getParentFile();
         }
-        
+
         return new File( pathTranslator.alignToBaseDirectory( file.getPath(), basedir ) );
     }
 

Modified: maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java?rev=191413&r1=191412&r2=191413&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java (original)
+++ maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java Mon Jun 20 00:17:32 2005
@@ -138,7 +138,8 @@
         MavenSession session = createSession( project, container, repo );
 
         ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, pluginDescriptor,
-                                                                                          null, container.getLogger() );
+                                                                                          null, container.getLogger(),
+                                                                                          project );
         return expressionEvaluator;
     }
 }

Modified: maven/components/trunk/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java?rev=191413&r1=191412&r2=191413&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java Mon Jun 20 00:17:32 2005
@@ -746,7 +746,7 @@
                     {
                         reports.addAll(
                             pluginManager.getReports( reportPlugin.getGroupId(), reportPlugin.getArtifactId(),
-                                                      reportPlugin.getVersion(), null, session ) );
+                                                      reportPlugin.getVersion(), null, session, project ) );
 
                     }
                     else
@@ -757,7 +757,7 @@
 
                             reports.addAll(
                                 pluginManager.getReports( reportPlugin.getGroupId(), reportPlugin.getArtifactId(),
-                                                          reportPlugin.getVersion(), reportSet, session ) );
+                                                          reportPlugin.getVersion(), reportSet, session, project ) );
                         }
                     }
                 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org