Take a look at the maven-dependency-plugin copy-dependencies code, this is pretty much exactly what you're trying to do. There are filters that are in a common jar you can reuse to filter out transitivity etc.
On Tue, Jul 7, 2009 at 6:21 PM, Samuel Le Berrigaud<samuel.lb.w...@gmail.com> wrote: > Hi Costin, > > I assume you have a project defined in your plugin's mojo, i.e.: > > /** > * The Maven Project > * > * @parameter expression="${project}" > * @required > * @readonly > */ > private MavenProject project; > > > Then getting *all* the dependencies (including the transitive ones) of > your project is as simple as: project.getArtifacts() > > This will return you a list of org.apache.maven.artifact.Artifact. > However they might not be resolve at the phase of the lifecyle your > mojo is bound to. To make sure that dependency resolution has happened > when executing your mojo "annotate" it with > @requiresDependencyResolution (see > http://maven.apache.org/developers/mojo-api-specification.html for > more information). > > If you want only the dependencies as declared in the pom you can use: > project.getDependencyArtifacts() > > Hope this helps, > SaM > > On Wed, Jul 8, 2009 at 2:28 AM, Costin Caraivan<ccarai...@axway.com> wrote: >> >> Hello, >> >> I have a plugin which needs to download & copy somewhere the transitive >> dependencies of the project's dependencies (at least level 1, I'll see about >> the rest). >> So I have this: project -> dependencies -> transitive dependencies. >> I extracted artifacts from the direct dependencies, so this part is ok. >> >> For the rest of the mail, "artifact" is a direct dependency. >> How can I access the transitive dependencies? I tried >> artifact.getDependencyTrail() on the artifact - but this doesn't give me >> what I need (I don't even understand exactly what getDependencyTrail() is >> supposed to return :) ). >> >> Next I tried creating MavenProjects from the artifact: >> DefaultMavenProjectBuilder defaultMavenProjectBuilder = new >> DefaultMavenProjectBuilder(); >> defaultMavenProjectBuilder.initialize(); >> mavenProject = defaultMavenProjectBuilder.buildFromRepository(artifact, >> remoteRepositories, localRepository) >> I was thinking of using getDependencies() on the project, but this gives me >> a nice NPE. How can I use DefaultMavenProjectBuilder? >> >> I also looked around at maven-dependency-plugin & others but I'm having >> problems understanding exactly the parts I need (plus the documentation >> isn't that great...). >> >> Any ideas? >> >> Kind regard, >> Costin. >> -- >> View this message in context: >> http://www.nabble.com/Copy-transitive-dependencies-tp24376786p24376786.html >> Sent from the Maven Developers mailing list archive at Nabble.com. >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org >> For additional commands, e-mail: dev-h...@maven.apache.org >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org > For additional commands, e-mail: dev-h...@maven.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org For additional commands, e-mail: dev-h...@maven.apache.org