4

We have a build server for Maven builds. As usual, all newly found dependencies are drawn into the local Maven repository. This means that the local repository grows more and more over time, keeping a lot of old artifacts.

As we are fighting for every GB on the server (I always hear that storage space is cheap - but the people saying this have probably never worked in a large company, where you cannot just "buy a server" or "use the cloud"), we like to develop a strategy for tidying up the local repository:

  • On the one hand, we want to keep the often used artifacts, so that "erase the local repository every Sunday" is not a good option.
  • On the other hand, we need to delete old artifacts, especially old snapshots that are no longer in use.

Any solutions for this?

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • What do you mean with `local Maven repository`? The `maven.local.repository` or a local repository manager (like Nexus)? – SubOptimal Jan 25 '17 at 07:26
  • @SubOptimal I don't mean Nexus or Artifactory, but the "cache" that is usually stored in .m2/repository. – J Fabian Meier Jan 25 '17 at 07:53
  • You might use something which is based on `find $MAVEN_REPO/ -type d -atime +180` to find files which were accessed last time more than 180 days ago. – SubOptimal Feb 03 '17 at 07:28
  • This probably does not work on Windows systems, does it? – J Fabian Meier Feb 03 '17 at 08:05
  • Don't know. NTFS supports a last access time stamp, but it might be disabled https://www.groovypost.com/howto/microsoft/enable-last-access-time-stamp-to-files-folder-windows-7/ – SubOptimal Feb 03 '17 at 08:45

0 Answers0