On Jun 19, 2014, at 6:36 PM, William Ferguson <william.fergu...@xandar.com.au> wrote:
> Hi Dan, > > if the ArtifactResolutionResult contains the deps for the Artifact in the > request then that's exactly what I want. However I can't see that it does. > What am I missing? ArtifactResolutionResult.getArtifacts() is a list of all the artifacts that it resolved. > NB the resolution also needs to be able to resolve Artifacts in the > reactor. I'm pretty certain that > > @Component > private org.apache.maven.repository.RepositorySystem repository; > > is only going to resolve from the local repo, not the reactor, right? This I don’t know. I haven’t tried to have it resolve anything in the reactor. Dan > William > > > On Fri, Jun 20, 2014 at 4:58 AM, Daniel Kulp <dk...@apache.org> wrote: > >> >> For Aries, I ended up doing: >> >> >> @Component >> private org.apache.maven.repository.RepositorySystem repository; >> >> private File resolve(String artifactDescriptor) { >> String[] s = artifactDescriptor.split(":"); >> >> String type = (s.length >= 4 ? s[3] : "jar"); >> Artifact artifact = repository.createArtifact(s[0], s[1], s[2], >> type); >> >> ArtifactResolutionRequest request = new >> ArtifactResolutionRequest(); >> request.setArtifact(artifact); >> >> request.setResolveRoot(true).setResolveTransitively(false); >> request.setServers( session.getRequest().getServers() ); >> request.setMirrors( session.getRequest().getMirrors() ); >> request.setProxies( session.getRequest().getProxies() ); >> request.setLocalRepository(session.getLocalRepository()); >> >> request.setRemoteRepositories(session.getRequest().getRemoteRepositories()); >> repository.resolve(request); >> return artifact.getFile(); >> } >> >> If you set “setResolveTransitively(true)” then the >> ArtifactResolutionResponse would have all the deps available in it. >> >> That seems to work for both Maven 3.0 and 3.1/3.2. >> >> Dan >> >> >> Op Thu, 19 Jun 2014 00:01:52 +0200 schreef William Ferguson < >> william.fergu...@xandar.com.au>: >> >>> I asked on maven-users but didn't get any viable responses. So I'm hoping >>> someone here can help. >>> >>> -------------------------- >>> I have a Mojo that needs to work with Maven 3.0.* and 3.1+ >>> >>> In the Mojo I have an Artifact and I need to resolve it's dependencies. >> How >>> can/should I do it? >>> >>> If I can resolve the Artifact to a MavenProject then I can use >>> DependencyGraphBuilder (from maven-dependency-tree) to construct a graph >> of >>> the deps. But I'm struggling to make the Artifact to MavenProject >>> conversion happen. >>> >>> I thought that If I could get a URL to the Artifact's POM file then I >> could >>> use DefaultMavenRuntime (maven-runtime) to resolve the URL into a >>> MavenProject. But >>> >>> 1. I can't work out how to get a URL to the artifact's POM file (it >>> needs to handle both reactor artifacts and repo artifacts) >>> 2. Even with a URL to the POM file, MavenRuntime#getProject) is >>> returning null. >>> >>> Can someone please point me in the right direction? >>> Am I even on the right path or is there a much more straight forward way >> of >>> getting the dependencies for the Artifact? >>> -------------------------- >>> >>> William >> >> >> -- >> Daniel Kulp >> dk...@apache.org - http://dankulp.com/blog >> Talend Community Coder - http://coders.talend.com >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org >> For additional commands, e-mail: dev-h...@maven.apache.org >> >> -- Daniel Kulp dk...@apache.org - http://dankulp.com/blog Talend Community Coder - http://coders.talend.com --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org For additional commands, e-mail: dev-h...@maven.apache.org