How to Deal with Maven-3 Timestamped Snapshots Efficiently

How do you deal with maven-3 timestamped snapshots efficiently?

The <uniqueVersion> configuration applied to artifacts that were deployed (via mvn deploy) to a Maven repository such as Nexus.

To remove these from Nexus, you can easily create an automated job to purge the SNAPSHOT repository every day. It can be configured to retain a certain number of shapshots or keep them for a certain period of time. Its super easy and works great.

Artifacts in the local repository on a developer machine get there from the "install" goal and do not use these timestamps...they just keep replacing the one and only SNAPSHOT version unless you are also incrementing the revision number (e.g. 1.0.0-SNAPSHOT to 1.0.1-SNAPSHOT).

Maven 3 and timestamps

Quoting from the relevant section in Maven 3.x Compatibility Notes

The setting false for a distribution
repository has no effect in version 3.x, snapshot artifacts will
always be deployed using a timestamped version.

Also, look at the comments in this nexus jira bug on a nice explanation to your other questions.

How to stop Maven/Artifactory from keeping Snapshots with timestamps

The simplest (and recommended) way is to use non-unique snapshots. If you must use unique snapshots, you can do this in Artifactory by specifying the <maxUniqueSnapshots> property on the <localRepository> definition in artifactory.config.xml

For example:

<localRepository>
<key>snapshots</key>
<blackedOut>false</blackedOut>
<handleReleases>false</handleReleases>
<handleSnapshots>true</handleSnapshots>
<maxUniqueSnapshots>1</maxUniqueSnapshots>
<includesPattern>**/*</includesPattern>
<snapshotVersionBehavior>non-unique</snapshotVersionBehavior>
</localRepository>

For reference you can do this in Nexus (via the UI) by setting up a scheduled service, it allows you to specify the minimum number to retain, the maximum period to retain them for, and whether to remove the snapshot if a release version is deployed.

How to tell maven to use a snapshot version? It tries to load x.y.z-SNAPSHOT but nexus has replaced -SNAPSHOT

Okay, the issue was resolved.

We had a "clean snapshots task" in Nexus which deleted "old" -- although this one was not that old -- snapshots. We changed the number of kept snapshots and restored the ones missing.

Thanks so far for all suggestions!



Related Topics



Leave a reply



Submit