No SNAPSHOTs
SNAPSHOTs are a confusing Maven concept.
Maven is a pre-historic build tool, invented inside The Apache Software Foundation to build its (mostly Java) projects back in the 2000s.
It is, thus, very opinionated, just like this post.
Those opinions — including SNAPSHOTs, maven-release-plugin
, POM, repository and project layouts, and many more — are still alive today and spoil modern projects.
Even ASF does not use Maven to build some of its projects anymore: Beam, Groovy, Lucene, Geode, POI, and Solr are not built with Maven. Those are not the most popular ASF projects, I know, but still, it is something.
Artifacts must be immutable, and two artifacts with the same version must be the same.
That is not the case with SNAPSHOTs: they are mutable by definition and every new build could change the artifact published under the -SNAPSHOT
version.
Because of that, SNAPSHOT
artifacts require special treatment.
They have their own updatePolicy
.
Do you, fellow Maven users, know off the top of your head, how often are they updated by default?
Daily.
SNAPSHOTs are usually uploaded to a separate repository and they are not — obviously — accepted by the Maven Central.
SNAPSHOTs are a potential source of errors. Hopefully, only during the development and testing process, because no one should use them in production.
Stick to something like Semantic Versioning, and use pre-release identifiers and unique build identifiers instead of SNAPSHOTs. By the way, "SNAPSHOT" is a valid Semver pre-release identifier, however to guarantee artifact immutability, you should include additional metadata in the version, like unique build number, commit hash, or timestamp, etc.
Abandoning SNAPSHOTs doesn’t mean that you cannot use the "latest" or "dynamic" version of the artifact in your project. Modern build tools support dynamic versions, rich versions, version ranges, constraints, and other cool stuff. I am pretty sure your build tool has it.
Just to be clear: published artifacts must be immutable, and SNAPSHOTs are not, but you could still have a dynamic version (or a dynamic, but locked/pinned, version) in your projects.