Dave
Dave

Reputation: 843

Will Maven overwrite a manually patched jar in local Maven repo?

I have a Maven project that works just fine.

In order to triage an issue, I manually patched a jar to add debug logging and then copied it to the local Maven repo directory. I made subsequent changes to the jar file to add more debugging and did a mvn install:install-file since that seemed more "official".

Note that I did not change the coordinates at all (I know that artifacts are meant to be immutable, but I did not want to change pom.xmls).

My question is: when (if ever) will Maven overwrite this patched jar with the one in the remote Maven repository which is considered the source of truth?

Upvotes: 2

Views: 3355

Answers (1)

ritesh.garg
ritesh.garg

Reputation: 3943

There are only three scenarios in which that jar can be overwritten:

  1. If you delete the jar from your local m2 repository, it will be downloaded from the remote repository the next time you build your maven project.
  2. If you build your maven project with '-U' option. Doing this will force maven to update the dependencies from remote repository.
  3. If you perform an mvn install on the same artifact(updated code) with the same version.

Upvotes: 4

Related Questions