0

In Our Project Nexus is used as Jar repository and we are having the below entry in the settings.xml .

<mirror>
     <!--This sends everything else to /public -->
     <id>nexus</id>
     <mirrorOf>*</mirrorOf>
     <url>http://*.*.*.*:7003/nexus/content/groups/public</url>
</mirror>

When ever a new jar is loaded in nexus it is uploaded in the path as per the entries present in the pom.xml .

<dependency>
          <groupId>com.pqr.xyz.abc</groupId>
          <artifactId>xyz</artifactId>
          <version>2.2.0.0.4.1</version> OR <version>LATEST<version>
 </dependency>

So, if the jar is uploaded in nexus every time with a new version then the it is getting picked when we are doing the maven update for our project which is having the entry of the version as mentioned above (either the specific version or LATEST.

But if we update the same version folder in nexus with the updated jar then maven update is not picking the latest jar, it keeps the old jar in the .m2 repository even if we do force update then also.

So we think that if the jar is replaced in the same folder in nexus then it will not be updated if the folder already exists in .m2 repository?

Is there any way to take the latest jar every time even if the same folder is updating in nexus via maven update?

  • What version of Maven are you using? To be clear here, are you actually uploading a new version number each time, or are you trying to overwrite an existing version? – Tim Biegeleisen Jun 12 '18 at 04:10
  • use "maven force update", adding the flag -U . See https://stackoverflow.com/questions/4701532/force-maven-update – Daniele Jun 12 '18 at 04:22
  • @Tim I am using Apache Maven 3.1.1. If i am uploading new version each time it is working fine when I do maven update it picks the new version. But when I am overwrite the jar in same version in nexus then it is not getting picked. – ritul sinha Jun 12 '18 at 04:28
  • @Daniele I already tried force maven update also , it did not worked. Still the old version jar was there in the .m2 folder for which jar was overridden in nexus, – ritul sinha Jun 12 '18 at 04:30
  • Then I think the problem is your Nexus configuration. I'll bet your overwrites are being rejected. – Tim Biegeleisen Jun 12 '18 at 04:31

1 Answers1

0

You have a misunderstanding of maven concepts regarding versioning of artefacts. There is a big difference between SNAPSHOT and release versions and I suggest to read these documentations: Release and Snapshot and Repositories settings

Back to your issue, the solution is to remove from your local maven repository the artefact that was updated on nexus. You have 2 options:

  1. List item manual delete the folder ${user.home}/.m2/repository/com/pqr/xyz/abc/xyz/2.2.0.0.4.1/ (this assume your local repository in under your home directory)
  2. Use dependency plugin - purge local repository to remove local artefacts. You can find an example here

In your expose you didn't mention why you have to update a release jar in nexus. Conceptually, this smells. I advise to reconsider your release procedure and to avoid updates on releses versions. It's better to create a patch/minor version instead of updating a release. Put in place of a client, when a client should check if a release was updated and based on what? A downloaded file timestamp is not reliable.

catta
  • 281
  • 1
  • 5