Cleanup use of repositories for resolving plugin dependencies by using a LinkedHashSet to avoid duplicated repository defs (although two defs pointing to the same URL but with different id's will still look like two repos).

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@615004 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2008-01-24 21:29:12 +00:00
parent b7960dce75
commit ba9624676d
6 changed files with 90 additions and 12 deletions

View File

@ -121,6 +121,48 @@ public class DefaultMavenExecutionRequest
private MavenRealmManager realmManager;
public DefaultMavenExecutionRequest()
{
// default constructor.
}
public DefaultMavenExecutionRequest( MavenExecutionRequest original )
{
localRepository = original.getLocalRepository();
localRepositoryPath = original.getLocalRepositoryPath();
offline = original.isOffline();
interactiveMode = original.isInteractiveMode();
proxies = original.getProxies();
servers = original.getServers();
mirrors = original.getMirrors();
profiles = original.getProfiles();
pluginGroups = original.getPluginGroups();
usePluginUpdateOverride = original.isUsePluginUpdateOverride();
isProjectPresent = original.isProjectPresent();
userSettingsFile = original.getUserSettingsFile();
globalSettingsFile = original.getGlobalSettingsFile();
basedir = new File( original.getBaseDirectory() );
goals = original.getGoals();
useReactor = original.useReactor();
recursive = original.isRecursive();
pom = original.getPom();
reactorFailureBehavior = original.getReactorFailureBehavior();
properties = original.getProperties();
startTime = original.getStartTime();
showErrors = original.isShowErrors();
eventMonitors = original.getEventMonitors();
activeProfiles = original.getActiveProfiles();
inactiveProfiles = original.getInactiveProfiles();
transferListener = original.getTransferListener();
loggingLevel = original.getLoggingLevel();
globalChecksumPolicy = original.getGlobalChecksumPolicy();
updateSnapshots = original.isUpdateSnapshots();
profileManager = original.getProfileManager();
remoteRepositories = original.getRemoteRepositories();
noSnapshotUpdates = original.isNoSnapshotUpdates();
realmManager = original.getRealmManager();
}
public String getBaseDirectory()
{
if ( basedir == null )

View File

@ -492,7 +492,7 @@ public class DefaultPluginManager
// followed by the plugin's default artifact set
dependencies.addAll( resolutionGroup.getArtifacts() );
List repositories = new ArrayList();
LinkedHashSet repositories = new LinkedHashSet();
repositories.addAll( resolutionGroup.getResolutionRepositories() );
@ -503,7 +503,10 @@ public class DefaultPluginManager
pluginArtifact,
Collections.EMPTY_MAP,
localRepository,
repositories,
repositories.isEmpty()
? Collections.EMPTY_LIST
: new ArrayList(
repositories ),
artifactMetadataSource,
coreArtifactFilterManager.getArtifactFilter() );

View File

@ -19,11 +19,15 @@ package org.apache.maven.plugin;
* under the License.
*/
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
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.LogEnabled;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.logging.console.ConsoleLogger;
import java.util.HashMap;
import java.util.HashSet;
@ -32,7 +36,7 @@ import java.util.Map;
import java.util.Set;
public class MavenPluginCollector
implements ComponentDiscoveryListener
implements ComponentDiscoveryListener, LogEnabled
{
private Set pluginsInProcess = new HashSet();
@ -40,6 +44,8 @@ public class MavenPluginCollector
private Map pluginIdsByPrefix = new HashMap();
private Logger logger;
// ----------------------------------------------------------------------
// Mojo discovery
// ----------------------------------------------------------------------
@ -75,12 +81,14 @@ public class MavenPluginCollector
private String constructPluginKey( Plugin plugin )
{
return plugin.getGroupId() + ":" + plugin.getArtifactId() + ":" + plugin.getVersion();
String version = ArtifactUtils.toSnapshotVersion( plugin.getVersion() );
return plugin.getGroupId() + ":" + plugin.getArtifactId() + ":" + version;
}
private String constructPluginKey( PluginDescriptor pluginDescriptor )
{
return pluginDescriptor.getGroupId() + ":" + pluginDescriptor.getArtifactId() + ":" + pluginDescriptor.getVersion();
String version = ArtifactUtils.toSnapshotVersion( pluginDescriptor.getVersion() );
return pluginDescriptor.getGroupId() + ":" + pluginDescriptor.getArtifactId() + ":" + version;
}
public boolean isPluginInstalled( Plugin plugin )
@ -104,4 +112,19 @@ public class MavenPluginCollector
return result;
}
protected Logger getLogger()
{
if ( logger == null )
{
logger = new ConsoleLogger( Logger.LEVEL_INFO, "internal" );
}
return logger;
}
public void enableLogging( Logger logger )
{
this.logger = logger;
}
}

View File

@ -92,6 +92,8 @@ public class DefaultPluginLoader
Map projectPluginMap = project.getBuild().getPluginsAsMap();
PluginDescriptor pluginDescriptor = null;
if ( descriptors != null )
{
for ( Iterator it = descriptors.iterator(); it.hasNext(); )
{
PluginDescriptor pd = (PluginDescriptor) it.next();
@ -103,6 +105,7 @@ public class DefaultPluginLoader
break;
}
}
}
if ( pluginDescriptor == null )
{

View File

@ -179,6 +179,8 @@ public class DefaultPluginVersionManager
String metaVersionId )
throws PluginVersionResolutionException, InvalidPluginException
{
getLogger().info( "Attempting to resolve a version for plugin: " + groupId + ":" + artifactId + " using meta-version: " + metaVersionId );
Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, metaVersionId );
String key = artifact.getDependencyConflictId();

View File

@ -181,6 +181,11 @@ public class MavenEmbedder
start( embedderConfiguration );
}
public MavenExecutionRequest getDefaultRequest()
{
return request;
}
// ----------------------------------------------------------------------
// Accessors
// ----------------------------------------------------------------------