Typically, whenever you run a build that includes a snapshot dependency, Maven will go out to the remote repository(ies), if any, and download the maven-metadata.xml file for that dependency to compare it against the snapshot stored in your local Maven repository to see if there is a newer version that needs to be downloaded. For example, when I run one of our builds, I see this in the build output when there is a newer snapshot version:
Downloading: http://myrepomanager.example.com/artifactory/my-repo/test/artifact/2.2-SNAPSHOT/maven-metadata.xml Downloaded: http://myrepomanager.example.com/artifactory/my-repo/test/artifact/2.2-SNAPSHOT/maven-metadata.xml (766 B at 1.4 KB/sec) Downloading: http://myrepomanager.example.com/artifactory/my-repo/test/artifact/2.2-SNAPSHOT/artifact-2.2-20170406.205529-591.pom Downloaded: http://myrepomanager.example.com/artifactory/my-repo/test/artifact/2.2-SNAPSHOT/artifact-2.2-20170406.205529-591.pom (3 KB at 12.5 KB/sec) Downloading: http://myrepomanager.example.com/artifactory/my-repo/test/artifact/2.2-SNAPSHOT/artifact-2.2-20170406.205529-591.jar Downloaded: http://myrepomanager.example.com/artifactory/my-repo/test/artifact/2.2-SNAPSHOT/artifact-2.2-20170406.205529-591.jar (43 KB at 25.3 KB/sec) And this output when there is not: Downloading: http://myrepomanager.example.com/artifactory/my-repo/test/artifact/2.2-SNAPSHOT/maven-metadata.xml Downloaded: http://myrepomanager.example.com/artifactory/my-repo/test/artifact/2.2-SNAPSHOT/maven-metadata.xml (766 B at 1.7 KB/sec) Whether it downloads and checks the maven-metadata.xml file every time or periodically is (at least somewhat) controlled by the repository declaration in your POM/settings.xml for the repository's updatePolicy. For example, this is what one of our builds uses: <snapshots> <enabled>false</enabled> <updatePolicy>always</updatePolicy> <checksumPolicy>fail</checksumPolicy> </snapshots> -----Original Message----- From: Russell Gold Sent: Friday, April 07, 2017 10:30 AM To: Maven Users List Subject: Re: dependency question That’s the way it works: when you specify a snapshot, it takes the latest. There are some corner cases where it won’t. I think it only checks for a new snapshot every few hours or so, so if you are putting out a lot you might conceivably miss one. You can reset that if you need to . > On Apr 7, 2017, at 11:27 AM, Magnanao, Hector <[email protected]> wrote: > > If the builds for A are always getting a unique build number as a snapshot > build, how am I sure that B will always get the latest snapshot of A ? Is > there a way to name the A snapshot builds with a unique build number each > time for this scenario. > > -----Original Message----- > From: Russell Gold [mailto:[email protected]] > Sent: Thursday, April 6, 2017 2:27 PM > To: Maven Users List <[email protected]> > Subject: Re: dependency question > > The simplest way is simply to use a snapshot version of A. That way B will > always use the latest snapshot. When you finally release A, you can have B > point to the released version instead of the snapshot. > >> On Apr 6, 2017, at 2:52 PM, Magnanao, Hector <[email protected]> wrote: >> >> I have to 2 java projects a and b in maven. The B project uses the A build >> as a dependency. How do I ensure the whenever the A project has a new >> build, the B project will always use that latest build in A. A is being >> built with a unique build number each time it gets built. So is A has build >> # 10 as the newest build, the B project has to use build #10 of A. >> >> >> Hector Magnanao Jr. >> SCM Analyst >> SAP Fieldglass >> Skype: (331) 702-6142 >> Mobile: (847) 857-8401 >> Email: [email protected] >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
