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

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).


This plugin removes project's artifacts from local repository. Useful to keep only one copy of large local snapshot.

<plugin>             <groupId>org.codehaus.mojo</groupId>             <artifactId>build-helper-maven-plugin</artifactId>             <version>1.7</version>             <executions>                   <execution>                         <id>remove-old-artifacts</id>                         <phase>package</phase>                         <goals>                               <goal>remove-project-artifact</goal>                         </goals>                        <configuration>                  <removeAll>true</removeAll><!-- When true, remove all built artifacts including all versions. When false, remove all built artifacts of this project version -->                         </configuration>                  </execution>             </executions>       </plugin>


Well I didn't like any of proposed solutions. Deleting maven cache often significantly increases network traffic and slows down build process. build-helper-maven-plugin helps only with one artifact, I wanted solution that can purge all outdated timestamped snapshot artifacts from local cache in one simple command. After few days of searching, I gave up and decided to write small program. The final program seems to be working quite well in our environment. So I decided to share it with others who may need such tool. Sources can be pulled from github: https://github.com/nadestin/tools/tree/master/MavenCacheCleanup