简体   繁体   中英

multiple repositories with the same artifact in maven

I have made some modifications to log4j and would like my project to use my local version rather than that from the remote maven repo, so I declared my project as a local repo in pom.xml in addition to my remote repo for other dependencies:

 <repository>
      <id>my-log4j</id>
      <name>my log4j</name>
      <url>file:///...</url>
 </repository>
 <repository>
      <id>remote</id>
      <name>remote repo</name>
      <url>http://...</url>
 </repository>

maven copied the files from my local repo as expected, but then it downloaded log4j again from the remote repo and overwrote the earlier files. Is there a way to exclude certain artifacts from being downloaded from the remote repo?

Also, how does maven detect changes to my-log4j? How can I make maven copy the my-log4j artifacts each time during compilation?

If maven looks for artifacts, it always looks in your local repository first, you do not have to specify it (you can specify the location of your local repository in your settings.xml ).

You answered your question already: If you had to change a third-party artifact, rename it (already in the pom.xml ) like my-log4j or log4j-my-patch . Then it won't collide with the original artifacts.

If you make a custom version of something, you give it a custom version number.

For example, if you modify log4j-1.2.17 for your own use, give it the version 1.2.17.JRR.1 and following numbers as you work on it.

You build them on your computer and when you run the install goal, it will put them in your local repo. If you have a shared repo for your group, it can be deployed there as well and never confused with the Apache releases.

This will never be found in the remote repo, just in yours.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM