top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What does Maven Snapshot and why do we need it?

+2 votes
271 views
What does Maven Snapshot and why do we need it?
posted Oct 1, 2014 by Amit Kumar Pandey

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

usually in maven we have two types of builds 1)Snapshot builds 2)Release builds

1)snapshot builds:SNAPSHOT is the special version that indicate current deployment copy not like a regular version, maven checks the version for every build in the remote repository so the snapshot builds are nothing but maintainance builds.

2)Release builds:Release means removing the SNAPSHOT at the version for the build, these are the regular build versions.

When you build an application, Maven will search for dependencies in the local repository. If a stable version is not found there, it will search the remote repositories (defined in settings.xml or pom.xml) to retrieve this dependency. Then, it will copy it into the local repository, to make it available for the next builds.

For example, a foo-1.0.jar library is considered as a stable version, and if Maven finds it in the local repository, it will use this one for the current build.

Now, if you need a foo-1.0-SNAPSHOT.jar library, Maven will know that this version is not stable and is subject to changes. That's why Maven will try to find a newer version in the remote repositories, even if a version of this library is found on the local repository. However, this check is made only once per day. That means that if you have a foo-1.0-20110506.110000-1.jar (i.e. this library has been generated on 2011/05/06 at 11:00:00) in your local repository, and if you run the Maven build again the same day, Maven will not check the repositories for a newer version.

Maven provides you a way to can change this update policy in your repository definition:

<repository>
    <id>foo-repository</id>
    <url>...</url>
    <snapshots>
        <enabled>true</enabled>
        <updatePolicy>XXX</updatePolicy>
    </snapshots>
</repository>

where XXX can be:

always: Maven will check for a newer version on every build;
daily, the default value;
interval:XXX: an interval in minutes (XXX)
never: Maven will never try to retrieve another version. It will do that only if it doesn't exist locally. With the configuration, SNAPSHOT version will be handled as the stable libraries.

answer Oct 3, 2014 by Kali Mishra
Similar Questions
+2 votes

Ivy offers the possibility to access maven repositories and download artifacts from there. There are only pom files in those repositories and no ivy.xml.

They can be retrieved with an ivy resolver that runs in m2compatible mode.

<ibiblio name="maven2" m2compatible="true"/>

Especially for this Use-case I want to know:

  1. which scopes are available by default and what artifacts will they offer
  2. How is a maven scoped mapped to an ivy conf / configuration?
...