You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Dawid Weiss <da...@gmail.com> on 2012/01/20 14:31:52 UTC
How to replace ArtifactResolver with Maven 3 equivalent (RepositorySystem)?
Hi there,
I've been eyeballing various bits and snippets of Maven for a few
hours but I can't see any pattern of right usage for resolving
transitive dependencies of an artifact at runtime (from a plugin). I
would like to require Maven 3, so I'm interested in Maven 3's
infrastructure for basically doing what surefire does in
AbstractSureFireMojo#resolveArtifact -- it uses ArtifactResolver to
look up dependencies of a given Artifact.
Now, I've tried to do the same with RepositorySystem#resolve, but it
fails to locate certain projects (in particular when launched via m2e,
when the projects are not yet installed in a local repository, but
available from their current Workspace locations).
The pattern of use is nearly identical, for ArtifactResolver (which
works for me):
ArtifactResolutionResult resolveTransitively =
resolver.resolveTransitively(
Collections.singleton( artifact ),
originatingArtifact,
session.getLocalRepository(),
project.getPluginArtifactRepositories(), metadataSource,
filter );
the same with RepositorySystem does not work:
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
request.setResolveTransitively(true);
request.setResolutionFilter(filter);
request.setArtifact(originatingArtifact);
request.setArtifactDependencies(Sets.newHashSet(artifact));
request.setLocalRepository(session.getLocalRepository());
request.setRemoteRepositories(project.getPluginArtifactRepositories());
ArtifactResolutionResult result2 = repositorySystem.resolve(request);
I get the exception saying:
java.lang.RuntimeException: Could not resolve:
[gid]:[aid]:jar:0.0.5-SNAPSHOT:compile
What is the "proper" way to lookup arbitrary artifact dependencies
from a plugin so that it can see transitive, reactor dependencies and
everything else?
I would gladly accept a RTFM with a pointer to where I can find
snippets of code that do it (but for Maven 3.x). Thanks,
Dawid
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org