You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by David Jencks <da...@yahoo.com> on 2011/03/21 08:37:03 UTC

How do you get aether to traverse the entire dependency tree?

One of the nice side effects of moving the maven resolution code away from apache is that people who work for companies with IP policies need additional approval to look at the source to find out how it works.  Since I don't have such approval I'm really hoping for some advice.

I've been following the sample code at 
http://aether.sonatype.org/using-aether-in-maven-plugins.html
http://www.sonatype.com/people/2011/01/how-to-use-aether-in-maven-plugins/#more-6838

I am working on a maven plugin that needs to traverse the entire dependency tree starting from a project artifact.  Aether is not finding the whole tree.  Why not?  How do I make it?

To be more specific, aether is finding no children for an artifact that...
-- is only present in my local repo
-- is a custom packaging
-- the artifact for this custom packaging has a classifier
-- the type is not the same as the packaging name

I'll call this artifact A below.

i've made some spot checks for jars that are deployed to apache snapshot repo or central and aether seems to be finding the children for these.

I think the relevant code is:

    /**
     * The entry point to Aether, i.e. the component doing all the work.
     *
     * @component
     */
    private RepositorySystem repoSystem;

    /**
     * The current repository/network configuration of Maven.
     *
     * @parameter default-value="${repositorySystemSession}"
     * @readonly
     */
    private RepositorySystemSession repoSession;

    /**
     * The project's remote repositories to use for the resolution of project dependencies.
     *
     * @parameter default-value="${project.remoteProjectRepositories}"
     * @readonly
     */
    private List<RemoteRepository> projectRepos;


    private DependencyNode getDependencyTree(Artifact artifact) throws MojoExecutionException {
        try {
            List<org.sonatype.aether.graph.Dependency> managedArtifacts = new ArrayList<org.sonatype.aether.graph.Dependency>();
            CollectRequest collectRequest = new CollectRequest(new org.sonatype.aether.graph.Dependency(artifact, "compile"), managedArtifacts, projectRepos);
            CollectResult result = repoSystem.collectDependencies(repoSession, collectRequest);
            return result.getRoot();
        } catch (DependencyCollectionException e) {
            throw new MojoExecutionException("Cannot build project dependency tree", e);
        }
    }

getDependencyTree when called on my project artifact returns a tree where the node for A has no children.  Furthermore calling getDependencyTree on A directly also finds no children.  On the other hand running this plugin on the project for A does find the children of A (the dependencies listed in the pom for A).

changing the dependency on A from

        <dependency>
            <groupId>org.apache.geronimo.features</groupId>
            <artifactId>org.apache.geronimo.jaxb-support</artifactId>
            <type>xml</type>
            <classifier>features</classifier>
            <version>3.99.99-SNAPSHOT</version>
        </dependency>
(xml is the primary artifact file extension)
to

        <dependency>
            <groupId>org.apache.geronimo.features</groupId>
            <artifactId>org.apache.geronimo.jaxb-support</artifactId>
            <type>feature</type>
            <classifier>features</classifier>
            <version>3.99.99-SNAPSHOT</version>
        </dependency>
(feature is the packaging type)
causes a resolution error:

[ERROR] Failed to execute goal on project org.apache.geronimo.transaction.kar: Could not resolve dependencies for project org.apache.geronimo.features:org.apache.geronimo.transaction.kar:kar:3.99.99-SNAPSHOT: Could not find artifact org.apache.geronimo.features:org.apache.geronimo.jaxb-support:feature:features:3.99.99-SNAPSHOT in nexus (http://localhost:8081/nexus/content/groups/public) -> [Help 1]

Any advice?

thanks
david jencks




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: How do you get aether to traverse the entire dependency tree?

Posted by Benjamin Bentmann <be...@udo.edu>.
David Jencks wrote:

> Is there some way to  require minimum plugin versions in a custom packaging or its LifecycleMapping?

No, lifecycle mappings can only provide default plugin versions, the 
versions from the POMs win.


Benjamin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: How do you get aether to traverse the entire dependency tree?

Posted by David Jencks <da...@yahoo.com>.
This ended up being good advice.  The problem was an antique maven-install-plugin specified in a parent pom.

Is there some way to  require minimum plugin versions in a custom packaging or its LifecycleMapping?  

thanks
david jencks

On Mar 21, 2011, at 3:06 AM, Benjamin Bentmann wrote:

> David Jencks wrote:
> 
>> Any advice?
> 
> Provide a standalone example project that allows others to reproduce/analyze the problem.
> 
> 
> Benjamin
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: How do you get aether to traverse the entire dependency tree?

Posted by Brian Fox <br...@infinity.nu>.
On Mon, Mar 21, 2011 at 6:06 AM, Benjamin Bentmann
<be...@udo.edu> wrote:
> David Jencks wrote:
>
>> Any advice?
>
> Provide a standalone example project that allows others to reproduce/analyze
> the problem.

People that can't browse source without approval likely can't post
code with out approval either ;-/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: How do you get aether to traverse the entire dependency tree?

Posted by Benjamin Bentmann <be...@udo.edu>.
David Jencks wrote:

> Any advice?

Provide a standalone example project that allows others to 
reproduce/analyze the problem.


Benjamin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org