3

At the moment, our Nexus tidies up SNAPSHOTs but always leaves the last SNAPSHOT even if a release version exists. The reasons for that are:

  • To be able to checkout old revisions and build them (locally).
  • To be able to run goals like versions:use-releases which can only replace existing SNAPSHOT versions with release versions.

What I don't like is the fact that SNAPSHOTs are taking hundreds of GB on the disk, although they are mostly useless.

In our Ant system that we retired some years ago, non-existent "SNAPSHOTs" were resolved against the release version. This solves above dilemma, but is not possible in Maven.

Is there another good solution?

Solutions for Nexus and Artifactory are both welcome.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142

1 Answers1

5

If you activate the Nexus3 cleanup policy to "prerelease", that should get rid of all snapshot whenever a release is published.

I use it in my shop, and get some calls of users unable to get a snapshot (any snapshot for a given version): I have to explain that is because a release has been published (with the same version number)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Yes, but how do you deal with the disadvantages as described in the question? It seems to be what some people call "red monday", which means that after cleanup on the weekend, suddenly their projects are red in Eclipse, and they need to tidy this up _manually_ to go on working (goals like `versions:use-releases` don't work any more). It would to avoid this interruption in development. – J Fabian Meier Apr 20 '20 at 18:12
  • @JFMeier my colleagues don't see it as a disavantage: they know they have to update their dependencies in order to depend on a release (safer than a snapshot, which can change at any time, and make the build go red) – VonC Apr 20 '20 at 18:17
  • I just fear the updating nightmare. What if e.g. one of your _transitive_ dependencies got released, but your direct dependencies are not yet released? Then you need to add extra `` entries to change that transitive dependency? – J Fabian Meier Apr 20 '20 at 18:36
  • @JFMeier Exactly, we are working with BOMs which inlcudes the right dependencyManagement. Project are only declaring their dependencies without specifying the version, and reference the BOMs as snashot artefacts. The CI/CD chain update the BOM, and all projects automatically benefit from the new version. – VonC Apr 20 '20 at 18:45
  • @JFMeier I documented that process before on Stack Overflow: https://stackoverflow.com/a/47372449/6309 – VonC Apr 20 '20 at 18:47
  • Oh I see we discussed that topic already two and a half years ago ;-). Using BOMs to clear this up generally seems like a good idea. I still do not like your idea of having "one SNAPSHOT BOM forever", but we are using BOMs quite extensively (with SNAPSHOT, BETA and release versions). So it might be a good idea to think about it this way. – J Fabian Meier Apr 20 '20 at 18:56
  • @JFMeier That particular snapshot BOM is only modified by release into production: it is supposed to represent the latest stable state, as validated by an official release. – VonC Apr 20 '20 at 19:07