Search code examples
javamavenbuildnexusrelease-management

SNAPSHOT and RELEASE versions are not getting update at Maven Local Repository


I had set up a Nexus Repository to link-up two separate projects. I am building and deploying the RELEASE and SNAPSHOT versions on Nexus successfully but when i am trying to use the changes in other project using maven update this changes are not getting updated.

So what I did in A_Project.jar in one Project which is got updated in nexus repository.

But when I am trying to get this updated jar at B_Project, I am getting the old jar which was there in maven's local repository. Now, if I manually delete the A_Project.jar, i apparently gets the updated code.

For achieving the updated version of SNAPSHOT and RELEASED version i had tried following ways.

  1. I had used -U with mvn clean build.
  2. I have changed the update policy in setting.xml and pom.xml as follows.

In settings.xml

       <pluginRepository>
            <id>deployment</id>
            <name>Internal Nexus Repository</name>
            <url>http://server/nexus/content/groups/public/</url>
            <layout>default</layout>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
            <releases>
                <updatePolicy>always</updatePolicy>
            </releases>
        </pluginRepository>

In pom.xml

<repositories>
    <repository>
        <id>snapshots</id>
        <url>http://server/nexus/content/repositories/snapshots</url>
        <snapshots>
            <updatePolicy>always</updatePolicy>
        </snapshots>
        <releases>
            <updatePolicy>always</updatePolicy>
        </releases>
    </repository>
</repositories>

Please help as this become a repeated process in getting the latest jar for me.


Solution

  • I can't see enough of your settings.xml to say what is going on. What you have shown is just the pluginRepository section, which is used for resolution of Maven plugins, not artifacts.

    I'd suggest starting with a standard settings.xml file:

    http://books.sonatype.com/nexus-book/reference/maven-sect-single-group.html

    You'll probably want to modify the central repository definition to always look for updates to snapshots:

      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
          </snapshots>
        </repository>
      </repositories>
    

    It sounds like you are also trying to re-release the same release versions? This is a bad practice, releases should be considered immutable (and a lot of the toolchain assumes they are). Increment the version number to make a new release.