• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Seeking explanation on Maven Snapshot

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a newbie to Maven and I am using internet resources to learn maven. One of my study material that I downloaded from online states that:

In case of Version, if Maven once downloaded the mentioned version say data-service:1.0, it will
never try to download a newer 1.0 available in repository. To download the updated code, data-
service version is be upgraded to 1.1.
In case of SNAPSHOT, Maven will automatically fetch the latest SNAPSHOT (data-service:1.0-
SNAPSHOT) everytime app-ui team build their project.



Let us say that my project depends on project A 1.0-SNAPSHOT. The first time I build my project, maven will download the project A artifact and store it in the local repository. If I am right, the next time I build my project, maven will fetch the artifact from local repository as long as the version of the artifact remains same in my project's pom.xml. So, if it was 1.0-SNAPSHOT when I first built the project and is still the same, maven will fetch the artifact from my local repository. What if the project A has changed in the meantime? Or, am I missing something here?

Please help me to understand this. Thanks in advance.
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are dependent on a snapshot build, ideally, Maven will make sure you local repository is always upto date. So, if the artifact is updated in the remote repository, it will download it to the local repository

It doesn't download artifacts from local repository. The artifacts are used directly from the local repository. They aren't downloaded from the local repository. Here, local repository means the /m2 folder on your machine.
 
Dineshkumar Gnanaprakasam
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would also like to know what would happen if I give some other number instead 1.0 in the "1.0-SNAPSHOT" for the version in my pom.xml
 
Bartender
Posts: 21003
128
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dineshkumar Gnanaprakasam wrote:I would also like to know what would happen if I give some other number instead 1.0 in the "1.0-SNAPSHOT" for the version in my pom.xml



It would pull the latest snapshot for that particular release number. Been there, done that. It helps when the offshore team is working on a different source branch. Where I might be working on v 1.4.3-SNAPSHOT and they're still working on 1.4.2-SNAPSHOT and we plan to all get together when we're ready to integrate for a production build.

If you have a site-wide repository (such as Sonatype Nexus), it can be used to hold snapshot builds. In fact, Nexus has a special repository subtree just for snaphots. Your POM would contain 2 repository definitions in its distributionManagement stanza - one for the primary repository and one for the snapshot repository.

The process for snapshots is essentially the same for any other build. When a dependency is encountered, Maven will check the repository FIRST, and then download to local cache IF the repository artifact is newer than the local artifact. Unless you run Maven with the "-o" (offline) switch.
 
incandescent light gives off an efficient form of heat. You must be THIS smart to ride this ride. Tiny ad:
professionally read, modify and write PDF files from Java
https://products.aspose.com/pdf/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!