Logo

dev-resources.site

for different kinds of informations.

No SNAPSHOTs

Published at
7/30/2024
Categories
maven
buildtool
Author
madhead
Categories
2 categories in total
maven
open
buildtool
open
Author
7 person written this
madhead
open
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. BTW, "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.

maven Article's
30 articles in total
Favicon
SpringBoot Web Service - Part 5 - Github Action
Favicon
SpringBoot Web Service - Part 2 - Preparing Using Spring Initializr
Favicon
SpringBoot Web Service - Part 1 - Create Repository
Favicon
SpringBoot Web Service - Part 4 - Initial Configuration
Favicon
Identifying and Removing Unused Dependencies in pom.xml
Favicon
JeKa: The Simplest Way to Start with Java for Real
Favicon
JeKa: The Simplest Way to Create Uber and Shade Jars
Favicon
JeKa: The Simplest Way to Publish on Maven Central
Favicon
Preparando o ambiente de desenvolvimento da melhor API de tabelas de campeonato que você já viu!
Favicon
Maven Guide for Beginners
Favicon
Wednesday Links - Edition 2024-10-16
Favicon
Unlock 10% Discounts in 5 Minutes: Build a Drools Project with Maven
Favicon
Getting Started with Maven
Favicon
Quick fix: com.github.everit-org.json-schema:org.everit.json.schema:jar:1.12.2 was not found
Favicon
How to deploy to maven central repo
Favicon
No SNAPSHOTs
Favicon
Maven Commands Cheat Sheet
Favicon
Apache Maven Kirish
Favicon
Difference between mvn install and mvn package
Favicon
Adding Liquibase plugin into Apache Maven managed project
Favicon
Accelerate Maven Application Builds: Maximizing Efficiency with Docker Volumes for Maven Repository Sharing
Favicon
Check for newer versions of dependencies in pom.xml
Favicon
Accelerate Your Automation Testing with Maven: A Step-by-Step Guide 🚀
Favicon
Junit Badge For Git Project
Favicon
Jenkins CICD
Favicon
Set JVM Timezone when running JUnit 5 tests
Favicon
Maven 4 - Part I - Easier Versions
Favicon
An Updated Guide to Maven Archetypes
Favicon
H2 database Setup Error Unable to load name org.hibernate.dialect.Oracle10gDialect
Favicon
Why I prefer Maven over Gradle

Featured ones: