Yes, I think this is what I'm looking for. I've modified a bit from that
article. The only thing is that the dependencies I get are somehow
associated from "test" and "compile" phase. I need runtime dependencies only
and I can't seem to find how to do this.

// code snippet
           List listeners = new ArrayList();

           Set dependencyArtifacts = mavenProject.getDependencyArtifacts();
           ArtifactResolutionResult result =
               artifactResolver.resolveTransitively(dependencyArtifacts,
               mavenProject.getArtifact(), Collections.EMPTY_LIST,
               localRepository, metadataSource);
           Set artifacts = result.getArtifacts();
           for (Iterator iter = artifacts.iterator(); iter.hasNext();) {
               Artifact artifact = (Artifact)iter.next();
               getLog().info("  " + artifact.getArtifactId() + "-" +
                   artifact.getVersion() + "." + artifact.getType() +
                   " " + artifact.getScope());
           }

// result in console
junit-3.8.1.jar test
avalon-framework-4.1.3.jar compile
commons-logging-1.1.jar compile
servlet-api-2.3.jar compile
bcel-5.1.jar compile

Am I missing something?

Cheers,
flaubertg




On 5/27/07, Jo Vandermeeren <[EMAIL PROTECTED]> wrote:

On 5/26/07, flaubert g <[EMAIL PROTECTED]> wrote:
>
> Hi Jo,
>
> Thanks for replying.
>
> I'm writing a simple mojo plugin. I want to retrieve all project
> dependencies and "subdependencies" and display this list on my console.
I
> used:
>
> @parameter expression="${project.dependencies}"
> List dependencies;
>
> which gives me a collection of "org.apache.maven.model.Dependency"
> objects.
> I can't find any getter methods to retrieve subdependencies. Should I
use
> some artifact resolver?


Indeed, you need use the ArtifactResolver to resolve them transitively..
You might find this recent article on Jan Bartel's blog interesting:
http://blogs.webtide.com/janb/2006/03/24/1143234000000.html

Reply via email to