diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java index 910141019d..4636525b96 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java @@ -140,35 +140,24 @@ public class DefaultPluginManager @Requirement protected RepositoryMetadataManager repositoryMetadataManager; - private Map pluginDefinitionsByPrefix = new HashMap(); + private Map pluginDefinitionsByPrefix = new HashMap(); public DefaultPluginManager() { pluginDescriptorBuilder = new PluginDescriptorBuilder(); } - // ---------------------------------------------------------------------- - // - // ---------------------------------------------------------------------- - + // This should be template method code for allowing subclasses to assist in contributing search/hint information public Plugin findPluginForPrefix( String prefix, MavenProject project, MavenSession session ) { - // TODO: since this is only used in the lifecycle executor, maybe it should be moved there? There is no other - // use for the mapping manager in here return getByPrefix( prefix, session.getPluginGroups(), project.getRemoteArtifactRepositories(), session.getLocalRepository() ); } public PluginDescriptor loadPlugin( Plugin plugin, MavenProject project, MavenSession session ) throws PluginLoaderException - { - if ( plugin.getGroupId() == null ) - { - plugin.setGroupId( PluginDescriptor.getDefaultPluginGroupId() ); - } - + { try - { - + { String pluginVersion = plugin.getVersion(); logger.debug( "Resolving plugin: " + plugin.getKey() + " with version: " + pluginVersion ); @@ -183,14 +172,11 @@ public class DefaultPluginManager logger.debug( "Resolved to version: " + pluginVersion ); } - - System.out.println( "XXXXXXXXXXXXXXXXXXXXXXX " + plugin.getArtifactId() + ":" + plugin.getVersion() ); - + addPlugin( plugin, project, session ); PluginDescriptor result = pluginCollector.getPluginDescriptor( plugin ); - - + project.addPlugin( plugin ); return result; @@ -335,7 +321,7 @@ public class DefaultPluginManager pluginDescriptor.setPluginArtifact( pluginArtifact ); // Make sure it's just the plugin artifacts - pluginDescriptor.setArtifacts( new ArrayList( pluginArtifacts ) ); + pluginDescriptor.setArtifacts( new ArrayList( pluginArtifacts ) ); pluginDescriptor.setClassRealm( pluginRealm ); pluginRealms.put( pluginKey( plugin ), pluginRealm ); @@ -842,13 +828,12 @@ public class DefaultPluginManager return; } - List parameters = mojoDescriptor.getParameters(); + List parameters = mojoDescriptor.getParameters(); + if ( ( parameters != null ) && !parameters.isEmpty() ) { - for ( Iterator it = parameters.iterator(); it.hasNext(); ) + for ( Parameter param : parameters ) { - Parameter param = (Parameter) it.next(); - if ( param.getDeprecated() != null ) { boolean warnOfDeprecation = false; @@ -926,14 +911,14 @@ public class DefaultPluginManager { // TODO: this should be built in to the configurator, as we presently double process the expressions - List parameters = goal.getParameters(); + List parameters = goal.getParameters(); if ( parameters == null ) { return; } - List invalidParameters = new ArrayList(); + List invalidParameters = new ArrayList(); for ( int i = 0; i < parameters.size(); i++ ) { @@ -998,7 +983,7 @@ public class DefaultPluginManager private void validatePomConfiguration( MojoDescriptor goal, PlexusConfiguration pomConfiguration ) throws PluginConfigurationException { - List parameters = goal.getParameters(); + List parameters = goal.getParameters(); if ( parameters == null ) { @@ -1050,10 +1035,8 @@ public class DefaultPluginManager { PlexusConfiguration fromMojo = mojoDescriptor.getMojoConfiguration(); - for ( Iterator it = mojoDescriptor.getParameters().iterator(); it.hasNext(); ) + for ( Parameter parameter : mojoDescriptor.getParameters() ) { - Parameter parameter = (Parameter) it.next(); - String paramName = parameter.getName(); String alias = parameter.getAlias(); String implementation = parameter.getImplementation(); diff --git a/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginCollector.java b/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginCollector.java index d5552a14cd..025d998639 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginCollector.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginCollector.java @@ -29,19 +29,13 @@ import java.util.Set; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.descriptor.PluginDescriptor; -import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.discovery.ComponentDiscoveryEvent; import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener; import org.codehaus.plexus.component.repository.ComponentSetDescriptor; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.logging.console.ConsoleLogger; public class MavenPluginCollector implements ComponentDiscoveryListener { - @Requirement - private Logger logger; - private Set pluginsInProcess = new HashSet(); private Map pluginDescriptors = new HashMap(); diff --git a/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java b/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java index 3574105721..131018c2b6 100644 --- a/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java +++ b/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java @@ -233,6 +233,7 @@ public class MavenEmbedderTest assertEquals( "somnambulance", p1.getProperties().getProperty( "occupation" ) ); } + //TODO: This needs to be a separate test and we can't use production plugins for the test. /** * Test that two executions of the embedder don't share data that has changed, see MNG-3013 * @@ -249,12 +250,11 @@ public class MavenEmbedderTest File pom = new File( targetDirectory, "pom.xml" ); - /* Add the surefire plugin 2.2 to the pom */ Model model = mavenEmbedder.readModel( pom ); Plugin plugin = new Plugin(); plugin.setArtifactId( "maven-surefire-plugin" ); - plugin.setVersion( "2.2" ); + plugin.setVersion( "2.4.2" ); model.setBuild( new Build() ); model.getBuild().addPlugin( plugin ); @@ -273,10 +273,10 @@ public class MavenEmbedderTest MavenProject project = result.getProject(); Artifact p = (Artifact) project.getPluginArtifactMap().get( plugin.getKey() ); - assertEquals( "2.2", p.getVersion() ); + assertEquals( "2.4.2", p.getVersion() ); /* Add the surefire plugin 2.3 to the pom */ - plugin.setVersion( "2.3" ); + plugin.setVersion( "2.4.3" ); writer = WriterFactory.newXmlWriter( pom ); mavenEmbedder.writeModel( writer, model ); writer.close(); @@ -291,7 +291,7 @@ public class MavenEmbedderTest project = result.getProject(); p = (Artifact) project.getPluginArtifactMap().get( plugin.getKey() ); - assertEquals( "2.3", p.getVersion() ); + assertEquals( "2.4.3", p.getVersion() ); } // ---------------------------------------------------------------------- diff --git a/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java b/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java index f624d813c7..25e86026e6 100644 --- a/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java +++ b/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java @@ -19,17 +19,16 @@ package org.apache.maven.plugin.descriptor; * under the License. */ +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + import org.apache.maven.plugin.Mojo; import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - /** * The bean containing the Mojo descriptor. *
@@ -56,9 +55,9 @@ public class MojoDescriptor private static final String DEFAULT_LANGUAGE = "java"; - private List parameters; + private List parameters; - private Map parameterMap; + private Map parameterMap; /** By default, the execution strategy is "once-per-session" */ private String executionStrategy = SINGLE_PASS_EXEC_STRATEGY; @@ -163,7 +162,7 @@ public class MojoDescriptor /** * @return the list of parameters */ - public List getParameters() + public List getParameters() { return parameters; } @@ -172,12 +171,11 @@ public class MojoDescriptor * @param parameters the new list of parameters * @throws DuplicateParameterException if any */ - public void setParameters( List parameters ) + public void setParameters( List parameters ) throws DuplicateParameterException { - for ( Iterator it = parameters.iterator(); it.hasNext(); ) + for ( Parameter parameter : parameters ) { - Parameter parameter = (Parameter) it.next(); addParameter( parameter ); } } @@ -198,7 +196,7 @@ public class MojoDescriptor if ( parameters == null ) { - parameters = new LinkedList(); + parameters = new LinkedList(); } parameters.add( parameter ); @@ -207,18 +205,16 @@ public class MojoDescriptor /** * @return the list parameters as a Map */ - public Map getParameterMap() + public Map getParameterMap() { if ( parameterMap == null ) { - parameterMap = new HashMap(); + parameterMap = new HashMap(); if ( parameters != null ) { - for ( Iterator iterator = parameters.iterator(); iterator.hasNext(); ) + for ( Parameter pd : parameters ) { - Parameter pd = (Parameter) iterator.next(); - parameterMap.put( pd.getName(), pd ); } } diff --git a/pom.xml b/pom.xml index 3b77527cce..3d22db8800 100644 --- a/pom.xml +++ b/pom.xml @@ -56,7 +56,7 @@ under the License. 3.8.1 1.0-beta-3.0.6 1.0-alpha-6 - 1.1 + 1.7 1.0-alpha-1 1.5.8 1.6 @@ -219,7 +219,7 @@ under the License. org.apache.maven.plugins maven-surefire-plugin - 2.4.2 + 2.4.3 org.apache.maven.plugins