1 - yes 2 - yes (Maven tries hard to simplify things for users, but heh) 3 - yes, model ordering matters, most easily checked with `mvn help:effective-pom`, so to say if depency A is before dependency B in effective POM, same should be true for classpath as well.
HTH T PS: Sorry for bloated answers, a I just spotted that this is user ML not dev ML.... On Thu, Jul 27, 2023 at 5:29 PM <mark.yagnatin...@barclays.com.invalid> wrote: > Thank you! I think my main takeaway here is that things (1) in flux (and > hopefully will improve in Maven 4) and (2) a bit complicated but > (3) I can still guarantee something comes first by listing it as the first > thing in the pom (is that right?) > > Thanks once more! > Mark. > > -----Original Message----- > From: Tamás Cservenák <ta...@cservenak.net> > Sent: Thursday, July 27, 2023 10:52 AM > To: Maven Users List <users@maven.apache.org> > Subject: Re: maven class path order documentation > > > CAUTION: This email originated from outside our organisation - > ta...@cservenak.net Do not click on links, open attachments, or respond > unless you recognize the sender and can validate the content is safe. > What a coincidence... > > I just started looking at an old issue (was looking at some edge cases) > where even reproducer exists and tackles similar topic: > > https://clicktime.symantec.com/15t5z3XK8nENdtkfvA1F3?h=Efy8jMRjTS28CUJyvgBnMOlaMr07e6ETXpi8khKLG3k=&u=https://issues.apache.org/jira/browse/MNG-6357 > > Then I went to maven sources and resolver sources to ensure what is > happening. > > Sadly, maven is not quite consistent in this matter, but is at least > aligned: > - at some places it uses PreorderNodeListGenerator to generate classpath > (and/or ordered artifacts) > - at some other places it relies on resolver ordering (that ALSO > implicitly uses preorder) > > The class in question: > > https://clicktime.symantec.com/15t5pP8kDYsBp16pq3Cwo?h=8f2DByrPlQLfzEcejbPLFPQGuQ8TsuWhXGbnYcguXpQ=&u=https://github.com/apache/maven-resolver/blob/maven-resolver-1.9.14/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/visitor/PreorderNodeListGenerator.java > > The example output: > > https://clicktime.symantec.com/15t5jYwTkwBbQ4GuHUooB?h=T619edEwyisQy-KWGy3VvRfMFWDbZCgujjHUqdh8Wfg=&u=https://gist.github.com/cstamas/ca113c1d6697540a4cf55c3098b9a550 > > As you can see in example, the classpath is basically ordered as "reading > the tree", this causes that for example maven-dependency-tree (2nd level > dependency) comes BEFORE enforcer-api (1sd level) dependency. > > So, I myself find this wrong as well, but at least the statement you found > "introduced deterministic ordering of dependencies on the classpath" still > stands today: is PreOrder. > > Then occurred to me that this is easily customisable, so I went for start > to create this: > > https://clicktime.symantec.com/15t5uDL2gAYnDwvkNbc6R?h=Oo9ciO2fkPcfkh29sRGMpRA_gqMZXDNvOTPIvINgw_A=&u=https://github.com/apache/maven-resolver/pull/322 > > But this is only half of the story, as the Maven part is missing, > especially where Maven sorts itself... > > All in all, an interesting coincidence.... > > As for your other question: what resolver does is > - builds a "dirty tree" (graph more precisely, it may have loops), we have > two algorithms for this: original depth-first (DF) and new breadth-first > (BF) > - applies conflict resolution (this is where "winners" are set, ie. > "closest wins" in case of duplicates) > - resulted "clean tree" is transformed into list of (resolved) artifacts, > possibly into classpath as well > - OR the resolved graph is with class like (but > consistently) PreorderNodeListGenerator used to create classpath -- so > PreOrder is applied always > > Thanks > T > > > On Thu, Jul 27, 2023 at 3:51 PM <mark.yagnatin...@barclays.com.invalid> > wrote: > > > Re-sending... didn't go through I think: > > > > In the release notes for Maven 2.0.9: > > https://clicktime.symantec.com/15t5ZtYtqhpQaAd4CN1Vw?h=XDVhSYMduTltP5c > > FPTLr7pXDMQ0hXrn_euWrugDjQoo=&u=http://people.apache.org/~jvanzyl/mave > > n-3.1.1/docs/2.0.9/release-notes.html > > It says: "introduced deterministic ordering of dependencies on the > > classpath. In the past, natural set ordering was used and this lead to > > odd results. The ordering is now preserved from your pom, with > > dependencies added by inheritance added last" > > Is this info still current? Is it documented anywhere aside from this > > release note? If not, perhaps it should be? And more details would > > be nice too. For instance: > > > > * Suppose my module M has parent P and grandparent G. Also, M > > depends on A and B, in that order. Further, suppose A depends on X, > > which in turn depends on Y. Meanwhile, B depends on Z. > > > > Based on the sentence above, both of these are plausible orders: > > > > a. M, A, B, X, Z, Y, P, G > > > > b. M, A, X, Y, B, Z, P, G > > > > c. Maybe others too? > > > > * How does this relate to the dependency "mediation" algorithm > > maven uses when there are conflicting versions of a dependency requested? > > > > As far as I understand, that uses a breadth-first search, where the > > parent pom comes FIRST rather than last. > > > > Does that mean that mediation algorithm is basically unrelated to > > class path algorithm, or do they still have some things in common? > > > > E.g., ordering (a) above is also a breadth-first search, whereas (b) > > is depth-first. > > Any words of wisdom would be nice. > > > > Thanks, > > Mark. > > > > This message is for information purposes only. It is not a > > recommendation, advice, offer or solicitation to buy or sell a product > > or service, nor an official confirmation of any transaction. It is > > directed at persons who are professionals and is intended for the > > recipient(s) only. It is not directed at retail customers. This message > is subject to the terms at: > > > https://clicktime.symantec.com/15t6QCVjRreLhctHdwzz9?h=bKQ27fsuIx4Xxr8OQZlMhCTfuRly4h0r58TJEoLAo7E=&u=https://www.cib.barclays/disclosures/web-and-email-disclaimer.html > . > > > > For important disclosures, please see: > > https://clicktime.symantec.com/15t6KNJSyExkHg4N6PbqX?h=ybaw-Nh1xLrILJk > > yXAS99Ei3SNNFFo5J2KB5vm56MtQ=&u=https://www.cib.barclays/disclosures/s > > ales-and-trading-disclaimer.html regarding marketing commentary from > > Barclays Sales and/or Trading desks, who are active market > > participants; > > https://clicktime.symantec.com/15t64sibbPuy3qabTiQPf?h=py8wR1d8d73qyHD > > DZxN0Smo58EoxOupWwqoULnWBkY0=&u=https://www.cib.barclays/disclosures/b > > arclays-global-markets-disclosures.html > > regarding our standard terms for Barclays Corporate and Investment > > Bank where we trade with you in principal-to-principal wholesale > > markets transactions; and in respect to Barclays Research, including > > disclosures relating to specific issuers, see: > https://clicktime.symantec.com/15t5eikBJKVzz7SyjvQeZ?h=z7g2f34T1OXzr_VF4QTmGJZXpv9m8zIyTKNvfsOM2X8=&u=http://publicresearch.barclays.com > . > > ______________________________________________________________________ > > ____________ > > > > If you are incorporated or operating in Australia, read these > > important > > disclosures: > > https://clicktime.symantec.com/15t69hut41bZTnQX1GoYH?h=D81Cbd9aEzDdnyN > > AJdypT-1WRx8SiGvIZPkwac34Gx4=&u=https://www.cib.barclays/disclosures/i > > mportant-disclosures-asia-pacific.html > > . > > > > ______________________________________________________________________ > > ____________ For more details about how we use personal information, > > see our privacy > > notice: > https://clicktime.symantec.com/15t6EY7AWdH9sjESYqCgu?h=90zqGsD_LYA3On9o-jjc4H3Q7_q9NTSgvBfQvwtEecs=&u=https://www.cib.barclays/disclosures/personal-information-use.html > . > > > > > > ______________________________________________________________________ > > ____________ > > This message is for information purposes only. It is not a recommendation, > advice, offer or solicitation to buy or sell a product or service, nor an > official confirmation of any transaction. It is directed at persons who are > professionals and is intended for the recipient(s) only. It is not directed > at retail customers. This message is subject to the terms at: > https://www.cib.barclays/disclosures/web-and-email-disclaimer.html. > > For important disclosures, please see: > https://www.cib.barclays/disclosures/sales-and-trading-disclaimer.html > regarding marketing commentary from Barclays Sales and/or Trading desks, > who are active market participants; > https://www.cib.barclays/disclosures/barclays-global-markets-disclosures.html > regarding our standard terms for Barclays Corporate and Investment Bank > where we trade with you in principal-to-principal wholesale markets > transactions; and in respect to Barclays Research, including disclosures > relating to specific issuers, see: http://publicresearch.barclays.com. > __________________________________________________________________________________ > > If you are incorporated or operating in Australia, read these important > disclosures: > https://www.cib.barclays/disclosures/important-disclosures-asia-pacific.html > . > > __________________________________________________________________________________ > For more details about how we use personal information, see our privacy > notice: https://www.cib.barclays/disclosures/personal-information-use.html. > > > __________________________________________________________________________________ >