You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Laird Nelson <lj...@gmail.com> on 2010/08/06 22:12:00 UTC

Best way to get topologically sorted classpath?

I need (ultimately) a list of URLs corresponding to elements in a project's
classpath, where that classpath has been sorted in dependency order.  (I
don't actually care if it's sorted "ascending" or "descending".)

I need this for a mojo that I'm working on that will be run as part of an
ear project's generate-resources phase.

(Running mvn dependency:list or mvn dependency:build-classpath on such a
project gets all the right jar files in there, but not in dependency order.
That is, if the ear project depends on A which depends on B which depends on
C, mvn dependency:list will return C before B.)

I've noticed that Surefire seems to get this exactly right.  If you look at
the classpath when you're running a unit test, you'll notice that all
dependencies are in that classpath and in proper topological order.  But I
can't see an easy way to inherit from or use Surefire simply for this
purpose, nor, frankly, would I want to.

What's the best/sanctioned way to get this information?

Thanks,
Laird

Re: Best way to get topologically sorted classpath?

Posted by Zac Thompson <za...@gmail.com>.
On Fri, Aug 6, 2010 at 1:12 PM, Laird Nelson <lj...@gmail.com> wrote:
> I need (ultimately) a list of URLs corresponding to elements in a project's
> classpath, where that classpath has been sorted in dependency order.  (I
> don't actually care if it's sorted "ascending" or "descending".)
>
> I need this for a mojo that I'm working on that will be run as part of an
> ear project's generate-resources phase.
>
> (Running mvn dependency:list or mvn dependency:build-classpath on such a
> project gets all the right jar files in there, but not in dependency order.
> That is, if the ear project depends on A which depends on B which depends on
> C, mvn dependency:list will return C before B.)

What about dependency:tree?  Obviously the standard output won't work
but perhaps you could find a way to leverage some of the logic.  It
seems to be in the order you want.

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