mirror of https://github.com/apache/maven.git
o use the artifact resolution request/result method to remove another couple methods from the repository system
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@747658 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
54da5ce53e
commit
4aea96aeb2
|
@ -85,7 +85,8 @@ public class ArtifactResolutionResult
|
|||
{
|
||||
artifacts = new LinkedHashSet<Artifact>();
|
||||
|
||||
for (ResolutionNode node : resolutionNodes) {
|
||||
for (ResolutionNode node : resolutionNodes)
|
||||
{
|
||||
artifacts.add(node.getArtifact());
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +96,8 @@ public class ArtifactResolutionResult
|
|||
|
||||
public Set<ResolutionNode> getArtifactResolutionNodes()
|
||||
{
|
||||
if (resolutionNodes == null) {
|
||||
if ( resolutionNodes == null)
|
||||
{
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ import org.apache.maven.artifact.metadata.ResolutionGroup;
|
|||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
||||
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.MultipleArtifactsNotFoundException;
|
||||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||
|
@ -450,16 +451,22 @@ public class DefaultPluginManager
|
|||
|
||||
repositories.addAll( project.getRemoteArtifactRepositories() );
|
||||
|
||||
ArtifactResolutionResult result = repositoryTools.resolveTransitively(
|
||||
dependencies,
|
||||
pluginArtifact,
|
||||
pluginManagedDependencies,
|
||||
localRepository,
|
||||
repositories.isEmpty()
|
||||
? Collections.EMPTY_LIST
|
||||
: new ArrayList( repositories ),
|
||||
filter );
|
||||
ArtifactResolutionRequest request = new ArtifactResolutionRequest()
|
||||
.setArtifact( pluginArtifact )
|
||||
.setArtifactDependencies( dependencies )
|
||||
.setLocalRepository( localRepository )
|
||||
.setRemoteRepostories( repositories.isEmpty() ? Collections.EMPTY_LIST : new ArrayList( repositories ) )
|
||||
.setManagedVersionMap( pluginManagedDependencies )
|
||||
.setFilter( filter )
|
||||
.setMetadataSource( repositoryTools );
|
||||
|
||||
ArtifactResolutionResult result = repositoryTools.resolve( request );
|
||||
|
||||
if ( result.hasErrorArtifactExceptions() )
|
||||
{
|
||||
throw result.getErrorArtifactExceptions().get( 0 );
|
||||
}
|
||||
|
||||
Set<Artifact> resolved = new LinkedHashSet<Artifact>();
|
||||
|
||||
for ( Iterator<Artifact> it = result.getArtifacts().iterator(); it.hasNext(); )
|
||||
|
@ -1471,7 +1478,7 @@ public class DefaultPluginManager
|
|||
// ----------------------------------------------------------------------
|
||||
|
||||
protected void resolveTransitiveDependencies( MavenSession context,
|
||||
MavenRepositorySystem repositoryTools,
|
||||
MavenRepositorySystem repositorySystem,
|
||||
String scope,
|
||||
MavenProject project,
|
||||
boolean isAggregator )
|
||||
|
@ -1479,7 +1486,7 @@ public class DefaultPluginManager
|
|||
InvalidDependencyVersionException
|
||||
{
|
||||
// TODO: such a call in MavenMetadataSource too - packaging not really the intention of type
|
||||
Artifact artifact = repositoryTools.createBuildArtifact( project.getGroupId(),
|
||||
Artifact artifact = repositorySystem.createBuildArtifact( project.getGroupId(),
|
||||
project.getArtifactId(),
|
||||
project.getVersion(),
|
||||
project.getPackaging() );
|
||||
|
@ -1490,43 +1497,45 @@ public class DefaultPluginManager
|
|||
if ( project.getDependencyArtifacts() == null )
|
||||
{
|
||||
// NOTE: Don't worry about covering this case with the error-reporter bindings...it's already handled by the project error reporter.
|
||||
project.setDependencyArtifacts( repositoryTools.createArtifacts( project.getDependencies(), null, null, project ) );
|
||||
project.setDependencyArtifacts( repositorySystem.createArtifacts( project.getDependencies(), null, null, project ) );
|
||||
}
|
||||
|
||||
ArtifactFilter filter = new ScopeArtifactFilter( scope );
|
||||
|
||||
ArtifactResolutionRequest request = new ArtifactResolutionRequest()
|
||||
.setArtifact( project.getArtifact() )
|
||||
.setArtifactDependencies( project.getDependencyArtifacts() )
|
||||
.setLocalRepository( context.getLocalRepository() )
|
||||
.setRemoteRepostories( project.getRemoteArtifactRepositories() )
|
||||
.setManagedVersionMap( project.getManagedVersionMap() )
|
||||
.setFilter( filter )
|
||||
.setMetadataSource( repositorySystem );
|
||||
|
||||
Set resolvedArtifacts;
|
||||
try
|
||||
{
|
||||
ArtifactResolutionResult result = repositoryTools.resolveTransitively(
|
||||
project.getDependencyArtifacts(),
|
||||
artifact,
|
||||
project.getManagedVersionMap(),
|
||||
context.getLocalRepository(),
|
||||
project.getRemoteArtifactRepositories(),
|
||||
filter );
|
||||
|
||||
ArtifactResolutionResult result = repositorySystem.resolve( request );
|
||||
|
||||
resolvedArtifacts = result.getArtifacts();
|
||||
}
|
||||
catch( MultipleArtifactsNotFoundException e )
|
||||
if ( result.hasErrorArtifactExceptions() )
|
||||
{
|
||||
/*only do this if we are an aggregating plugin: MNG-2277
|
||||
/*
|
||||
|
||||
only do this if we are an aggregating plugin: MNG-2277
|
||||
if the dependency doesn't yet exist but is in the reactor, then
|
||||
all we can do is warn and skip it. A better fix can be inserted into 2.1*/
|
||||
if ( isAggregator
|
||||
&& checkMissingArtifactsInReactor( context.getSortedProjects(),
|
||||
e.getMissingArtifacts() ) )
|
||||
all we can do is warn and skip it. A better fix can be inserted into 2.1
|
||||
|
||||
*/
|
||||
if ( isAggregator && checkMissingArtifactsInReactor( context.getSortedProjects(), result.getMissingArtifacts() ) )
|
||||
{
|
||||
resolvedArtifacts = new LinkedHashSet( e.getResolvedArtifacts() );
|
||||
resolvedArtifacts = new LinkedHashSet( result.getArtifacts() );
|
||||
}
|
||||
else
|
||||
{
|
||||
//we can't find all the artifacts in the reactor so bubble the exception up.
|
||||
throw e;
|
||||
throw result.getErrorArtifactExceptions().get( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
project.setArtifacts( resolvedArtifacts );
|
||||
|
||||
project.setArtifacts( result.getArtifacts() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1542,8 +1551,7 @@ public class DefaultPluginManager
|
|||
* @param missing the artifacts that can't be found
|
||||
* @return true if ALL missing artifacts are found in the reactor.
|
||||
*/
|
||||
private boolean checkMissingArtifactsInReactor( Collection projects,
|
||||
Collection missing )
|
||||
private boolean checkMissingArtifactsInReactor( Collection projects, Collection missing )
|
||||
{
|
||||
Collection foundInReactor = new HashSet();
|
||||
Iterator iter = missing.iterator();
|
||||
|
@ -1582,7 +1590,7 @@ public class DefaultPluginManager
|
|||
|
||||
private void downloadDependencies( MavenProject project,
|
||||
MavenSession context,
|
||||
MavenRepositorySystem repositoryTools )
|
||||
MavenRepositorySystem repositorySystem )
|
||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||
{
|
||||
ArtifactRepository localRepository = context.getLocalRepository();
|
||||
|
@ -1592,7 +1600,7 @@ public class DefaultPluginManager
|
|||
{
|
||||
Artifact artifact = (Artifact) it.next();
|
||||
|
||||
repositoryTools.resolve( artifact, localRepository, remoteArtifactRepositories );
|
||||
repositorySystem.resolve( artifact, localRepository, remoteArtifactRepositories );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -457,42 +457,6 @@ public class MavenEmbedder
|
|||
return result;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Artifacts
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
public Artifact createArtifact( String groupId,
|
||||
String artifactId,
|
||||
String version,
|
||||
String scope,
|
||||
String type )
|
||||
{
|
||||
return repositoryTools.createArtifact( groupId, artifactId, version, scope, type );
|
||||
}
|
||||
|
||||
public Artifact createArtifactWithClassifier( String groupId,
|
||||
String artifactId,
|
||||
String version,
|
||||
String type,
|
||||
String classifier )
|
||||
{
|
||||
return repositoryTools.createArtifactWithClassifier( groupId, artifactId, version, type, classifier );
|
||||
}
|
||||
|
||||
public void resolve( Artifact artifact,
|
||||
List remoteRepositories,
|
||||
ArtifactRepository localRepository )
|
||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||
{
|
||||
repositoryTools.resolve( artifact, localRepository, remoteRepositories );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Plugins
|
||||
// ----------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------
|
||||
// Execution of phases/goals
|
||||
// ----------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------
|
||||
// Lifecycle information
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
|
@ -86,7 +86,7 @@ public class DefaultMavenExecutionRequestPopulator
|
|||
private MavenSettingsBuilder settingsBuilder;
|
||||
|
||||
@Requirement
|
||||
private MavenRepositorySystem mavenTools;
|
||||
private MavenRepositorySystem repositorySystem;
|
||||
|
||||
// 2009-02-12 Oleg: this component is defined in maven-core components.xml
|
||||
// because it already has another declared (not generated) component
|
||||
|
@ -217,7 +217,7 @@ public class DefaultMavenExecutionRequestPopulator
|
|||
ArtifactRepository ar;
|
||||
try
|
||||
{
|
||||
ar = mavenTools.buildArtifactRepository( r );
|
||||
ar = repositorySystem.buildArtifactRepository( r );
|
||||
}
|
||||
catch ( InvalidRepositoryException e )
|
||||
{
|
||||
|
@ -354,12 +354,12 @@ public class DefaultMavenExecutionRequestPopulator
|
|||
{
|
||||
if ( request.isUpdateSnapshots() )
|
||||
{
|
||||
mavenTools.setGlobalUpdatePolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS );
|
||||
repositorySystem.setGlobalUpdatePolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS );
|
||||
}
|
||||
else if ( request.isNoSnapshotUpdates() )
|
||||
{
|
||||
getLogger().info( "+ Supressing SNAPSHOT updates." );
|
||||
mavenTools.setGlobalUpdatePolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_NEVER );
|
||||
repositorySystem.setGlobalUpdatePolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_NEVER );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -371,7 +371,7 @@ public class DefaultMavenExecutionRequestPopulator
|
|||
private void checksumPolicy( MavenExecutionRequest request,
|
||||
Configuration configuration )
|
||||
{
|
||||
mavenTools.setGlobalChecksumPolicy( request.getGlobalChecksumPolicy() );
|
||||
repositorySystem.setGlobalChecksumPolicy( request.getGlobalChecksumPolicy() );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -387,17 +387,17 @@ public class DefaultMavenExecutionRequestPopulator
|
|||
|
||||
if ( request.isOffline() )
|
||||
{
|
||||
mavenTools.setOnline( false );
|
||||
repositorySystem.setOnline( false );
|
||||
}
|
||||
else if ( ( request.getSettings() != null ) && request.getSettings().isOffline() )
|
||||
{
|
||||
mavenTools.setOnline( false );
|
||||
repositorySystem.setOnline( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
mavenTools.setDownloadMonitor( request.getTransferListener() );
|
||||
repositorySystem.setDownloadMonitor( request.getTransferListener() );
|
||||
|
||||
mavenTools.setOnline( true );
|
||||
repositorySystem.setOnline( true );
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -422,7 +422,7 @@ public class DefaultMavenExecutionRequestPopulator
|
|||
throw new SettingsConfigurationException( "Proxy in settings.xml has no host" );
|
||||
}
|
||||
|
||||
mavenTools.addProxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), proxy.getUsername(), proxy.getPassword(), proxy.getNonProxyHosts() );
|
||||
repositorySystem.addProxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), proxy.getUsername(), proxy.getPassword(), proxy.getNonProxyHosts() );
|
||||
}
|
||||
|
||||
for ( Iterator i = settings.getServers().iterator(); i.hasNext(); )
|
||||
|
@ -441,9 +441,9 @@ public class DefaultMavenExecutionRequestPopulator
|
|||
throw new SettingsConfigurationException( "Error decrypting server password/passphrase.", e );
|
||||
}
|
||||
|
||||
mavenTools.addAuthenticationInfo( server.getId(), server.getUsername(), pass, server.getPrivateKey(), phrase );
|
||||
repositorySystem.addAuthenticationInfo( server.getId(), server.getUsername(), pass, server.getPrivateKey(), phrase );
|
||||
|
||||
mavenTools.addPermissionInfo( server.getId(), server.getFilePermissions(), server.getDirectoryPermissions() );
|
||||
repositorySystem.addPermissionInfo( server.getId(), server.getFilePermissions(), server.getDirectoryPermissions() );
|
||||
}
|
||||
|
||||
RepositoryPermissions defaultPermissions = new RepositoryPermissions();
|
||||
|
@ -452,7 +452,7 @@ public class DefaultMavenExecutionRequestPopulator
|
|||
{
|
||||
Mirror mirror = (Mirror) i.next();
|
||||
|
||||
mavenTools.addMirror( mirror.getId(), mirror.getMirrorOf(), mirror.getUrl() );
|
||||
repositorySystem.addMirror( mirror.getId(), mirror.getMirrorOf(), mirror.getUrl() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -516,7 +516,7 @@ public class DefaultMavenExecutionRequestPopulator
|
|||
|
||||
try
|
||||
{
|
||||
return mavenTools.createLocalRepository( localRepositoryPath, MavenEmbedder.DEFAULT_LOCAL_REPO_ID );
|
||||
return repositorySystem.createLocalRepository( localRepositoryPath, MavenEmbedder.DEFAULT_LOCAL_REPO_ID );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
|
|
|
@ -1,22 +1,18 @@
|
|||
package org.apache.maven.repository;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
|
||||
* agreements. See the NOTICE file distributed with this work for additional information regarding
|
||||
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
|
@ -65,7 +61,6 @@ import org.apache.maven.wagon.proxy.ProxyInfo;
|
|||
import org.apache.maven.wagon.repository.RepositoryPermissions;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.codehaus.plexus.logging.LogEnabled;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
|
@ -74,63 +69,63 @@ import org.codehaus.plexus.util.StringUtils;
|
|||
*/
|
||||
@Component(role = MavenRepositorySystem.class)
|
||||
public class LegacyMavenRepositorySystem
|
||||
implements MavenRepositorySystem, LogEnabled
|
||||
implements MavenRepositorySystem
|
||||
{
|
||||
@Requirement
|
||||
private ArtifactFactory artifactFactory;
|
||||
|
||||
@Requirement
|
||||
private ArtifactResolver artifactResolver;
|
||||
|
||||
|
||||
@Requirement
|
||||
private ArtifactRepositoryFactory artifactRepositoryFactory;
|
||||
|
||||
@Requirement
|
||||
private ArtifactRepositoryLayout defaultArtifactRepositoryLayout;
|
||||
|
||||
|
||||
@Requirement
|
||||
private WagonManager wagonManager;
|
||||
|
||||
|
||||
@Requirement
|
||||
private ArtifactMetadataSource artifactMetadataSource;
|
||||
|
||||
|
||||
@Requirement
|
||||
private Logger logger;
|
||||
|
||||
|
||||
private static HashMap<String, Artifact> cache = new HashMap<String, Artifact>();
|
||||
|
||||
|
||||
// Artifact Creation
|
||||
|
||||
public Artifact createArtifact(String groupId, String artifactId, String version, String scope, String type)
|
||||
|
||||
public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type )
|
||||
{
|
||||
return artifactFactory.createArtifact(groupId, artifactId, version, scope, type);
|
||||
return artifactFactory.createArtifact( groupId, artifactId, version, scope, type );
|
||||
}
|
||||
|
||||
public Artifact createArtifactWithClassifier(String groupId, String artifactId, String version, String type, String classifier)
|
||||
public Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String type, String classifier )
|
||||
{
|
||||
return artifactFactory.createArtifactWithClassifier(groupId, artifactId, version, type, classifier);
|
||||
return artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, classifier );
|
||||
}
|
||||
|
||||
public Artifact createBuildArtifact(String groupId, String artifactId, String version, String packaging )
|
||||
|
||||
public Artifact createBuildArtifact( String groupId, String artifactId, String version, String packaging )
|
||||
{
|
||||
return artifactFactory.createBuildArtifact(groupId, artifactId, version, packaging );
|
||||
return artifactFactory.createBuildArtifact( groupId, artifactId, version, packaging );
|
||||
}
|
||||
|
||||
|
||||
public Artifact createProjectArtifact( String groupId, String artifactId, String metaVersionId )
|
||||
{
|
||||
return artifactFactory.createProjectArtifact(groupId, artifactId, metaVersionId );
|
||||
return artifactFactory.createProjectArtifact( groupId, artifactId, metaVersionId );
|
||||
}
|
||||
|
||||
public Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, boolean optional )
|
||||
{
|
||||
return artifactFactory.createDependencyArtifact( groupId, artifactId, versionRange, type, classifier, scope );
|
||||
return artifactFactory.createDependencyArtifact( groupId, artifactId, versionRange, type, classifier, scope );
|
||||
}
|
||||
|
||||
public Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, String inheritedScope )
|
||||
{
|
||||
return artifactFactory.createDependencyArtifact( groupId, artifactId, versionRange, type, classifier, scope, inheritedScope );
|
||||
return artifactFactory.createDependencyArtifact( groupId, artifactId, versionRange, type, classifier, scope, inheritedScope );
|
||||
}
|
||||
|
||||
|
||||
public Artifact createExtensionArtifact( String groupId, String artifactId, VersionRange versionRange )
|
||||
{
|
||||
return artifactFactory.createExtensionArtifact( groupId, artifactId, versionRange );
|
||||
|
@ -140,44 +135,32 @@ public class LegacyMavenRepositorySystem
|
|||
{
|
||||
return artifactFactory.createParentArtifact( groupId, artifactId, version );
|
||||
}
|
||||
|
||||
|
||||
public Artifact createPluginArtifact( String groupId, String artifactId, VersionRange versionRange )
|
||||
{
|
||||
return artifactFactory.createPluginArtifact( groupId, artifactId, versionRange );
|
||||
}
|
||||
|
||||
|
||||
public Set<Artifact> createArtifacts( List<Dependency> dependencies, String inheritedScope, ArtifactFilter dependencyFilter, MavenProject project )
|
||||
throws InvalidDependencyVersionException
|
||||
{
|
||||
return MavenMetadataSource.createArtifacts( artifactFactory, dependencies, inheritedScope, dependencyFilter, project );
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
|
||||
public List<ArtifactVersion> retrieveAvailableVersions(Artifact artifact,
|
||||
ArtifactRepository localRepository,
|
||||
List<ArtifactRepository> remoteRepositories)
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
return artifactMetadataSource.retrieveAvailableVersions(artifact, localRepository, remoteRepositories);
|
||||
}
|
||||
|
||||
|
||||
public List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
return artifactMetadataSource.retrieveAvailableVersions( artifact, localRepository, remoteRepositories );
|
||||
}
|
||||
|
||||
public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
return artifactMetadataSource.retrieve(artifact, localRepository, remoteRepositories);
|
||||
return artifactMetadataSource.retrieve( artifact, localRepository, remoteRepositories );
|
||||
}
|
||||
|
||||
public ArtifactResolutionResult resolveTransitively(
|
||||
Set<Artifact> artifacts, Artifact originatingArtifact,
|
||||
Map managedVersions, ArtifactRepository localRepository,
|
||||
List<ArtifactRepository> remoteRepositories,
|
||||
ArtifactFilter filter )
|
||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||
{
|
||||
return artifactResolver.resolveTransitively(artifacts, originatingArtifact, remoteRepositories, localRepository, artifactMetadataSource );
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Code snagged from ProjectUtils: this will have to be moved somewhere else
|
||||
// but just trying to collect it all in one place right now.
|
||||
|
@ -188,7 +171,7 @@ public class LegacyMavenRepositorySystem
|
|||
{
|
||||
List<ArtifactRepository> repos = new ArrayList<ArtifactRepository>();
|
||||
|
||||
for( Repository mavenRepo : repositories )
|
||||
for ( Repository mavenRepo : repositories )
|
||||
{
|
||||
ArtifactRepository artifactRepo = buildArtifactRepository( mavenRepo );
|
||||
|
||||
|
@ -197,7 +180,7 @@ public class LegacyMavenRepositorySystem
|
|||
repos.add( artifactRepo );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return repos;
|
||||
}
|
||||
|
||||
|
@ -214,7 +197,7 @@ public class LegacyMavenRepositorySystem
|
|||
throw new InvalidRepositoryException( "Repository ID must not be empty (URL is: " + url + ").", url );
|
||||
}
|
||||
|
||||
if ( url == null || url.trim().length() < 1 )
|
||||
if ( url == null || url.trim().length() < 1 )
|
||||
{
|
||||
throw new InvalidRepositoryException( "Repository URL must not be empty (ID is: " + id + ").", id );
|
||||
}
|
||||
|
@ -255,7 +238,7 @@ public class LegacyMavenRepositorySystem
|
|||
|
||||
return new ArtifactRepositoryPolicy( enabled, updatePolicy, checksumPolicy );
|
||||
}
|
||||
|
||||
|
||||
// From MavenExecutionRequestPopulator
|
||||
|
||||
public ArtifactRepository createLocalRepository( String url, String repositoryId )
|
||||
|
@ -310,13 +293,10 @@ public class LegacyMavenRepositorySystem
|
|||
|
||||
return artifactRepositoryFactory.createArtifactRepository( repositoryId, url, defaultArtifactRepositoryLayout, snapshotsPolicy, releasesPolicy );
|
||||
}
|
||||
|
||||
public ArtifactRepository createRepository( String url,
|
||||
String repositoryId,
|
||||
ArtifactRepositoryPolicy snapshotsPolicy,
|
||||
ArtifactRepositoryPolicy releasesPolicy )
|
||||
|
||||
public ArtifactRepository createRepository( String url, String repositoryId, ArtifactRepositoryPolicy snapshotsPolicy, ArtifactRepositoryPolicy releasesPolicy )
|
||||
{
|
||||
return artifactRepositoryFactory.createArtifactRepository( repositoryId, url, defaultArtifactRepositoryLayout, snapshotsPolicy, releasesPolicy );
|
||||
return artifactRepositoryFactory.createArtifactRepository( repositoryId, url, defaultArtifactRepositoryLayout, snapshotsPolicy, releasesPolicy );
|
||||
}
|
||||
|
||||
public void setGlobalUpdatePolicy( String policy )
|
||||
|
@ -326,11 +306,11 @@ public class LegacyMavenRepositorySystem
|
|||
|
||||
public void setGlobalChecksumPolicy( String policy )
|
||||
{
|
||||
artifactRepositoryFactory.setGlobalChecksumPolicy( policy );
|
||||
artifactRepositoryFactory.setGlobalChecksumPolicy( policy );
|
||||
}
|
||||
|
||||
|
||||
// Taken from RepositoryHelper
|
||||
|
||||
|
||||
public void findModelFromRepository( Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
|
@ -353,7 +333,7 @@ public class LegacyMavenRepositorySystem
|
|||
else
|
||||
{
|
||||
logger.debug( "Attempting to build MavenProject instance for Artifact (" + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion() + ") of type: "
|
||||
+ artifact.getType() + "; constructing POM artifact instead." );
|
||||
+ artifact.getType() + "; constructing POM artifact instead." );
|
||||
|
||||
projectArtifact = artifactFactory.createProjectArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getScope() );
|
||||
}
|
||||
|
@ -440,52 +420,48 @@ public class LegacyMavenRepositorySystem
|
|||
return ArtifactUtils.versionlessKey( gid, aid );
|
||||
}
|
||||
|
||||
public void enableLogging( Logger logger )
|
||||
{
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the specified artifact
|
||||
*
|
||||
*
|
||||
* @param artifact the artifact to resolve
|
||||
* @throws IOException if there is a problem resolving the artifact
|
||||
*/
|
||||
public void resolve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||
{
|
||||
/* FIXME: Not sure what this was meant to do here but right now it screws up several ITs
|
||||
File artifactFile = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
|
||||
artifact.setFile( artifactFile );
|
||||
//*/
|
||||
artifactResolver.resolve( artifact, remoteRepositories, localRepository );
|
||||
}
|
||||
|
||||
public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
|
||||
{
|
||||
return artifactResolver.resolve( request );
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Extracted from DefaultWagonManager
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
|
||||
private static final String WILDCARD = "*";
|
||||
|
||||
private static final String EXTERNAL_WILDCARD = "external:*";
|
||||
|
||||
|
||||
private static int anonymousMirrorIdSeed = 0;
|
||||
|
||||
private boolean online = true;
|
||||
|
||||
private boolean interactive = true;
|
||||
|
||||
|
||||
private TransferListener downloadMonitor;
|
||||
|
||||
private Map<String,ProxyInfo> proxies = new HashMap<String,ProxyInfo>();
|
||||
|
||||
private Map<String,AuthenticationInfo> authenticationInfoMap = new HashMap<String,AuthenticationInfo>();
|
||||
|
||||
private Map<String,RepositoryPermissions> serverPermissionsMap = new HashMap<String,RepositoryPermissions>();
|
||||
|
||||
|
||||
private Map<String, ProxyInfo> proxies = new HashMap<String, ProxyInfo>();
|
||||
|
||||
private Map<String, AuthenticationInfo> authenticationInfoMap = new HashMap<String, AuthenticationInfo>();
|
||||
|
||||
private Map<String, RepositoryPermissions> serverPermissionsMap = new HashMap<String, RepositoryPermissions>();
|
||||
|
||||
//used LinkedMap to preserve the order.
|
||||
private Map<String,ArtifactRepository> mirrors = new LinkedHashMap<String,ArtifactRepository>();
|
||||
|
||||
private Map<String, ArtifactRepository> mirrors = new LinkedHashMap<String, ArtifactRepository>();
|
||||
|
||||
public ArtifactRepository getMirrorRepository( ArtifactRepository repository )
|
||||
{
|
||||
ArtifactRepository mirror = getMirror( repository );
|
||||
|
@ -499,17 +475,16 @@ public class LegacyMavenRepositorySystem
|
|||
}
|
||||
|
||||
logger.debug( "Using mirror: " + mirror.getId() + " for repository: " + repository.getId() + "\n(mirror url: " + mirror.getUrl() + ")" );
|
||||
repository = artifactRepositoryFactory.createArtifactRepository( id, mirror.getUrl(),
|
||||
repository.getLayout(), repository.getSnapshots(),
|
||||
repository.getReleases() );
|
||||
repository = artifactRepositoryFactory.createArtifactRepository( id, mirror.getUrl(), repository.getLayout(), repository.getSnapshots(), repository.getReleases() );
|
||||
}
|
||||
return repository;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method finds a matching mirror for the selected repository. If there is an exact match, this will be used.
|
||||
* If there is no exact match, then the list of mirrors is examined to see if a pattern applies.
|
||||
*
|
||||
* This method finds a matching mirror for the selected repository. If there is an exact match,
|
||||
* this will be used. If there is no exact match, then the list of mirrors is examined to see if
|
||||
* a pattern applies.
|
||||
*
|
||||
* @param originalRepository See if there is a mirror for this repository.
|
||||
* @return the selected mirror or null if none are found.
|
||||
*/
|
||||
|
@ -536,13 +511,10 @@ public class LegacyMavenRepositorySystem
|
|||
}
|
||||
|
||||
/**
|
||||
* This method checks if the pattern matches the originalRepository.
|
||||
* Valid patterns:
|
||||
* * = everything
|
||||
* external:* = everything not on the localhost and not file based.
|
||||
* repo,repo1 = repo or repo1
|
||||
* *,!repo1 = everything except repo1
|
||||
*
|
||||
* This method checks if the pattern matches the originalRepository. Valid patterns: * =
|
||||
* everything external:* = everything not on the localhost and not file based. repo,repo1 = repo
|
||||
* or repo1 *,!repo1 = everything except repo1
|
||||
*
|
||||
* @param originalRepository to compare for a match.
|
||||
* @param pattern used for match. Currently only '*' is supported.
|
||||
* @return true if the repository is a match to this pattern.
|
||||
|
@ -561,36 +533,43 @@ public class LegacyMavenRepositorySystem
|
|||
{
|
||||
// process the list
|
||||
String[] repos = pattern.split( "," );
|
||||
for (String repo : repos) {
|
||||
for ( String repo : repos )
|
||||
{
|
||||
// see if this is a negative match
|
||||
if (repo.length() > 1 && repo.startsWith("!")) {
|
||||
if (originalId.equals(repo.substring(1))) {
|
||||
if ( repo.length() > 1 && repo.startsWith( "!" ) )
|
||||
{
|
||||
if ( originalId.equals( repo.substring( 1 ) ) )
|
||||
{
|
||||
// explicitly exclude. Set result and stop processing.
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// check for exact match
|
||||
else if (originalId.equals(repo)) {
|
||||
else if ( originalId.equals( repo ) )
|
||||
{
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
// check for external:*
|
||||
else if (EXTERNAL_WILDCARD.equals(repo) && isExternalRepo(originalRepository)) {
|
||||
else if ( EXTERNAL_WILDCARD.equals( repo ) && isExternalRepo( originalRepository ) )
|
||||
{
|
||||
result = true;
|
||||
// don't stop processing in case a future segment explicitly excludes this repo
|
||||
} else if (WILDCARD.equals(repo)) {
|
||||
}
|
||||
else if ( WILDCARD.equals( repo ) )
|
||||
{
|
||||
result = true;
|
||||
// don't stop processing in case a future segment explicitly excludes this repo
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the URL to see if this repository refers to an external repository
|
||||
*
|
||||
*
|
||||
* @param originalRepository
|
||||
* @return true if external.
|
||||
*/
|
||||
|
@ -599,15 +578,15 @@ public class LegacyMavenRepositorySystem
|
|||
try
|
||||
{
|
||||
URL url = new URL( originalRepository.getUrl() );
|
||||
return !( url.getHost().equals( "localhost" ) || url.getHost().equals( "127.0.0.1" ) || url.getProtocol().equals("file" ) );
|
||||
return !( url.getHost().equals( "localhost" ) || url.getHost().equals( "127.0.0.1" ) || url.getProtocol().equals( "file" ) );
|
||||
}
|
||||
catch ( MalformedURLException e )
|
||||
{
|
||||
// bad url just skip it here. It should have been validated already, but the wagon lookup will deal with it
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void addMirror( String id, String mirrorOf, String url )
|
||||
{
|
||||
if ( id == null )
|
||||
|
@ -615,12 +594,12 @@ public class LegacyMavenRepositorySystem
|
|||
id = "mirror-" + anonymousMirrorIdSeed++;
|
||||
logger.warn( "You are using a mirror that doesn't declare an <id/> element. Using \'" + id + "\' instead:\nId: " + id + "\nmirrorOf: " + mirrorOf + "\nurl: " + url + "\n" );
|
||||
}
|
||||
|
||||
|
||||
ArtifactRepository mirror = new DefaultArtifactRepository( id, url, null );
|
||||
|
||||
mirrors.put( mirrorOf, mirror );
|
||||
}
|
||||
|
||||
|
||||
public void setOnline( boolean online )
|
||||
{
|
||||
this.online = online;
|
||||
|
@ -635,12 +614,12 @@ public class LegacyMavenRepositorySystem
|
|||
{
|
||||
this.interactive = interactive;
|
||||
}
|
||||
|
||||
|
||||
public void setDownloadMonitor( TransferListener downloadMonitor )
|
||||
{
|
||||
this.downloadMonitor = downloadMonitor;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void addProxy( String protocol, String host, int port, String username, String password, String nonProxyHosts )
|
||||
{
|
||||
ProxyInfo proxyInfo = new ProxyInfo();
|
||||
|
@ -663,8 +642,8 @@ public class LegacyMavenRepositorySystem
|
|||
authInfo.setPassphrase( passphrase );
|
||||
|
||||
authenticationInfoMap.put( repositoryId, authInfo );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void addPermissionInfo( String repositoryId, String filePermissions, String directoryPermissions )
|
||||
{
|
||||
RepositoryPermissions permissions = new RepositoryPermissions();
|
||||
|
@ -689,14 +668,9 @@ public class LegacyMavenRepositorySystem
|
|||
}
|
||||
}
|
||||
|
||||
public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
|
||||
{
|
||||
return artifactResolver.resolve( request );
|
||||
}
|
||||
|
||||
// These two methods are here so that the ArtifactMetadataSource is implemented so that I can pass this into an ArtifactResolutionRequest.
|
||||
// Intermediate measure before separating the RepositorySystem out into its own module.
|
||||
|
||||
|
||||
public List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact, ArtifactRepository localRepository, ArtifactRepository remoteRepository )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
|
@ -707,10 +681,10 @@ public class LegacyMavenRepositorySystem
|
|||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
return artifactMetadataSource.retrieveRelocatedArtifact( artifact, localRepository, remoteRepositories );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Test for this stuff
|
||||
|
||||
|
||||
/*
|
||||
|
||||
public void testAddMirrorWithNullRepositoryId()
|
||||
|
|
|
@ -98,13 +98,10 @@ public interface MavenRepositorySystem
|
|||
|
||||
ArtifactResolutionResult resolve( ArtifactResolutionRequest request );
|
||||
|
||||
// This can be reduced to the request/result
|
||||
void resolve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws ArtifactResolutionException, ArtifactNotFoundException;
|
||||
|
||||
ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository,
|
||||
List<ArtifactRepository> remoteRepositories, ArtifactFilter filter )
|
||||
throws ArtifactResolutionException, ArtifactNotFoundException;
|
||||
|
||||
void findModelFromRepository( Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
|
|
Loading…
Reference in New Issue