I was in the understanding you already had your own Maven artifact, as you
were talking about two different dependencies. It doesn't have to be a new
artifact in the sense that it has to live in a different repository, you
can also have this artifact as a module in your project.

You can unpack the dependency with the Maven dependency plugin and
repackage it with your own classes.

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
   <execution>
       <id></id>
       <phase>process-resources</phase>
       <goals>
           <goal>unpack</goal>
       </goals>
       <configuration>
           <artifactItems>
             <artifactItem>
               <groupId>commons-lang</groupId>
               <artifactId>commons-lang</artifactId>
               <version>2.6</version>
             </artifactItem>
           </artifactItems>

 <outputDirectory>${project.build.outputDirectory}</outputDirectory>
       </configuration>
   </execution>
    </executions>
</plugin>

Nick Stolwijk

~~~ Try to leave this world a little better than you found it and, when
your turn comes to die, you can die happy in feeling that at any rate you
have not wasted your time but have done your best ~~~

Lord Baden-Powell


On Sat, 29 Jul 2023 at 00:16, <mark.yagnatin...@barclays.com.invalid> wrote:

> I see, so the "proper" way to do this is to create a brand new maven
> artifact.  Sigh.  That is more trouble than I was hoping for.
> Re: upstream: they've already learned their lesson and newer versions
> don't have this issue.
> But they're also not backwards compatible with the version we're on.
>
> -----Original Message-----
> From: Nick Stolwijk <nick.stolw...@gmail.com>
> Sent: Friday, July 28, 2023 6:10 PM
> To: Maven Users List <users@maven.apache.org>
> Subject: Re: enforcing class path order using maven enforcer
>
>
> CAUTION: This email originated from outside our organisation -
> nick.stolw...@gmail.com Do not click on links, open attachments, or
> respond unless you recognize the sender and can validate the content is
> safe.
> Ah, that sounds like a good usecase to fix in your own dependency. Unpack
> the "faulty" dependency there, overwrite it with your own implementation
> and repackage it again. Then in your consuming project forbid the use of
> the "faulty" dependency, using the Maven Enforcer[1] and fix any violation
> with an <exlude> clause.
>
> And, of course, try to push your change upstream as soon as possible, so
> you don't have to maintain this dependency hell forever.
>
> Hth,
>
> [1]
> https://clicktime.symantec.com/15sMqb69g4ndT6CkJRSfW?h=WpHk9xFV9vRGzKQLbhSmi7KXJ9z78ttlOaGHNvrUkDE=&u=https://maven.apache.org/enforcer/enforcer-rules/bannedDependencies.html
>
> Nick Stolwijk
>
> ~~~ Try to leave this world a little better than you found it and, when
> your turn comes to die, you can die happy in feeling that at any rate you
> have not wasted your time but have done your best ~~~
>
> Lord Baden-Powell
>
>
> On Fri, 28 Jul 2023 at 23:53, <mark.yagnatin...@barclays.com.invalid>
> wrote:
>
> > I'd like to clarify one point about why I care about order:
> > I have a class name which clashes on purpose!
> > That is, I have a third-party dependency from maven central that does
> > the Wrong Thing in one of its classes.
> > I have my own "fork" of that class which does the Right Thing.
> > I want to make sure that my version gets picked up!
> >
> > -----Original Message-----
> > From: Tamás Cservenák <ta...@cservenak.net>
> > Sent: Friday, July 28, 2023 5:29 PM
> > To: Maven Users List <users@maven.apache.org>
> > Subject: Re: enforcing class path order using maven enforcer
> >
> >
> > 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.
> > Yup,
> >
> > My "coinciding" work was not to fix people depending in cp ordering,
> > but was more related to my guts telling that "level order" (introduced
> > in experiment PR) is more correct than "pre order".
> >
> > Latter may cause that your 3rd or 4th level transitive dep be enlisted
> > on CP before your 2nd first level dependency (ie.if you consider a pom
> > with 2 dependencies, 1st dep nth level transitive dependency may
> > "shadow" your 2nd direct dependency).
> >
> > Thanks
> > T
> >
> > On Fri, Jul 28, 2023, 23:14 Nick Stolwijk <nick.stolw...@gmail.com>
> wrote:
> >
> > > Hi Tamás,
> > >
> > > Thanks for the corrections! I was still in the belief that it wasn't
> > > explicitly ordered, but it seems that changed in the years. I still
> > > think it is easier to reason about your application if you don't
> > > depend on the order of dependencies. I have always used the Enforcer
> > > plugin to at first give warnings about duplicate classes and later
> > > in a project (when (almost) every duplicate was solved) to start
> > > failing the build if someone introduced a new duplicate.
> > >
> > > I have seen a lot of "strange" behaviour because the IDE used a
> > > different ordering than Maven did, and don't start about the runtime.
> > > If you have duplicate classes and Maven "behaves", who says that the
> > > runtime behaves in the same way?
> > >
> > > I would make it a bigger issue that you have duplicate classes,
> > > instead of trying to live with those duplicates.
> > >
> > > With regards,
> > >
> > > Nick Stolwijk
> > >
> > > ~~~ Try to leave this world a little better than you found it and,
> > > when your turn comes to die, you can die happy in feeling that at
> > > any rate you have not wasted your time but have done your best ~~~
> > >
> > > Lord Baden-Powell
> > >
> > >
> > > On Fri, 28 Jul 2023 at 22:56, Tamás Cservenák <ta...@cservenak.net>
> > wrote:
> > >
> > > > Nick,
> > > >
> > > > I have to correct you, as what you wrote is not true (anymore).
> > > > But
> > > first,
> > > > I think this mail was on hold by moderator, as we had a
> > > > same/similar discussion already on this thread:
> > > > https://clicktime.symantec.com/15sM67LbYXeHjamSQPrKv?h=vxZZY3izFeq
> > > > lPG2oAGQqqxxfPZSoaeUZH6mYPCPUQ5E=&u=https://clicktime.symantec.com
> > > > /15t5jYwsx6K5Z7UziRch6?h%3DVKa9Ey2evQPqt
> > > > ITYTqeL8EywPKBX_Y4PmejsjmKDpPE=&u=https://clicktime.symantec.com/1
> > > > 5sMkktsDT7339Npks3Wt?h=yuPM_pKiMhcXrkpDfmfCxN_suUc5M9SM7Jm7p9i18k4
> > > > =&u=https://lists.apache.org/thread/16
> > > > 055md5s2d5fqch5t4vkn13j7czfybr
> > > >
> > > > But in short:
> > > > - since 2.0.9 dependencies ARE ordered in deterministic way
> > > > (unsure how), but since Maven 3+ they are pre-order (graph
> > > > "flattened" into list, that
> > > is
> > > > then used to create CP and similar things)
> > > > - the plugins are ordered as well (and Maven 4 got or is about to
> > > > get
> > > even
> > > > finer solution)
> > > > - and in above mentioned thread, this is where we at
> > > >
> > > >
> > > https://clicktime.symantec.com/15sM1H9K5uxhKdwWrqTBJ?h=L8F8oV9T9r12T
> > > Jx7Qfl79s9Vfs-4f6fU3RCdCx2O30s=&u=https://clicktime.symantec.com/15t
> > > 5eikbVUdV9Af5AsDYU?h%3DsAaRELxca8Z4PlY
> > > jvO260Lq5WEBvkad0aTt_3p0wSb0=&u=https://clicktime.symantec.com/15sMf
> > > vhakqRSdCYuDJeNG?h=Z3yAZ4KhJ47VH6Kogz5KD_ISs55HmqPuogsogwqpRb4=&u=ht
> > > tps://issues.apache.org/jira/browse/
> > > MNG-6357?focusedCommentId%3D17748655%26page%3Dcom.atlassian.jira.plu
> > > gi
> > > n.system.issuetabpanels%253Acomment-tabpanel%23comment-17748655
> > > > - for the rest (overlapping classes) I do agree fully, but life is
> > > life...
> > > >
> > > > HTH
> > > > T
> > > >
> > > > On Fri, Jul 28, 2023 at 10:45 PM Nick Stolwijk
> > > > <nick.stolw...@gmail.com>
> > > > wrote:
> > > >
> > > > > Hi Mark,
> > > > >
> > > > > I don't think there is any guarantee for ordering in Maven. The
> > > > > dependencies are not ordered, the plugins in the build section
> > > > > are not ordered. I remember that with a Java upgrade the plugins
> > > > > were executed
> > > > in a
> > > > > different ordering due to a new implementation of HashMap. (Only
> > > > > the plugins in the same phase in a lifecycle, of course). The
> > > > > only thing ordered are the phases in the lifecycle.
> > > > >
> > > > > I think it would be more feasible to make sure you don't have
> > > > dependencies
> > > > > with overlapping classes (you can use the Maven Enforcer Plugin
> > > > > for that[1]). If you really need those 2 dependencies on the
> > > > > classpath,
> > > maybe
> > > > > you can try something with the Maven Shade Plugin, to give one
> > > > > of those dependencies their unique package names[2].
> > > > >
> > > > > [1]
> > > > https://clicktime.symantec.com/15sMb6WJJDjrDFiyfkFDe?h=cDnEp1hPoz0
> > > > U4CgYf0D1rg9P6fr4gT2N1Z3NC8ZU9hk=&u=https://clicktime.symantec.com
> > > > /15t6QCW9d1mprg6P4tot4?h%3D37l3X1rUMHCNa
> > > > zx5tx73nMPMatZatBRkIVE73EVfz5s=&u=https://clicktime.symantec.com/1
> > > > 5sNkjEGiqJ9zVHuHZqJL?h=Wj40IL08TQx1Am6CbWuAq82crOtvT16rG_ru_Q2bJ_s
> > > > =&u=https://www.mojohaus.org/extra-enf
> > > > orcer-rules/banDuplicateClasses.html
> > > > > [2]
> > > > >
> > > > >
> > > >
> > > https://clicktime.symantec.com/15sMAwXt19Kt9XbMwxFUY?h=9JBB5o1JiTgpe
> > > yxq5Ox0ZYKyEC8Un7fhV2TTVKJx91E=&u=https://clicktime.symantec.com/15t
> > > 5pP9AQhzfy4JvFz1qi?h%3D454YA129nQl0eUE
> > > Uetl13kca-YVeudTafYsvmeO1vd0=&u=https://clicktime.symantec.com/15sMv
> > > RHS8gUDs32fqyqp8?h=foVu4uALN44dhWiTZkS9Gt6DG3xh-LWy7R19egvate0=&u=ht
> > > tps://maven.apache.org/plugins/maven
> > > -shade-plugin/examples/class-relocation.html
> > > > >
> > > > > Hth,
> > > > >
> > > > > Nick Stolwijk
> > > > >
> > > > > ~~~ Try to leave this world a little better than you found it
> > > > > and, when your turn comes to die, you can die happy in feeling
> > > > > that at any rate
> > > you
> > > > > have not wasted your time but have done your best ~~~
> > > > >
> > > > > Lord Baden-Powell
> > > > >
> > > > >
> > > > > On Fri, 28 Jul 2023 at 21:25,
> > > > > <mark.yagnatin...@barclays.com.invalid>
> > > > > wrote:
> > > > >
> > > > > > I already asked this question on Stack Overflow but got no
> > > > > > takers so
> > > > I'm
> > > > > > trying again here:
> > > > > >
> > > > > > Suppose I have a maven module M which declares a direct
> > > > > > dependency on modules X and Y.
> > > > > > I want the classes from X to come before classes from Y in the
> > > > > > class
> > > > > path.
> > > > > > Is there any easy way to add a rule in maven enforcer to
> > > > > > ensure that
> > > I
> > > > > > don't accidentally swap the order sometime in the future?
> > > > > >
> > > > > > Copied from here:
> > > > > >
> > > > > >
> > > > >
> > > >
> > > https://clicktime.symantec.com/15sMFmjATm1UZURHVWedA?h=ynRdiTFrrG1rF
> > > aXcxysOeaKsUmg0dmldb_cBA1sSznc=&u=https://clicktime.symantec.com/15t
> > > 5uDLSsKgGP18qoYQzL?h%3D7EsniQcHdjM6TWA
> > > LQmIQCb3sq4YQHFeY033chmgMmio=&u=https://clicktime.symantec.com/15sN1
> > > FUibJ9pGyrbPYExk?h=eDkz8-Obuy4h2sALuIdSFh7By5I1VTpDwHTlwl6RV2U=&u=ht
> > > tps://stackoverflow.com/questions/76
> > > 766623/maven-enforcer-enforce-class-path-order
> > > > > >
> > > > > >
> > > > > > 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/15t6KNJsAQ6ESjGTXLQjS?h=UYic_JXsxcpL2aF
> > 1JEpHtd_IKig2nm08TfffhuM3isI=&u=https://clicktime.symantec.com/15sNfu2
> > zGDcZaYTyk1S9i?h=K0jItvf7d52pJ6QO0WRJULKdBOsAc57F5tm3EUmLNwk=&u=https:
> > //www.cib.barclays/disclosures/web-and-email-disclaimer.html
> > .
> > > > > >
> > > > > > For important disclosures, please see:
> > > > > >
> > > https://clicktime.symantec.com/15sMWGK1qc4FoJu48Br52?h=o-9EIDPJAoK3L
> > > PMXx1VUMsMjQSZVyE4utP01aHhia1U=&u=https://clicktime.symantec.com/15t
> > > 6EY7ahnQe2nSXyn1ap?h%3D3yPmimR8ZeJmRI1
> > > Qrhr5Iz1WBozTWiLZY6jnjTIL5WU=&u=https://clicktime.symantec.com/15sNW
> > > EeRLzFNkep8etdrU?h=O8ycT8aHZrOgAo8cEEg88S9qb-sIFm_ejnN-XCxeNcs=&u=ht
> > > tps://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/15sMLbvSvNh4yRFD353mn?h=RO-H88TlQKnXZ
> > > jEOcByFjLom9aCmtt1crfNguIoWaM4=&u=https://clicktime.symantec.com/15t
> > > 5z3XjKwMrnwxmM6p8x?h%3DnnifedQWQSIN0hF
> > > ZZCphqp2eD_UPYsXCh03glxrZv0E=&u=https://clicktime.symantec.com/15sN6
> > > 5g13uqQgvgWw6e7N?h=eZkUHyPzMn3kOO9XxiadYUj4GH1KSQcOOjLqobnDizQ=&u=ht
> > > tps://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/15t5ZtZK2rwtjDq9dJpPr?h=ebFuluTMuHrujaX
> > g7BbA6RFvI3sVnJosEx6rvhG3whQ=&u=https://clicktime.symantec.com/15sLvSx
> > 2dJH6uh7bKH42g?h=l177LTq9GZUa3qCC2V1ZuJ4-xA1MfEySTpa3z3dBhEU=&u=http:/
> > /publicresearch.barclays.com
> > .
> > > > > >
> > > > >
> > > >
> > > ____________________________________________________________________
> > > __
> > > ____________
> > > > > >
> > > > > > If you are incorporated or operating in Australia, read these
> > > important
> > > > > > disclosures:
> > > > > >
> > > > >
> > > >
> > > https://clicktime.symantec.com/15sMRS7jNzNfPN58adSvQ?h=H4ggbvT0eNYNH
> > > vjCMzXHjd5oyPG-Gx5NWjOG_3QGbek=&u=https://clicktime.symantec.com/15t
> > > 64sj1nZ3TCtngtfDHa?h%3DamyGj5lckrWHDr6
> > > zgTItvkj4U9D2J4Cuf_bbIvQD9n8=&u=https://clicktime.symantec.com/15sNF
> > > k4Zy9CbWpLN2DSQc?h=CcoN2rbpoaZATX98tJVWa7MZEGrkbc7YqvKw-657s2g=&u=ht
> > > tps://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/15t69hvJFAj3cqccSDcSC?h=_BB12LrslSf75XH
> > 6-ndRMcBbzwMd5gE9uHGHB7VdVIk=&u=https://clicktime.symantec.com/15sNRQT
> > 8tNZnLhzD7LEhr?h=GvFImECNx8gTf62seylU45ciOyb-VLCknXotfCE2sBI=&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://clicktime.symantec.com/15sNfu2zGDcZaYTyk1S9i?h=K0jItvf7d52pJ6QO0WRJULKdBOsAc57F5tm3EUmLNwk=&u=https://www.cib.barclays/disclosures/web-and-email-disclaimer.html
> .
> >
> > For important disclosures, please see:
> > https://clicktime.symantec.com/15sNb4qhobvyAbe4CT316?h=1_1xUcUb3v53tSM
> > y9ISqiHNodhziFuVFqIbSBOKerDQ=&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/15sNAusHWXX16sWSUf3Fz?h=E9H2DdRSa4CA05p
> > 57gzKRXrtWa6vhmaQBEoiWvyeEQk=&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/15sLvSx2dJH6uh7bKH42g?h=l177LTq9GZUa3qCC2V1ZuJ4-xA1MfEySTpa3z3dBhEU=&u=http://publicresearch.barclays.com
> .
> > ______________________________________________________________________
> > ____________
> >
> > If you are incorporated or operating in Australia, read these
> > important
> > disclosures:
> > https://clicktime.symantec.com/15sNLaFrRktBvmAHZmqZE?h=SloBRruZTEV7z7s
> > cEJ3mxrsTUYeco575d3ODzv79_ZQ=&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/15sNRQT8tNZnLhzD7LEhr?h=GvFImECNx8gTf62seylU45ciOyb-VLCknXotfCE2sBI=&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.
>
>
> __________________________________________________________________________________
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
>

Reply via email to