Return-Path: X-Original-To: apmail-maven-users-archive@www.apache.org Delivered-To: apmail-maven-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DBEF810A13 for ; Sun, 5 Jan 2014 23:25:24 +0000 (UTC) Received: (qmail 66086 invoked by uid 500); 5 Jan 2014 23:25:22 -0000 Delivered-To: apmail-maven-users-archive@maven.apache.org Received: (qmail 66003 invoked by uid 500); 5 Jan 2014 23:25:22 -0000 Mailing-List: contact users-help@maven.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Maven Users List" Reply-To: "Maven Users List" Delivered-To: mailing list users@maven.apache.org Received: (qmail 65995 invoked by uid 99); 5 Jan 2014 23:25:22 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Jan 2014 23:25:22 +0000 X-ASF-Spam-Status: No, hits=3.2 required=5.0 tests=FREEMAIL_REPLY,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of mgainty@hotmail.com designates 65.55.116.17 as permitted sender) Received: from [65.55.116.17] (HELO blu0-omc1-s6.blu0.hotmail.com) (65.55.116.17) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Jan 2014 23:25:17 +0000 Received: from BLU172-W37 ([65.55.116.9]) by blu0-omc1-s6.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Sun, 5 Jan 2014 15:24:57 -0800 X-TMN: [UMbpE0C8iyyqAueF4uWYAtqQdZe1Lcac] X-Originating-Email: [mgainty@hotmail.com] Message-ID: Content-Type: multipart/alternative; boundary="_f79d300f-c3e0-4eae-8a18-17c6a14c29fd_" From: Martin Gainty To: "users@maven.apache.org" Subject: RE: Topologically sorted list of Artifacts for use by a plugin? Date: Sun, 5 Jan 2014 18:24:56 -0500 Importance: Normal In-Reply-To: References: ,, MIME-Version: 1.0 X-OriginalArrivalTime: 05 Jan 2014 23:24:57.0120 (UTC) FILETIME=[58997A00:01CF0A6D] X-Virus-Checked: Checked by ClamAV on apache.org --_f79d300f-c3e0-4eae-8a18-17c6a14c29fd_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable > Date: Sat=2C 4 Jan 2014 16:11:02 -0800 > Subject: Re: Topologically sorted list of Artifacts for use by a plugin? > From: ljnelson@gmail.com > To: users@maven.apache.org >=20 > On Fri=2C Jan 3=2C 2014 at 6:17 PM=2C Martin Gainty = wrote: >=20 > > MG>so I would say you are definitely on the right track > > >=20 > Thanks=3B I'm not sure I am. >=20 >=20 > > MG>any reason for topological sorting of dependencies? > > >=20 > In my original post=2C I wrote: >=20 > (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 un= it > > and integration testing=2C I'd like to use this dependency order=2C har= vest the > > changelog.xml resources in each .jar file=2C and then combine them to c= reate > > only the database tables actually needed for the test. If a.jar has A's > > tables=2C and b.jar has B's tables and b.jar depends on a.jar=2C then I= 'd like > > to run a.jar!/META-INF/liquibase/changelog.xml first=2C then > > b.jar!/META-INF/liquibase/changelog.xml next=2C and I'd like to not hav= e to > > specify this in any place in my pom.xmls=2C since the dependency order = is > > already captured there.) >=20 >=20 > So the fact that I'm using > ProjectSorterstrikes > me as wrong=97worse than wrong: an awful hack=2C in fact=97because I am > basically using the reactor to sort MavenProjects that I've roped in from > elsewhere. Yucko. >=20 > Various people have noted tersely that the maven-dependency-plugin is wha= t > I want. Of course=2C its *goals* are completely useless for this task MG_01_05>I went the same tack but I couldnt find a goal to collect all the = dependencies so I deprecated that thought process =20 >=97but > buried in an obscure StackOverflow comment tangentially related to the > maven-dependency-plugin I found a reference to this class: > http://maven.apache.org/shared/maven-dependency-tree/apidocs/index.html?o= rg/apache/maven/shared/dependency/graph/DependencyGraphBuilder.html > If I understand it right=2C then code like the following should do the > trick > (untested=2C but you get the general idea): >=20 > public class Artifacts { >=20 > private final DependencyGraphBuilder dependencyGraphBuilder=3B >=20 > public Artifacts(final DependencyGraphBuilder dependencyGraphBuilder) { > super()=3B > this.dependencyGraphBuilder =3D dependencyGraphBuilder=3B > } >=20 > public Collection > getDependencyArtifactsInTopologicalOrder(final MavenProject project) thro= ws > DependencyGraphBuilderException { > List returnValue =3D null=3B > final DependencyNode projectNode =3D > this.dependencyGraphBuilder.buildDependencyGraph(project=2C null /* no > ArtifactFilter=3B prob. need one */)=3B > assert projectNode !=3D null=3B > final CollectingDependencyNodeVisitor visitor =3D new > CollectingDependencyNodeVisitor()=3B > projectNode.accept(visitor)=3B > final Collection nodes =3D visitor.getNodes()= =3B > if (nodes !=3D null && !nodes.isEmpty()) { > returnValue =3D new ArrayList()=3B > for (final DependencyNode node : nodes) { > if (node !=3D null) { > final Artifact artifact =3D node.getArtifact()=3B > if (artifact !=3D null) { > returnValue.add(artifact)=3B > } > } > } > if (!returnValue.isEmpty()) { > Collections.reverse(returnValue)=3B > } > } > return returnValue=3B > } >=20 > } MG_01_05>An excellent test-case for maven-dependency-tree >=20 > I think that might be the right way to do it. It's unclear to me how > Maven's internals themselves make use of this class=2C but it is probably > used somewhere=2C and it clearly hides and mediates between the Sonatype > Aether and MG_01_05>most of the Original Sonatype authors monitor this list.. > Eclipse Aether kerfuffle that occurred between 3.0.5 and 3.1.x=2C MG_01_05>a fair amount of confusion once IBM orphaned Eclipse to OpenSource= mavens MG_01_05>The one 'positive' we 'gain' is seamless integration to Eclipse ID= E.. > so this also seems like something that isn't going to be deprecated any > time soon. MG_01_05>lets hope..! > IWBNI there were a quick primer in the documentation somewhere about how > Maven loads its own guts. I know that fundamentally Maven is just a bundl= e > of components that get instantiated and wired together by Plexus but it > sure is confusing to try to figure out how and where something is called= =97as > a result when there are problems you have to go digging through=2C well= =2C > obscure StackOverflow questions. :-) MG_01_05>usually if we can funnel the permutations of thought processes to = one specific question an answer will be MG_01_05>shortly forthcoming for a = real adventure in managing maven repositories thru Embedding I invite you t= o take ride on MG_01_05>the Aether train MG_01_05>http://blog.sonatype.com/2010/08/introducing-aether/ > Best=2C > Laird MG_01_05>Thanks for taking time to 'think this through' MG_01_05>All the Best=2C Martin- >=20 > --=20 > http://about.me/lairdnelson = --_f79d300f-c3e0-4eae-8a18-17c6a14c29fd_--