maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laird Nelson <ljnel...@gmail.com>
Subject Topologically sorted list of Artifacts for use by a plugin?
Date Fri, 03 Jan 2014 22:03:22 GMT
Hello; in Maven 3.0.5 and 3.1.x, what is the preferred way, given a
MavenProject representing the current pom.xml/project, to obtain a list of
its resolved dependency Artifacts in test scope that has been topologically
sorted such that the Artifact at the head of the list has the fewest
dependencies and the artifact at the tail of the list has the most?

I asked this question many moons ago (
http://maven.40175.n5.nabble.com/Topologically-sorting-dependencies-tp3384898p3387803.html)
and after no answers, came up with what felt like an awful hack to produce
what I wanted, whose code I pasted in that message.

If you follow the link, you'll see that I used the ProjectSorter class,
which is what Maven's reactor uses when processing a multi-module
project--which gives me exactly the order I wanted--but seems like overkill
and like misusing a tool, and maybe isn't the Right Way given all the new
Aether stuff and whatnot.  Nevertheless, it is still how Maven's reactor
works, so...who knows.

Anyway, I started there and "worked backwards"--needed a List of
MavenProjects to feed to it, so ended up using the MavenProjectBuilder, as
you can see in the link.

That class has since been deprecated and moved to the compat layer, though,
and its replacement (another class named DefaultMavenProjectBuilder) has
removed the convenience method that I was using.  I'd like to update my
plugin to avoid depending on this deprecated subsystem.

So then: suppose I'm writing a Maven plugin that needs to fetch a
particular well-known classpath resource from all artifacts available in
test scope, and needs that list to be in topological order (starting with
an artifact that has the fewest dependencies and ending with the artifact
that has the most).  What is the preferred mechanism for doing this these
days?  Is it still by way of the ProjectSorter hammer?  Or is there a more
elegant way to do it?

(As background: I am working with Liquibase (http://www.liquibase.org/).
 Each of my .jar projects has a META-INF/liquibase/changelog.xml file in
it.  Various of these .jar projects already depend on each other--for unit
and integration testing, I'd like to use this dependency order, harvest the
changelog.xml resources in each .jar file, and then combine them to create
only the database tables actually needed for the test.  If a.jar has A's
tables, and b.jar has B's tables and b.jar depends on a.jar, then I'd like
to run a.jar!/META-INF/liquibase/changelog.xml first, then
b.jar!/META-INF/liquibase/changelog.xml next, and I'd like to not have to
specify this in any place in my pom.xmls, since the dependency order is
already captured there.)

Best,
Happy 2014,
Laird

-- 
http://about.me/lairdnelson

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message