Wow, so this stuff is literally "hot off the press"!  Is this likely to end up 
in the 3.x series, or need to upgrade to 4?
Also, once it goes in, can this please be documented somewhere more "official" 
than a release notes thingy?

-----Original Message-----
From: Tamás Cservenák <ta...@cservenak.net> 
Sent: Thursday, July 27, 2023 11:29 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.
And here it is:
https://clicktime.symantec.com/15sipz7F5STrvRGrevHBY?h=7Y8hfhGCp9uBBufC8Pdra11MjKQK1pB9sZxKj0WyVT4=&u=https://github.com/apache/maven/pull/1212

To have this tested, first build this
https://clicktime.symantec.com/15sik9uxcpnGWUSw7Mt2v?h=Ykgfx9FlWtp9Mzx3hItBj6j3zdtVOq7AohrAHo-SEhg=&u=https://github.com/apache/maven-resolver/pull/322
then this:
https://clicktime.symantec.com/15sipz7F5STrvRGrevHBY?h=7Y8hfhGCp9uBBufC8Pdra11MjKQK1pB9sZxKj0WyVT4=&u=https://github.com/apache/maven/pull/1212

And you will end up with maven:
- that fully delegates to resolver classpath ordering (removed all places where 
they are "sorted", it is done by resolver)
- resolver supports "preOrder, "postOrder" and "levelOrder" transformation

Examples:
preOrder 
https://clicktime.symantec.com/15siaVXPhbR5gao62F5jg?h=ZNj2Gfw4KUWOqAboOy7hrW4_dA-8ANFsatojmBQ23HU=&u=https://gist.github.com/cstamas/d1cb11d96938cdb9e6da2b46eec449b6
levelOrder 
https://clicktime.symantec.com/15siQq8pnN3trh9Ew8HSS?h=SFbeFNH1ZOnGqJUbSsU15ER7BNDe9eZuFYruemWExQo=&u=https://gist.github.com/cstamas/6498cfb31afe74ded1471c02d982eee6

Observe how collected trees are TOTALLY SAME, but classpath order differs.

Thanks
T

On Thu, Jul 27, 2023 at 4:51 PM Tamás Cservenák <ta...@cservenak.net> wrote:

> 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/15siupJXY49TLN6nCUgLA?h=7vkUPM03eakDwHh
> dabKdvr3cDonDm1gylwtF58tHzag=&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/15sifKigAD6g6Xd1ZoUtJ?h=SEFwjM88CuRbMjD
> -_g1kUUwvb0y9AuM49l0EoicAJ_o=&u=https://github.com/apache/maven-resolv
> er/blob/maven-resolver-1.9.14/maven-resolver-util/src/main/java/org/ec
> lipse/aether/util/graph/visitor/PreorderNodeListGenerator.java
>
> The example output:
> https://clicktime.symantec.com/15siVfL7EyjVGdyAUggb4?h=eKPHFWmgDwUy2Jd
> 9zqj7FZMg0YLR8cEQ_HTJ5N88EVk=&u=https://gist.github.com/cstamas/ca113c
> 1d6697540a4cf55c3098b9a550
>
> 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/15sik9uxcpnGWUSw7Mt2v?h=Ykgfx9FlWtp9Mzx
> 3hItBj6j3zdtVOq7AohrAHo-SEhg=&u=https://github.com/apache/maven-resolv
> er/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/15siFAkFs8gi2oVPr1V9C?h=CzqA8kBOdhB05Y
>> fPbEvxwyofbPnfsaxl96JNiQ24c3U=&u=http://people.apache.org/~jvanzyl/ma
>> ven-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/15sjKyGwq8ZRQ6EPvGg5G?h=R8p3aI2uzqYl9AJrGqULxFlFy3cX0fiBCQDRP1AeyGo=&u=https://www.cib.barclays/disclosures/web-and-email-disclaimer.html.
>>
>> For important disclosures, please see:
>> https://clicktime.symantec.com/15sjF95fNWspz9QUNiGve?h=MtdCG72x7TXyv9
>> -dgFuFKoFO-ky6c2ogYYC7zLOfJd0=&u=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://clicktime.symantec.com/15sizeVozfq3kJvhk35Un?h=sdSAcHHKzTOsIE
>> p2LfFkNvZhzipyXqvxhNQCgxq4Io0=&u=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: 
>> https://clicktime.symantec.com/15siKzwYKkNJSkKKPZtHp?h=Je7qpaTZtASq-iQ-xl57meLRZRwWrJXo2vFVWrrZIME=&u=http://publicresearch.barclays.com.
>> _____________________________________________________________________
>> _____________
>>
>> If you are incorporated or operating in Australia, read these 
>> important
>> disclosures:
>> https://clicktime.symantec.com/15sj5Uh6THWeAFkdHbUdQ?h=KdEyApOqeQa_6n
>> BY05SQeHaeqyGWHGTut75n7L0sC5I=&u=https://www.cib.barclays/disclosures
>> /important-disclosures-asia-pacific.html
>> .
>>
>> _____________________________________________________________________
>> _____________ For more details about how we use personal information, 
>> see our privacy
>> notice:
>> https://clicktime.symantec.com/15sjAJtNuuCEaCaYq9sn2?h=hT4zPl827uvY3a4r5majQRgGLX7sPO7jWLHFSlXrLvY=&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. 
__________________________________________________________________________________

Reply via email to