0

My Maven project has 2 snapshot dependencies. I need the latest snapshot for dependency A available in the remote repo and at the same time, the version of snapshot dependency B available in my local ~/.m2 repo.

Snapshot depedency B is in the remote repo as well, but my CI job needs to use the locally built instance of this snapshot dependency. Therefore, there is no timestamp on the snapshot so its file path is ~/.m2/repository/groupId/artifactId/1.0.0-SNAPSHOT/artifactId-1.0.0-SNAPSHOT.tar.gz

Due to the split requirement, solutions like --no-snapshot-updates and configuring settings.xml aren't doing the trick.

Any suggestions?

UPDATE: This works by default if the locally generated snapshot is less than 24 hours old. I'm not sure what I had misconfigured during my original experimentation. It turns out that the local version of snapshot B is used since its' filesystem last updated time is less than 24 hours old. Snapshot A does not exist in the local repo so it is fetched from the remote repo as expected.

Jake Hilborn
  • 311
  • 4
  • 8
  • To be honest I don't understand the problem? Is this a multi module build? Or are those two different separate project which are depending on each other ? If you are using Jenkins you could stash artifacts during the build but this sounds like a real issue with your project architecture ? – khmarbaise Feb 10 '19 at 10:11
  • Did my answer help you? – J Fabian Meier Feb 22 '19 at 15:54

3 Answers3

0

Try out timestamp, and you can use 1.0.0 for version.

Check this article: How do I add time-stamp information to Maven artifacts?

rockfarkas
  • 132
  • 2
  • 8
  • Unfortunately the `` doesn't impact the storage of the artifact in the local ~/.m2 repo. `[INFO] Installing /Users/jhilborn/test/target/artifactId-1.0.0-SNAPSHOT-2019-02-06T22:14:48Z-PLEASE-WORK.jar to /Users/jhilborn/.m2/repository/groupId/artifactId/1.0.0-SNAPSHOT/artifactId-1.0.0-SNAPSHOT.jar` The accompanying metadata files in the ~/.m2 sub dir do not contain the timestamped name or PLEASE-WORK suffix either. – Jake Hilborn Feb 06 '19 at 22:18
0

I would change the version of B by adding a suffix: When B is now 2.0.0-SNAPSHOT, make it 2.0.0-LOCAL-SNAPSHOT. If you build and reference B by this version, you can be sure that no remote version of B will interfere with your build.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • Unfortunately this approach won't work for my use case since I need to both deploy the artifact to Nexus and use the same artifact installed to the local ~/.m2 repo. – Jake Hilborn Feb 23 '19 at 02:42
0

This works by default if the locally generated snapshot is less than 24 hours old. I'm not sure what I had misconfigured during my original experimentation. It turns out that the local version of snapshot B is used since its' filesystem last updated time is less than 24 hours old. Snapshot A does not exist in the local repo so it is fetched from the remote repo as expected.

Jake Hilborn
  • 311
  • 4
  • 8