Am 07.11.2011 18:29, schrieb Jérémy:
> Hi,
>
> I'm trying to sort the dependencies expressed in the pom.xml (including the
> transitive ones) in a topological way.

Sonatype / Eclipse Aether can help with this. I use it myself for
exactly the purpose you describe here to build a post-order depth first
visit sequence of the (transitive) dependency tree. This is then used to
load the dependencies in this order to match requirements of the
underlying technology (JBoss Drools). If you use Aether, you get this
kind of sorting for free (pre-order, post-order depth-first are
supported out of the box). Look out for PostorderNodeListGenerator,
PreorderNodeListGenerator in package org.sonatype.aether.util.graph.

Aether is also used by Maven internally to do dependency resolution and
stuff. It's currently in incubation at eclipse.org and licensed under EPL.

Source code is available on github [1]

Example code can be found
* in maven-drools-plugin [2]
* blog post about using aether in plugins [3]

Best regards

Ansgar

[1] https://github.com/sonatype/sonatype-aether
[2]
https://github.com/maven-drools/plugin.maven-drools-plugin/tree/master/mojos
[3]
http://www.sonatype.com/people/2011/01/how-to-use-aether-in-maven-plugins/
>  I'm using the maven-* API
> 3.0-alpha-2 and it is in the context of a plugin. I tried to use Maven's
> embedded API to do so, but I get a NPE when I
> call getTopologicallySortedProjects().
> Here's a snippet of my Mojo:
>
> MavenExecutionResult dm = new DefaultMavenExecutionResult();
> dm = dm.setProject(getMavenProject()); //Maven project provided by plexus
> List<MavenProject> list = dm.getTopologicallySortedProjects();
>
> Anyone has any experience with that?
>
> Cheers,
> Jérémy
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to