You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by flaubert g <fl...@gmail.com> on 2007/05/26 13:13:49 UTC
How to Get Dependencies
Hi,
How do I retrieve all transitive dependencies, which includes
"sub-dependencies" from a maven api?
Thanks.
Cheers,
flaubertg
Re: How to Get Dependencies
Posted by flaubert g <fl...@gmail.com>.
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 <jo...@gmail.com> wrote:
>
> On 5/26/07, flaubert g <fl...@gmail.com> 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
>
Re: How to Get Dependencies
Posted by Jo Vandermeeren <jo...@gmail.com>.
On 5/26/07, flaubert g <fl...@gmail.com> 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
Re: How to Get Dependencies
Posted by flaubert g <fl...@gmail.com>.
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?
Cheers,
flaubertg
On 5/26/07, Jo Vandermeeren <jo...@gmail.com> wrote:
>
> Maven API?
>
> If you are talking about a Maven project, just build it to install all of
> its dependencies in your local repository.
> Maven2 resolves transitive dependencies automatically.
>
> Cheers
> Jo
>
> On 5/26/07, flaubert g <fl...@gmail.com> wrote:
> >
> > Hi,
> >
> > How do I retrieve all transitive dependencies, which includes
> > "sub-dependencies" from a maven api?
> >
> > Thanks.
> >
> > Cheers,
> > flaubertg
> >
>
Re: How to Get Dependencies
Posted by Jo Vandermeeren <jo...@gmail.com>.
Maven API?
If you are talking about a Maven project, just build it to install all of
its dependencies in your local repository.
Maven2 resolves transitive dependencies automatically.
Cheers
Jo
On 5/26/07, flaubert g <fl...@gmail.com> wrote:
>
> Hi,
>
> How do I retrieve all transitive dependencies, which includes
> "sub-dependencies" from a maven api?
>
> Thanks.
>
> Cheers,
> flaubertg
>