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
Check If Int Is Between Two Numbers
Gc Overhead of Optional<T> in Java
How to Get Windows Username in Java
Java 9, Compatability Issue with Classloader.Getsystemclassloader
How to Capture Https with Fiddler, in Java
Gradle - Getting the Latest Release Version of a Dependency
Use of the Manifest.Mf File in Java
Correct Idiom for Managing Multiple Chained Resources in Try-With-Resources Block
Constantly Update UI in Java Fx Worker Thread
In Java, How to Know Whether a Class Has Already Been Loaded
Could Not Set the Column Width to Zero I.E. Not Made Column Invisible
Karate Karate-Config.Js Not a Js Function
How to Run a Class from Jar Which Is Not the Main-Class in Its Manifest File
Possible to Use Two Java Classes with Same Name and Same Package
Pdfbox - Signature Validity Checkmark Not Visible in Acrobat Reader
How to Get Http Response Code for a Url in Java
Running a Java Program as an Exe in Windows Without Jre Installed