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:
Brett Leslie Porter 2005-08-24 15:06:54 +00:00
parent b935ee1b58
commit 22748d4e0d
4 changed files with 40 additions and 10 deletions

View File

@ -74,6 +74,14 @@
<fileset refid="my.dependency.fileset"/>
</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"/>
<artifact:install file="${outJar}">

View File

@ -24,6 +24,8 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
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.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Repository;
@ -38,6 +40,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
@ -57,6 +60,8 @@ public class DependenciesTask
private String filesetId;
private String useScope;
private boolean verbose;
/**
@ -130,9 +135,14 @@ public class DependenciesTask
remoteRepositories.add( remoteRepository );
List remoteArtifactRepositories = createRemoteArtifactRepositories( remoteRepositories );
// TODO: managed dependencies
result = resolver.resolveTransitively( artifacts, pomArtifact, remoteArtifactRepositories, localRepo,
metadataSource, listeners );
// TODO: managed dependencies
Map managedDependencies = Collections.EMPTY_MAP;
ArtifactFilter filter = useScope != null ? new ScopeArtifactFilter( useScope ) : null;
result = resolver.resolveTransitively( artifacts, pomArtifact, managedDependencies, localRepo,
remoteArtifactRepositories, metadataSource, filter, listeners );
}
catch ( ArtifactResolutionException e )
{
@ -235,4 +245,9 @@ public class DependenciesTask
{
this.verbose = verbose;
}
public void setUseScope( String useScope )
{
this.useScope = useScope;
}
}

View File

@ -46,7 +46,7 @@ public class DefaultArtifactResolver
// ----------------------------------------------------------------------
private WagonManager wagonManager;
private ArtifactTransformationManager transformationManager;
protected ArtifactFactory artifactFactory;
@ -109,10 +109,12 @@ public class DefaultArtifactResolver
{
wagonManager.getArtifact( artifact, remoteRepositories );
}
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
@ -182,10 +184,10 @@ public class DefaultArtifactResolver
}
private ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
Map managedVersions, ArtifactRepository localRepository,
List remoteRepositories, ArtifactMetadataSource source,
ArtifactFilter filter, List listeners )
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
Map managedVersions, ArtifactRepository localRepository,
List remoteRepositories, ArtifactMetadataSource source,
ArtifactFilter filter, List listeners )
throws ArtifactResolutionException
{
ArtifactResolutionResult artifactResolutionResult;

View File

@ -64,6 +64,11 @@ public interface ArtifactResolver
ArtifactMetadataSource source, ArtifactFilter filter )
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 )
throws ArtifactResolutionException;
}