maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r812869 - in /maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven: ./ lifecycle/ project/
Date Wed, 09 Sep 2009 10:07:01 GMT
Author: bentmann
Date: Wed Sep  9 10:07:01 2009
New Revision: 812869

URL: http://svn.apache.org/viewvc?rev=812869&view=rev
Log:
[MNG-4342] [regression] Multiple goals within single execution with equally named parameter
get configured with wrong default values

Modified:
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java?rev=812869&r1=812868&r2=812869&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java Wed Sep
 9 10:07:01 2009
@@ -311,12 +311,6 @@
     {
         ProjectBuildingRequest projectBuildingRequest = request.getProjectBuildingRequest();
 
-        /*
-         * NOTE: We delay plugin configuration processing until a project is actually build
to allow plugins to be
-         * resolved from the reactor.
-         */
-        projectBuildingRequest.setProcessPluginConfiguration( false );
-
         List<ProjectBuildingResult> results = projectBuilder.build( files, request.isRecursive(),
projectBuildingRequest );
 
         for ( ProjectBuildingResult result : results )

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=812869&r1=812868&r2=812869&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
(original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
Wed Sep  9 10:07:01 2009
@@ -273,7 +273,7 @@
                 fireEvent( session, null, LifecycleEventCatapult.PROJECT_STARTED );
 
                 repositoryRequest.setRemoteRepositories( currentProject.getPluginArtifactRepositories()
);
-                populateDefaultConfigurationForPlugins( currentProject.getBuild().getPlugins(),
repositoryRequest );
+                resolveMissingPluginVersions( currentProject.getBuildPlugins(), repositoryRequest
);
 
                 ClassRealm projectRealm = currentProject.getClassRealm();
                 if ( projectRealm != null )
@@ -722,7 +722,7 @@
             populateMojoExecutionConfiguration( project, mojoExecution,
                                                 MojoExecution.Source.CLI.equals( mojoExecution.getSource()
) );
 
-            extractMojoConfiguration( mojoExecution );
+            finalizeMojoConfiguration( mojoExecution );
 
             calculateForkedExecutions( mojoExecution, session, project, new HashSet<MojoDescriptor>()
);
 
@@ -1120,7 +1120,7 @@
 
         populateMojoExecutionConfiguration( project, forkedExecution, true );
 
-        extractMojoConfiguration( forkedExecution );
+        finalizeMojoConfiguration( forkedExecution );
 
         calculateForkedExecutions( forkedExecution, session, project, alreadyForkedExecutions
);
 
@@ -1163,13 +1163,11 @@
 
         for ( List<MojoExecution> forkedExecutions : lifecycleMappings.values() )
         {
-            for ( Iterator<MojoExecution> it = forkedExecutions.iterator(); it.hasNext();
)
+            for ( MojoExecution forkedExecution : forkedExecutions )
             {
-                MojoExecution forkedExecution = it.next();
-
                 if ( !alreadyForkedExecutions.contains( forkedExecution.getMojoDescriptor()
) )
                 {
-                    extractMojoConfiguration( forkedExecution );
+                    finalizeMojoConfiguration( forkedExecution );
 
                     calculateForkedExecutions( forkedExecution, session, project, alreadyForkedExecutions
);
 
@@ -1282,13 +1280,9 @@
 
         Plugin plugin = findPlugin( g, a, project.getBuildPlugins() );
 
-        boolean managedPlugin = false;
-
         if ( plugin == null && project.getPluginManagement() != null )
         {
             plugin = findPlugin( g, a, project.getPluginManagement().getPlugins() );
-
-            managedPlugin = true;
         }
 
         MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
@@ -1306,18 +1300,6 @@
 
                     mojoConfiguration = Xpp3Dom.mergeXpp3Dom( mojoExecution.getConfiguration(),
mojoConfiguration );
 
-                    /*
-                     * The model only contains the default configuration for those goals
that are present in the plugin
-                     * execution. For goals invoked from the CLI or a forked execution, we
need to grab the default
-                     * parameter values explicitly.
-                     */
-                    if ( managedPlugin || !e.getGoals().contains( mojoExecution.getGoal()
) )
-                    {
-                        Xpp3Dom defaultConfiguration = getMojoConfiguration( mojoDescriptor
);
-
-                        mojoConfiguration = Xpp3Dom.mergeXpp3Dom( mojoConfiguration, defaultConfiguration
);
-                    }
-
                     mojoExecution.setConfiguration( mojoConfiguration );
 
                     return;
@@ -1344,13 +1326,26 @@
         }
     }
 
-    private void extractMojoConfiguration( MojoExecution mojoExecution )
+    /**
+     * Post-processes the effective configuration for the specified mojo execution. This
step discards all parameters
+     * from the configuration that are not applicable to the mojo and injects the default
values for any missing
+     * parameters.
+     * 
+     * @param mojoExecution The mojo execution whose configuration should be finalized, must
not be {@code null}.
+     */
+    private void finalizeMojoConfiguration( MojoExecution mojoExecution )
     {
-        Xpp3Dom configuration = mojoExecution.getConfiguration();
+        MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
+
+        Xpp3Dom mojoConfiguration = mojoExecution.getConfiguration();
+
+        mojoConfiguration = extractMojoConfiguration( mojoConfiguration, mojoDescriptor );
 
-        configuration = extractMojoConfiguration( configuration, mojoExecution.getMojoDescriptor()
);
+        Xpp3Dom defaultConfiguration = getMojoConfiguration( mojoDescriptor );
 
-        mojoExecution.setConfiguration( configuration );
+        mojoConfiguration = Xpp3Dom.mergeXpp3Dom( mojoConfiguration, defaultConfiguration,
Boolean.TRUE );
+
+        mojoExecution.setConfiguration( mojoConfiguration );
     }
 
     /**
@@ -1645,82 +1640,25 @@
             plugin.getExecutions().add( execution );
         }
     }
-    
-    public void populateDefaultConfigurationForPlugin( Plugin plugin, RepositoryRequest repositoryRequest
) 
+
+    private void resolveMissingPluginVersions( Collection<Plugin> plugins, RepositoryRequest
repositoryRequest )
         throws LifecycleExecutionException
     {
-        if ( plugin.getVersion() == null )
-        {
-            try
-            {
-                resolvePluginVersion( plugin, repositoryRequest );
-            }
-            catch ( PluginVersionResolutionException e )
-            {
-                throw new LifecycleExecutionException( "Error resolving version for plugin
" + plugin.getKey(), e );
-            }
-        }
-
-        try
+        for ( Plugin plugin : plugins )
         {
-            // NOTE: Retrieve the plugin descriptor regardless whether there are any executions
to verify the plugin
-            PluginDescriptor pluginDescriptor = pluginManager.loadPlugin( plugin, repositoryRequest
);
-
-            for ( PluginExecution pluginExecution : plugin.getExecutions() )
+            if ( plugin.getVersion() == null )
             {
-                for ( String goal : pluginExecution.getGoals() )
+                try
                 {
-                    MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
-
-                    if ( mojoDescriptor == null )
-                    {
-                        throw new MojoNotFoundException( goal, pluginDescriptor );
-                    }
-
-                    Xpp3Dom defaultConfiguration = getMojoConfiguration( mojoDescriptor );
-
-                    Xpp3Dom executionConfiguration =
-                        Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) pluginExecution.getConfiguration(),
defaultConfiguration,
-                                              Boolean.TRUE );
-
-                    pluginExecution.setConfiguration( executionConfiguration );
+                    resolvePluginVersion( plugin, repositoryRequest );
+                }
+                catch ( PluginVersionResolutionException e )
+                {
+                    throw new LifecycleExecutionException( "Error resolving version for plugin
" + plugin.getKey()
+                        + ": " + e.getMessage(), e );
                 }
             }
         }
-        catch ( PluginNotFoundException e )
-        {
-            throw new LifecycleExecutionException( "Error getting plugin information for
" + plugin.getId() + ": "
-                + e.getMessage(), e );
-        }
-        catch ( PluginResolutionException e )
-        {
-            throw new LifecycleExecutionException( "Error getting plugin information for
" + plugin.getId() + ": "
-                + e.getMessage(), e );
-        }
-        catch ( PluginDescriptorParsingException e )
-        {
-            throw new LifecycleExecutionException( "Error getting plugin information for
" + plugin.getId() + ": "
-                + e.getMessage(), e );
-        }
-        catch ( MojoNotFoundException e )
-        {
-            throw new LifecycleExecutionException( "Error getting plugin information for
" + plugin.getId() + ": "
-                + e.getMessage(), e );
-        }
-        catch ( InvalidPluginDescriptorException e )
-        {
-            throw new LifecycleExecutionException( "Error getting plugin information for
" + plugin.getId() + ": "
-                + e.getMessage(), e );
-        }
-    }
-
-    public void populateDefaultConfigurationForPlugins( Collection<Plugin> plugins,
RepositoryRequest repositoryRequest ) 
-        throws LifecycleExecutionException
-    {
-        for( Plugin plugin : plugins )
-        {            
-            populateDefaultConfigurationForPlugin( plugin, repositoryRequest );
-        }
     }
 
     public Xpp3Dom getMojoConfiguration( MojoDescriptor mojoDescriptor )

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java?rev=812869&r1=812868&r2=812869&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java
(original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java
Wed Sep  9 10:07:01 2009
@@ -19,11 +19,9 @@
  * under the License.
  */
 
-import java.util.Collection;
 import java.util.List;
 import java.util.Set;
 
-import org.apache.maven.artifact.repository.RepositoryRequest;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.plugin.InvalidPluginDescriptorException;
@@ -80,15 +78,6 @@
      */
     Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging );
 
-    // Given a set of {@link org.apache.maven.Plugin} objects where the GAV is set we can
lookup the plugin
-    // descriptor and populate the default configuration.
-    //
-    void populateDefaultConfigurationForPlugins( Collection<Plugin> plugins, RepositoryRequest
repositoryRequest )
-        throws LifecycleExecutionException;
-
-    void populateDefaultConfigurationForPlugin( Plugin plugin, RepositoryRequest repositoryRequest
)
-        throws LifecycleExecutionException;
-    
     void execute( MavenSession session );
 
     /**

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java?rev=812869&r1=812868&r2=812869&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
(original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
Wed Sep  9 10:07:01 2009
@@ -22,17 +22,12 @@
 
 import org.apache.maven.Maven;
 import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.repository.DefaultRepositoryRequest;
-import org.apache.maven.artifact.repository.RepositoryRequest;
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
 import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
 import org.apache.maven.artifact.resolver.ResolutionErrorHandler;
-import org.apache.maven.lifecycle.LifecycleExecutionException;
-import org.apache.maven.lifecycle.LifecycleExecutor;
 import org.apache.maven.model.Build;
 import org.apache.maven.model.Model;
-import org.apache.maven.model.Plugin;
 import org.apache.maven.model.Profile;
 import org.apache.maven.model.building.DefaultModelBuildingRequest;
 import org.apache.maven.model.building.DefaultModelProblem;
@@ -66,9 +61,6 @@
     private ProjectBuildingHelper projectBuildingHelper;
 
     @Requirement
-    private LifecycleExecutor lifecycle;
-
-    @Requirement
     private RepositorySystem repositorySystem;
 
     @Requirement
@@ -127,33 +119,6 @@
                 project = toProject( result, configuration, listener );
             }
 
-            if ( configuration.isProcessPlugins() && configuration.isProcessPluginConfiguration()
)
-            {
-                RepositoryRequest repositoryRequest = new DefaultRepositoryRequest();
-                repositoryRequest.setLocalRepository( configuration.getLocalRepository()
);
-                repositoryRequest.setRemoteRepositories( project.getPluginArtifactRepositories()
);
-                repositoryRequest.setCache( configuration.getRepositoryCache() );
-                repositoryRequest.setOffline( configuration.isOffline() );
-
-                for ( Plugin plugin : project.getBuildPlugins() )
-                {
-                    try
-                    {
-                        lifecycle.populateDefaultConfigurationForPlugin( plugin, repositoryRequest
);
-                    }
-                    catch ( LifecycleExecutionException e )
-                    {
-                        if ( modelProblems == null )
-                        {
-                            modelProblems = new ArrayList<ModelProblem>();
-                        }
-
-                        modelProblems.add( new DefaultModelProblem( e.getMessage(), ModelProblem.Severity.WARNING,
-                                                                    project.getModel(), e
) );
-                    }
-                }
-            }
-
             ArtifactResolutionResult artifactResult = null;
 
             if ( configuration.isResolveDependencies() )

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java?rev=812869&r1=812868&r2=812869&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java
(original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java
Wed Sep  9 10:07:01 2009
@@ -61,8 +61,6 @@
 
     private boolean processPlugins;
 
-    private boolean processPluginConfiguration;
-
     private List<Profile> profiles;
 
     private List<String> activeProfileIds;
@@ -80,7 +78,6 @@
     public DefaultProjectBuildingRequest()
     {
         processPlugins = true;
-        processPluginConfiguration = true;
         profiles = new ArrayList<Profile>();
         activeProfileIds = new ArrayList<String>();
         inactiveProfileIds = new ArrayList<String>();
@@ -294,17 +291,6 @@
         this.processPlugins = processPlugins;
         return this;
     }
-
-    public boolean isProcessPluginConfiguration()
-    {
-        return processPluginConfiguration;
-    }
-
-    public ProjectBuildingRequest setProcessPluginConfiguration( boolean processPluginConfiguration
)
-    {
-        this.processPluginConfiguration = processPluginConfiguration;
-        return this;
-    }
     
     public ProjectBuildingRequest setResolveDependencies( boolean resolveDependencies )
     {

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java?rev=812869&r1=812868&r2=812869&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java
(original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java
Wed Sep  9 10:07:01 2009
@@ -110,10 +110,6 @@
 
     boolean isProcessPlugins();
 
-    ProjectBuildingRequest setProcessPluginConfiguration( boolean processPluginConfiguration
);
-
-    boolean isProcessPluginConfiguration();
-
     ProjectBuildingRequest setResolveDependencies( boolean resolveDependencies );
 
     boolean isResolveDependencies();



Mime
View raw message