Maven Repositories contain many sorts of build artifacts and dependencies. Two types of repositories are local and remote. A local repository is a directory on the computer that executes Maven. It stores remote downloads and builds artifacts.
In this article, we will discuss about Maven Snapshot Repository vs Release Repository.
Maven Snapshot RepositoryMaven Snapshots are used to capture a work in progress while it is being developed. In Maven, a snapshot is an artifact whose version ends with -SNAPSHOT. When deployed, the snapshot is converted to a timestamp. Snapshots, by definition, can be changed, whereas releases cannot. This is why requires you to keep them separately and normally don’t care if you lose snapshots, but you do if you lose releases. This makes snapshot cleanup much easier to manage. A Snapshot artifact includes both a version number and a timestamp.
Example of Maven Snapshot Repository:
XML
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.horje</groupId>
<artifactId>my-project</artifactId>
<version>1.0-SNAPSHOT</version>
<distributionManagement>
<snapshotRepository>
<id>snapshots</id>
<name>Snapshot Repository</name>
<url>http://my.
horje.org/maven2/snapshots</url>
</snapshotRepository>
</distributionManagement>
<repositories>
<repository>
<id>central</id>
<name>Maven Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>company-snapshots</id>
<name>Company Snapshot Repository</name>
<url>http://my.horje.org/maven2/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</project>
Maven Release RepositoryMaven Release repositories hold releases, while Snapshot repositories store snapshots. Artifacts that have been generated and signed are immediately copied and saved to this separate repository, where they cannot be altered or deleted. Release Repository ensures that the distribution is consistent across target instances. Even if the original artifacts are removed from the original repository, they will remain in the release bundle repository, ready for distribution.
Example of Maven Release Repository:
XML
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.horje</groupId>
<artifactId>my-project</artifactId>
<version>1.0.0</version>
<distributionManagement>
<repository>
<id>releases</id>
<name>Release Repository</name>
<url>http://my.
horje.org/maven2/releases</url>
</repository>
</distributionManagement>
<repositories>
<repository>
<id>central</id>
<name>Maven Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>company-releases</id>
<name>Company Release Repository</name>
<url>http://my.horje.org/maven2/releases</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
Difference Between Maven Snapshot Repository and Release RepositoryBelow is the difference table of Maven Snapshot Repository and Release Repository.
Maven Snapshot Repository
| Maven Release Repository
|
---|
The Maven snapshot version is a version that has not been released yet.
| The Maven release repository mostly contains the final versions of artifacts.
| Snapshot repository for projects still in development.
| Release repositories are for projects that are ready for production.
| Maven Snapshot repositories store snapshots.
| Maven Release repositories hold releases.
| Maven Snapshot, by definition, can be changed.
| The Maven Release Repository can not be changed.
|
|