2

For a REST service environment I am writing the REST server application along with a client library in order to use the same model objects on server and client side.

For local development it would be great if I could include the latest build SNAPSHOT from my local maven repository as current version.

In my pom.xml I have

<dependency>
    <groupId>com.mygroup</groupId>
    <artifactId>backoffice-client</artifactId>
    <version>LATEST</version>
</dependency>

My local repository holds versions 1.0.0-SNAPSHOT, 1.0.0 and 1.0.1-SNAPSHOT.

The imported version in this case is 1.0.0 but I would expect it to be 1.0.1-SNAPSHOT.

On gradle this is working by using compile(com.mygroup:backoffice-client:+).

I already tried setting -DignoreSnapshots=false on maven command line without success.

What can I do to get the latest snapshot from my local repository loaded properly?

Dero
  • 309
  • 1
  • 2
  • 17
  • I would look at this answer using the version-plugin: https://stackoverflow.com/questions/30571/how-do-i-tell-maven-to-use-the-latest-version-of-a-dependency/1172805#1172805 – trappski Aug 23 '18 at 10:42
  • The `LATEST` is long time deprecated and should not used anymore.... – khmarbaise Aug 23 '18 at 12:34

2 Answers2

1

That's because your are using the word SNAPSHOT, which is a keyword for Maven.

As described here, Maven treats the SNAPSHOT qualifier differently from all others. If a version number is followed by -SNAPSHOT, then Maven considers it the "as-yet-unreleased" version of the associated MajorVersion, MinorVersion, or IncrementalVersion.

So for Maven the "snapshot" is not the latest stable release, which is the one that is looking for when you tell him to take the latest release.

Leviand
  • 2,745
  • 4
  • 29
  • 43
  • 1
    I read this part but didn't realize that `LATEST` requires a stable release. Is there a way to tell maven to cover unstable releases as well? – Dero Aug 23 '18 at 10:41
  • Not with the LATEST keyword, you have to specify that version into the version number into your pom, as said by @Damith in his answer – Leviand Aug 23 '18 at 10:42
1

Your workaround is add the exact version number to your dependency.

<dependency>
    <groupId>com.mygroup</groupId>
    <artifactId>backoffice-client</artifactId>
    <version>1.0.1-SNAPSHOT</version>
</dependency>

for the question why its not automatically loaded when you add LATEST, @Leviand's explanation is correct.

Damith
  • 740
  • 4
  • 12