mirror of https://github.com/apache/maven.git
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:
parent
b7960dce75
commit
ba9624676d
|
@ -121,6 +121,48 @@ public class DefaultMavenExecutionRequest
|
||||||
|
|
||||||
private MavenRealmManager realmManager;
|
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()
|
public String getBaseDirectory()
|
||||||
{
|
{
|
||||||
if ( basedir == null )
|
if ( basedir == null )
|
||||||
|
|
|
@ -492,7 +492,7 @@ public class DefaultPluginManager
|
||||||
// followed by the plugin's default artifact set
|
// followed by the plugin's default artifact set
|
||||||
dependencies.addAll( resolutionGroup.getArtifacts() );
|
dependencies.addAll( resolutionGroup.getArtifacts() );
|
||||||
|
|
||||||
List repositories = new ArrayList();
|
LinkedHashSet repositories = new LinkedHashSet();
|
||||||
|
|
||||||
repositories.addAll( resolutionGroup.getResolutionRepositories() );
|
repositories.addAll( resolutionGroup.getResolutionRepositories() );
|
||||||
|
|
||||||
|
@ -503,7 +503,10 @@ public class DefaultPluginManager
|
||||||
pluginArtifact,
|
pluginArtifact,
|
||||||
Collections.EMPTY_MAP,
|
Collections.EMPTY_MAP,
|
||||||
localRepository,
|
localRepository,
|
||||||
repositories,
|
repositories.isEmpty()
|
||||||
|
? Collections.EMPTY_LIST
|
||||||
|
: new ArrayList(
|
||||||
|
repositories ),
|
||||||
artifactMetadataSource,
|
artifactMetadataSource,
|
||||||
coreArtifactFilterManager.getArtifactFilter() );
|
coreArtifactFilterManager.getArtifactFilter() );
|
||||||
|
|
||||||
|
|
|
@ -19,11 +19,15 @@ package org.apache.maven.plugin;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.ArtifactUtils;
|
||||||
import org.apache.maven.model.Plugin;
|
import org.apache.maven.model.Plugin;
|
||||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||||
import org.codehaus.plexus.component.discovery.ComponentDiscoveryEvent;
|
import org.codehaus.plexus.component.discovery.ComponentDiscoveryEvent;
|
||||||
import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener;
|
import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener;
|
||||||
import org.codehaus.plexus.component.repository.ComponentSetDescriptor;
|
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.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -32,7 +36,7 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class MavenPluginCollector
|
public class MavenPluginCollector
|
||||||
implements ComponentDiscoveryListener
|
implements ComponentDiscoveryListener, LogEnabled
|
||||||
{
|
{
|
||||||
private Set pluginsInProcess = new HashSet();
|
private Set pluginsInProcess = new HashSet();
|
||||||
|
|
||||||
|
@ -40,6 +44,8 @@ public class MavenPluginCollector
|
||||||
|
|
||||||
private Map pluginIdsByPrefix = new HashMap();
|
private Map pluginIdsByPrefix = new HashMap();
|
||||||
|
|
||||||
|
private Logger logger;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Mojo discovery
|
// Mojo discovery
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@ -75,12 +81,14 @@ public class MavenPluginCollector
|
||||||
|
|
||||||
private String constructPluginKey( Plugin plugin )
|
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 )
|
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 )
|
public boolean isPluginInstalled( Plugin plugin )
|
||||||
|
@ -104,4 +112,19 @@ public class MavenPluginCollector
|
||||||
return result;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,15 +92,18 @@ public class DefaultPluginLoader
|
||||||
Map projectPluginMap = project.getBuild().getPluginsAsMap();
|
Map projectPluginMap = project.getBuild().getPluginsAsMap();
|
||||||
|
|
||||||
PluginDescriptor pluginDescriptor = null;
|
PluginDescriptor pluginDescriptor = null;
|
||||||
for ( Iterator it = descriptors.iterator(); it.hasNext(); )
|
if ( descriptors != null )
|
||||||
{
|
{
|
||||||
PluginDescriptor pd = (PluginDescriptor) it.next();
|
for ( Iterator it = descriptors.iterator(); it.hasNext(); )
|
||||||
|
|
||||||
Plugin projectPlugin = (Plugin) projectPluginMap.get( pd.getPluginLookupKey() );
|
|
||||||
if ( ( projectPlugin != null ) && ( projectPlugin.getVersion() != null ) && projectPlugin.getVersion().equals( pd.getVersion() ) )
|
|
||||||
{
|
{
|
||||||
pluginDescriptor = pd;
|
PluginDescriptor pd = (PluginDescriptor) it.next();
|
||||||
break;
|
|
||||||
|
Plugin projectPlugin = (Plugin) projectPluginMap.get( pd.getPluginLookupKey() );
|
||||||
|
if ( ( projectPlugin != null ) && ( projectPlugin.getVersion() != null ) && projectPlugin.getVersion().equals( pd.getVersion() ) )
|
||||||
|
{
|
||||||
|
pluginDescriptor = pd;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -179,6 +179,8 @@ public class DefaultPluginVersionManager
|
||||||
String metaVersionId )
|
String metaVersionId )
|
||||||
throws PluginVersionResolutionException, InvalidPluginException
|
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 );
|
Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, metaVersionId );
|
||||||
|
|
||||||
String key = artifact.getDependencyConflictId();
|
String key = artifact.getDependencyConflictId();
|
||||||
|
|
|
@ -181,6 +181,11 @@ public class MavenEmbedder
|
||||||
start( embedderConfiguration );
|
start( embedderConfiguration );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MavenExecutionRequest getDefaultRequest()
|
||||||
|
{
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Accessors
|
// Accessors
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue