mirror of https://github.com/apache/maven.git
o Fixed legacy artifact creation by metadata source
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@807836 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3dd5ffbcaf
commit
e8f81a7d36
|
@ -223,30 +223,40 @@ public class MavenMetadataSource
|
||||||
private Artifact createDependencyArtifact( Dependency dependency, Artifact owner, Artifact pom )
|
private Artifact createDependencyArtifact( Dependency dependency, Artifact owner, Artifact pom )
|
||||||
throws ArtifactMetadataRetrievalException
|
throws ArtifactMetadataRetrievalException
|
||||||
{
|
{
|
||||||
String effectiveScope = getEffectiveScope( dependency.getScope(), ( owner != null ) ? owner.getScope() : null );
|
|
||||||
|
|
||||||
if ( effectiveScope == null )
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
VersionRange versionRange;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
versionRange = VersionRange.createFromVersionSpec( dependency.getVersion() );
|
String inheritedScope = ( owner != null ) ? owner.getScope() : null;
|
||||||
|
|
||||||
|
ArtifactFilter inheritedFilter = ( owner != null ) ? owner.getDependencyFilter() : null;
|
||||||
|
|
||||||
|
return createDependencyArtifact( repositorySystem, dependency, inheritedScope, inheritedFilter );
|
||||||
}
|
}
|
||||||
catch ( InvalidVersionSpecificationException e )
|
catch ( InvalidVersionSpecificationException e )
|
||||||
{
|
{
|
||||||
throw new ArtifactMetadataRetrievalException( "Invalid version for dependency "
|
throw new ArtifactMetadataRetrievalException( "Invalid version for dependency "
|
||||||
+ dependency.getManagementKey() + ": " + e.getMessage(), e, pom );
|
+ dependency.getManagementKey() + ": " + e.getMessage(), e, pom );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Artifact createDependencyArtifact( ArtifactFactory factory, Dependency dependency, String inheritedScope,
|
||||||
|
ArtifactFilter inheritedFilter )
|
||||||
|
throws InvalidVersionSpecificationException
|
||||||
|
{
|
||||||
|
String effectiveScope = getEffectiveScope( dependency.getScope(), inheritedScope );
|
||||||
|
|
||||||
|
if ( effectiveScope == null )
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
VersionRange versionRange = VersionRange.createFromVersionSpec( dependency.getVersion() );
|
||||||
|
|
||||||
Artifact dependencyArtifact =
|
Artifact dependencyArtifact =
|
||||||
repositorySystem.createDependencyArtifact( dependency.getGroupId(), dependency.getArtifactId(),
|
factory.createDependencyArtifact( dependency.getGroupId(), dependency.getArtifactId(), versionRange,
|
||||||
versionRange, dependency.getType(), dependency.getClassifier(),
|
dependency.getType(), dependency.getClassifier(), effectiveScope,
|
||||||
effectiveScope, dependency.isOptional() );
|
dependency.isOptional() );
|
||||||
|
|
||||||
ArtifactFilter dependencyFilter = ( owner != null ) ? owner.getDependencyFilter() : null;
|
ArtifactFilter dependencyFilter = inheritedFilter;
|
||||||
|
|
||||||
if ( dependencyFilter != null && !dependencyFilter.include( dependencyArtifact ) )
|
if ( dependencyFilter != null && !dependencyFilter.include( dependencyArtifact ) )
|
||||||
{
|
{
|
||||||
|
@ -263,7 +273,7 @@ public class MavenMetadataSource
|
||||||
return dependencyArtifact;
|
return dependencyArtifact;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getEffectiveScope( String originalScope, String inheritedScope )
|
private static String getEffectiveScope( String originalScope, String inheritedScope )
|
||||||
{
|
{
|
||||||
String effectiveScope = Artifact.SCOPE_RUNTIME;
|
String effectiveScope = Artifact.SCOPE_RUNTIME;
|
||||||
|
|
||||||
|
@ -304,7 +314,7 @@ public class MavenMetadataSource
|
||||||
return effectiveScope;
|
return effectiveScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArtifactFilter createDependencyFilter( Dependency dependency, ArtifactFilter inheritedFilter )
|
private static ArtifactFilter createDependencyFilter( Dependency dependency, ArtifactFilter inheritedFilter )
|
||||||
{
|
{
|
||||||
ArtifactFilter effectiveFilter = inheritedFilter;
|
ArtifactFilter effectiveFilter = inheritedFilter;
|
||||||
|
|
||||||
|
@ -398,19 +408,22 @@ public class MavenMetadataSource
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static Set<Artifact> createArtifacts( ArtifactFactory artifactFactory, List<Dependency> dependencies, String inheritedScope, ArtifactFilter dependencyFilter, MavenProject project )
|
public static Set<Artifact> createArtifacts( ArtifactFactory artifactFactory, List<Dependency> dependencies, String inheritedScope, ArtifactFilter dependencyFilter, MavenProject project )
|
||||||
throws InvalidDependencyVersionException
|
throws InvalidDependencyVersionException
|
||||||
{
|
|
||||||
return createArtifacts( artifactFactory, dependencies, dependencyFilter );
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Set<Artifact> createArtifacts( ArtifactFactory factory, List<Dependency> dependencies, ArtifactFilter filter )
|
|
||||||
{
|
{
|
||||||
Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
|
Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
|
||||||
|
|
||||||
for ( Dependency d : dependencies )
|
for ( Dependency d : dependencies )
|
||||||
{
|
{
|
||||||
Artifact dependencyArtifact = factory.createArtifact( d.getGroupId(), d.getArtifactId(), d.getVersion(), d.getScope(), d.getType() );
|
Artifact dependencyArtifact;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
dependencyArtifact = createDependencyArtifact( artifactFactory, d, inheritedScope, dependencyFilter );
|
||||||
|
}
|
||||||
|
catch ( InvalidVersionSpecificationException e )
|
||||||
|
{
|
||||||
|
throw new InvalidDependencyVersionException( project.getId(), d, project.getFile(), e );
|
||||||
|
}
|
||||||
|
|
||||||
if ( filter.include( dependencyArtifact ) )
|
if ( dependencyArtifact != null )
|
||||||
{
|
{
|
||||||
artifacts.add( dependencyArtifact );
|
artifacts.add( dependencyArtifact );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue