mirror of https://github.com/apache/maven.git
use managed versions for project
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@191783 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d30f51a6a6
commit
c3d0ba0846
|
@ -102,6 +102,7 @@ public class DependenciesTask
|
|||
pom.getVersion(), null, pom.getPackaging() );
|
||||
|
||||
List remoteArtifactRepositories = createRemoteArtifactRepositories( getRemoteRepositories() );
|
||||
// TODO: managed dependencies
|
||||
result = resolver.resolveTransitively( artifacts, pomArtifact, remoteArtifactRepositories, localRepo,
|
||||
metadataSource );
|
||||
}
|
||||
|
|
|
@ -31,8 +31,10 @@ import org.codehaus.plexus.logging.AbstractLogEnabled;
|
|||
import org.codehaus.plexus.logging.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class DefaultArtifactResolver
|
||||
|
@ -130,14 +132,35 @@ public class DefaultArtifactResolver
|
|||
}
|
||||
|
||||
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||
List remoteRepositories, ArtifactRepository localRepository,
|
||||
ArtifactRepository localRepository, List remoteRepositories,
|
||||
ArtifactMetadataSource source, ArtifactFilter filter )
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
return resolveTransitively( artifacts, originatingArtifact, Collections.EMPTY_MAP, localRepository,
|
||||
remoteRepositories, source, filter );
|
||||
|
||||
}
|
||||
|
||||
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||
Map managedVersions, ArtifactRepository localRepository,
|
||||
List remoteRepositories, ArtifactMetadataSource source )
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository,
|
||||
remoteRepositories, source, null );
|
||||
}
|
||||
|
||||
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||
Map managedVersions, ArtifactRepository localRepository,
|
||||
List remoteRepositories, ArtifactMetadataSource source,
|
||||
ArtifactFilter filter )
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
ArtifactResolutionResult artifactResolutionResult;
|
||||
|
||||
artifactResolutionResult = artifactCollector.collect( artifacts, originatingArtifact, localRepository,
|
||||
remoteRepositories, source, filter, artifactFactory );
|
||||
artifactResolutionResult = artifactCollector.collect( artifacts, originatingArtifact, managedVersions,
|
||||
localRepository, remoteRepositories, source, filter,
|
||||
artifactFactory );
|
||||
|
||||
for ( Iterator i = artifactResolutionResult.getArtifacts().iterator(); i.hasNext(); )
|
||||
{
|
||||
|
@ -153,7 +176,7 @@ public class DefaultArtifactResolver
|
|||
ArtifactMetadataSource source )
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
return resolveTransitively( artifacts, originatingArtifact, remoteRepositories, localRepository, source, null );
|
||||
return resolveTransitively( artifacts, originatingArtifact, localRepository, remoteRepositories, source, null );
|
||||
}
|
||||
|
||||
}
|
|
@ -22,6 +22,7 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
|
|||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
|
@ -43,8 +44,18 @@ public interface ArtifactResolver
|
|||
ArtifactRepository localRepository, ArtifactMetadataSource source )
|
||||
throws ArtifactResolutionException;
|
||||
|
||||
ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, List remoteRepositories,
|
||||
ArtifactRepository localRepository, ArtifactMetadataSource source,
|
||||
ArtifactFilter filter )
|
||||
ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||
ArtifactRepository localRepository, List remoteRepositories,
|
||||
ArtifactMetadataSource source, ArtifactFilter filter )
|
||||
throws ArtifactResolutionException;
|
||||
|
||||
ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions,
|
||||
ArtifactRepository localRepository, List remoteRepositories,
|
||||
ArtifactMetadataSource source )
|
||||
throws ArtifactResolutionException;
|
||||
|
||||
ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions,
|
||||
ArtifactRepository localRepository, List remoteRepositories,
|
||||
ArtifactMetadataSource source, ArtifactFilter filter )
|
||||
throws ArtifactResolutionException;
|
||||
}
|
|
@ -92,7 +92,12 @@ public class DefaultArtifactCollector
|
|||
Object key = node.getKey();
|
||||
if ( managedVersions.containsKey( key ) )
|
||||
{
|
||||
node.getArtifact().setVersion( (String) managedVersions.get( key ) );
|
||||
Artifact artifact = (Artifact) managedVersions.get( key );
|
||||
// TODO: apply scope. assign whole artifact, except that the missing bits must be filled in
|
||||
if ( artifact.getVersion() != null )
|
||||
{
|
||||
node.getArtifact().setVersion( artifact.getVersion() );
|
||||
}
|
||||
}
|
||||
|
||||
ResolutionNode previous = (ResolutionNode) resolvedArtifacts.get( key );
|
||||
|
|
|
@ -284,8 +284,7 @@ public class DefaultArtifactCollectorTest
|
|||
private ArtifactResolutionResult collect( ArtifactSpec a, Artifact managedVersion )
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
Map managedVersions = Collections.singletonMap( managedVersion.getDependencyConflictId(),
|
||||
managedVersion.getVersion() );
|
||||
Map managedVersions = Collections.singletonMap( managedVersion.getDependencyConflictId(), managedVersion );
|
||||
return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact,
|
||||
managedVersions, null, null, source, null, artifactFactory );
|
||||
}
|
||||
|
|
|
@ -561,8 +561,9 @@ public class DefaultPluginManager
|
|||
remoteArtifactRepositories );
|
||||
|
||||
ArtifactResolutionResult result = artifactResolver.resolveTransitively( dependencies, pluginArtifact,
|
||||
localRepository,
|
||||
remoteArtifactRepositories,
|
||||
localRepository, metadataSource,
|
||||
metadataSource,
|
||||
artifactFilter );
|
||||
|
||||
Set resolved = result.getArtifacts();
|
||||
|
@ -586,7 +587,7 @@ public class DefaultPluginManager
|
|||
ArtifactFilter distroProvidedFilter = new InversionArtifactFilter( artifactFilter );
|
||||
|
||||
ArtifactResolutionResult distroProvidedResult = artifactResolver
|
||||
.resolveTransitively( dependencies, pluginArtifact, remoteArtifactRepositories, localRepository,
|
||||
.resolveTransitively( dependencies, pluginArtifact, localRepository, remoteArtifactRepositories,
|
||||
metadataSource, distroProvidedFilter );
|
||||
|
||||
Set distroProvided = distroProvidedResult.getArtifacts();
|
||||
|
@ -1023,9 +1024,8 @@ public class DefaultPluginManager
|
|||
// TODO: we don't need to resolve over and over again, as long as we are sure that the parameters are the same
|
||||
// check this with yourkit as a hot spot.
|
||||
ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getDependencyArtifacts(),
|
||||
artifact,
|
||||
artifact, context.getLocalRepository(),
|
||||
project.getRemoteArtifactRepositories(),
|
||||
context.getLocalRepository(),
|
||||
sourceReader, filter );
|
||||
|
||||
project.setArtifacts( result.getArtifacts() );
|
||||
|
|
|
@ -25,6 +25,8 @@ import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
|||
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
||||
import org.apache.maven.model.Build;
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.DependencyManagement;
|
||||
import org.apache.maven.model.DistributionManagement;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Parent;
|
||||
|
@ -141,19 +143,35 @@ public class DefaultMavenProjectBuilder
|
|||
// ----------------------------------------------------------------------
|
||||
|
||||
// TODO: such a call in MavenMetadataSource too - packaging not really the intention of type
|
||||
Artifact artifact = artifactFactory.createArtifact( project.getGroupId(), project.getArtifactId(),
|
||||
project.getVersion(), null, project.getPackaging() );
|
||||
Artifact projectArtifact = artifactFactory.createArtifact( project.getGroupId(), project.getArtifactId(),
|
||||
project.getVersion(), null, project.getPackaging() );
|
||||
|
||||
Map managedVersions = createManagedVersionMap( project.getDependencyManagement() );
|
||||
ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getDependencyArtifacts(),
|
||||
artifact,
|
||||
project.getRemoteArtifactRepositories(),
|
||||
projectArtifact, managedVersions,
|
||||
localRepository,
|
||||
project.getRemoteArtifactRepositories(),
|
||||
artifactMetadataSource );
|
||||
|
||||
project.setArtifacts( result.getArtifacts() );
|
||||
return project;
|
||||
}
|
||||
|
||||
private Map createManagedVersionMap( DependencyManagement dependencyManagement )
|
||||
{
|
||||
Map map = new HashMap();
|
||||
for ( Iterator i = dependencyManagement.getDependencies().iterator(); i.hasNext(); )
|
||||
{
|
||||
Dependency d = (Dependency) i.next();
|
||||
|
||||
Artifact artifact = artifactFactory.createArtifact( d.getGroupId(), d.getArtifactId(), d.getVersion(),
|
||||
d.getScope(), d.getType(), null );
|
||||
|
||||
map.put( d.getManagementKey(), artifact );
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public MavenProject build( File projectDescriptor, ArtifactRepository localRepository, List externalProfiles )
|
||||
throws ProjectBuildingException, ArtifactResolutionException
|
||||
{
|
||||
|
|
|
@ -107,11 +107,11 @@ public class ProjectClasspathArtifactResolver
|
|||
}
|
||||
|
||||
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||
List remoteRepositories, ArtifactRepository localRepository,
|
||||
ArtifactRepository localRepository, List remoteRepositories,
|
||||
ArtifactMetadataSource source, ArtifactFilter filter )
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
return super.resolveTransitively( artifacts, originatingArtifact, remoteRepositories, localRepository,
|
||||
return super.resolveTransitively( artifacts, originatingArtifact, localRepository, remoteRepositories,
|
||||
new Source( artifactFactory ), filter );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue