Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven automatic SNAPSHOT update

Tags:

maven-2

maven

Let's say I have one project with the following POM:

<groupId>com.mine</groupId> <artifactId>coreJar</artifactId> <packaging>jar</packaging> <version>0.0.1-SNAPSHOT</version> 

And then in another project I always want to reference the latest SNAPSHOT:

<dependencies>      <dependency>         <groupId>com.mine</groupId>         <artifactId>coreJar</artifactId>         <version>0.0.1-SNAPSHOT</version>     </dependency>     ... <dependencies>  

But instead of 0.0.1-SNAPSHOT, I want it to always grab the latest SNAPSHOT version. In the past you could use LATEST, but this has since been deprecated (for reasonable reasons).

I do understand you can specify versions, such as:

[1.5,) 

But I could never get it to work with a "-SNAPSHOT":

[0.0.1,)-SNAPSHOT // Doesn't work! 

The question then is how do I get maven to grab the latest SNAPSHOT in my other project?

like image 402
Stephane Grenier Avatar asked Mar 01 '10 20:03

Stephane Grenier


People also ask

How often does Maven check for snapshot updates?

data-service project is releasing 1.0-SNAPSHOT for every minor change. Although, in case of SNAPSHOT, Maven automatically fetches the latest SNAPSHOT on daily basis, you can force maven to download latest snapshot build using -U switch to any maven command.

What is update snapshots in Maven?

In the command line help, I see that maven "checks" for updates: -U,--update-snapshots Forces a check for updated releases and snapshots on remote repositories. However, most questions on Stack Overflow imply that this option forces Maven to update.

What is force update of snapshots releases?

At this time, the season MM configuration for the module A 2.1-SNAPSHOT version of the dependency, when she component module B, Maven will automatically check from the warehouse module A 2.1-SNAPSHOT the latest component, when found to be updated when the download The By default, Maven checks an update every day ( ...


1 Answers

Another option (which I use) is to include the following in your pom.xml. updatePolicy tag will force maven to always use latest snapshot from this repo.

<repositories>     <repository>         <id>you-snapshots</id>         <url>http://host/nexus/repos/snapshots</url>         <snapshots>             <updatePolicy>always</updatePolicy>         </snapshots>         <releases>             <updatePolicy>always</updatePolicy>         </releases>     </repository> </repositories> 

p.s. I always configure all repos in pom.xml because we use several CI servers and it will be quite hard to configure all of them (I am lazy...)

Doc on settings.xml updatePolicy for reference. The frequency for downloading updates - can be "always", "daily" (default), "interval:XXX" (in minutes) or "never" (only if it doesn't exist locally).

like image 157
Worker Avatar answered Sep 20 '22 21:09

Worker