mirror of https://github.com/apache/maven.git
PR: MNG-634
add a "useScope" attribute to the dependencies task so that you can determine what dependency set you want git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@239682 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b935ee1b58
commit
22748d4e0d
|
@ -74,6 +74,14 @@
|
||||||
<fileset refid="my.dependency.fileset"/>
|
<fileset refid="my.dependency.fileset"/>
|
||||||
</copy>
|
</copy>
|
||||||
|
|
||||||
|
<artifact:dependencies filesetId="my.compile.dependency.fileset" useScope="compile">
|
||||||
|
<pom refid="maven.project"/>
|
||||||
|
</artifact:dependencies>
|
||||||
|
|
||||||
|
<copy todir="target/my-compile-dependencies">
|
||||||
|
<fileset refid="my.compile.dependency.fileset"/>
|
||||||
|
</copy>
|
||||||
|
|
||||||
<property name="outJar" value="${maven.project.build.directory}/${maven.project.build.finalName}.jar"/>
|
<property name="outJar" value="${maven.project.build.directory}/${maven.project.build.finalName}.jar"/>
|
||||||
|
|
||||||
<artifact:install file="${outJar}">
|
<artifact:install file="${outJar}">
|
||||||
|
|
|
@ -24,6 +24,8 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
||||||
|
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||||
|
import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
|
||||||
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
|
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
|
||||||
import org.apache.maven.model.Dependency;
|
import org.apache.maven.model.Dependency;
|
||||||
import org.apache.maven.model.Repository;
|
import org.apache.maven.model.Repository;
|
||||||
|
@ -38,6 +40,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,6 +60,8 @@ public class DependenciesTask
|
||||||
|
|
||||||
private String filesetId;
|
private String filesetId;
|
||||||
|
|
||||||
|
private String useScope;
|
||||||
|
|
||||||
private boolean verbose;
|
private boolean verbose;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,9 +135,14 @@ public class DependenciesTask
|
||||||
remoteRepositories.add( remoteRepository );
|
remoteRepositories.add( remoteRepository );
|
||||||
|
|
||||||
List remoteArtifactRepositories = createRemoteArtifactRepositories( remoteRepositories );
|
List remoteArtifactRepositories = createRemoteArtifactRepositories( remoteRepositories );
|
||||||
|
|
||||||
// TODO: managed dependencies
|
// TODO: managed dependencies
|
||||||
result = resolver.resolveTransitively( artifacts, pomArtifact, remoteArtifactRepositories, localRepo,
|
Map managedDependencies = Collections.EMPTY_MAP;
|
||||||
metadataSource, listeners );
|
|
||||||
|
ArtifactFilter filter = useScope != null ? new ScopeArtifactFilter( useScope ) : null;
|
||||||
|
|
||||||
|
result = resolver.resolveTransitively( artifacts, pomArtifact, managedDependencies, localRepo,
|
||||||
|
remoteArtifactRepositories, metadataSource, filter, listeners );
|
||||||
}
|
}
|
||||||
catch ( ArtifactResolutionException e )
|
catch ( ArtifactResolutionException e )
|
||||||
{
|
{
|
||||||
|
@ -235,4 +245,9 @@ public class DependenciesTask
|
||||||
{
|
{
|
||||||
this.verbose = verbose;
|
this.verbose = verbose;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUseScope( String useScope )
|
||||||
|
{
|
||||||
|
this.useScope = useScope;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,9 @@ public class DefaultArtifactResolver
|
||||||
|
|
||||||
if ( !artifact.isResolved() )
|
if ( !artifact.isResolved() )
|
||||||
{
|
{
|
||||||
throw new ArtifactResolutionException( "Failed to resolve artifact, possibly due to a repository list that is not appropriately equipped for this artifact's metadata.", artifact, remoteRepositories );
|
throw new ArtifactResolutionException(
|
||||||
|
"Failed to resolve artifact, possibly due to a repository list that is not appropriately equipped for this artifact's metadata.",
|
||||||
|
artifact, remoteRepositories );
|
||||||
}
|
}
|
||||||
|
|
||||||
// must be after the artifact is downloaded
|
// must be after the artifact is downloaded
|
||||||
|
@ -182,7 +184,7 @@ public class DefaultArtifactResolver
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||||
Map managedVersions, ArtifactRepository localRepository,
|
Map managedVersions, ArtifactRepository localRepository,
|
||||||
List remoteRepositories, ArtifactMetadataSource source,
|
List remoteRepositories, ArtifactMetadataSource source,
|
||||||
ArtifactFilter filter, List listeners )
|
ArtifactFilter filter, List listeners )
|
||||||
|
|
|
@ -64,6 +64,11 @@ public interface ArtifactResolver
|
||||||
ArtifactMetadataSource source, ArtifactFilter filter )
|
ArtifactMetadataSource source, ArtifactFilter filter )
|
||||||
throws ArtifactResolutionException;
|
throws ArtifactResolutionException;
|
||||||
|
|
||||||
|
ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions,
|
||||||
|
ArtifactRepository localRepository, List remoteRepositories,
|
||||||
|
ArtifactMetadataSource source, ArtifactFilter filter, List listeners )
|
||||||
|
throws ArtifactResolutionException;
|
||||||
|
|
||||||
void resolveAlways( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
|
void resolveAlways( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
|
||||||
throws ArtifactResolutionException;
|
throws ArtifactResolutionException;
|
||||||
}
|
}
|
Loading…
Reference in New Issue