o more organization in the plugin manager

o there seems to be an incompatible change between surefire 2.4.2 and 2.4.3 with the booter and the useManifestJar option



git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@757120 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2009-03-22 03:04:05 +00:00
parent 66d06cee8a
commit e3212b468c
5 changed files with 35 additions and 62 deletions

View File

@ -140,35 +140,24 @@ public class DefaultPluginManager
@Requirement
protected RepositoryMetadataManager repositoryMetadataManager;
private Map pluginDefinitionsByPrefix = new HashMap();
private Map<String,org.apache.maven.model.Plugin> pluginDefinitionsByPrefix = new HashMap<String,org.apache.maven.model.Plugin>();
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<Artifact>( pluginArtifacts ) );
pluginDescriptor.setClassRealm( pluginRealm );
pluginRealms.put( pluginKey( plugin ), pluginRealm );
@ -842,13 +828,12 @@ public class DefaultPluginManager
return;
}
List parameters = mojoDescriptor.getParameters();
List<Parameter> 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<Parameter> parameters = goal.getParameters();
if ( parameters == null )
{
return;
}
List invalidParameters = new ArrayList();
List<Parameter> invalidParameters = new ArrayList<Parameter>();
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<Parameter> 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();

View File

@ -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<String, PluginDescriptor> pluginDescriptors = new HashMap();

View File

@ -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() );
}
// ----------------------------------------------------------------------

View File

@ -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.
* <br/>
@ -56,9 +55,9 @@ public class MojoDescriptor
private static final String DEFAULT_LANGUAGE = "java";
private List parameters;
private List<Parameter> parameters;
private Map parameterMap;
private Map<String,Parameter> 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<Parameter> 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<Parameter> 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<Parameter>();
}
parameters.add( parameter );
@ -207,18 +205,16 @@ public class MojoDescriptor
/**
* @return the list parameters as a Map
*/
public Map getParameterMap()
public Map<String,Parameter> getParameterMap()
{
if ( parameterMap == null )
{
parameterMap = new HashMap();
parameterMap = new HashMap<String,Parameter>();
if ( parameters != null )
{
for ( Iterator iterator = parameters.iterator(); iterator.hasNext(); )
for ( Parameter pd : parameters )
{
Parameter pd = (Parameter) iterator.next();
parameterMap.put( pd.getName(), pd );
}
}

View File

@ -56,7 +56,7 @@ under the License.
<junitVersion>3.8.1</junitVersion>
<plexusVersion>1.0-beta-3.0.6</plexusVersion>
<plexusInteractivityVersion>1.0-alpha-6</plexusInteractivityVersion>
<plexusInterpolationVersion>1.1</plexusInterpolationVersion>
<plexusInterpolationVersion>1.7</plexusInterpolationVersion>
<plexusPluginManagerVersion>1.0-alpha-1</plexusPluginManagerVersion>
<plexusUtilsVersion>1.5.8</plexusUtilsVersion>
<plexusJetty6Version>1.6</plexusJetty6Version>
@ -219,7 +219,7 @@ under the License.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.2</version>
<version>2.4.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>