How do I make projects download regularly updated snapshot dependencies reliably?

Our build process includes a great deal of updating a library, and then building a second project (which depends on the first) in order to test them together. For some reason we can’t get the build to check and download the snapshot dependencies.

All of our scripts have the following line included:

configurations.all { resolutionStrategy.cacheChangingModulesFor 0, ‘seconds’ }

Also, we always call our scripts with the --update-dependencies flag.

Could someone please let us know what we’re doing wrong? We’re using Gradle 1.8 connecting to Artifactory.

Have you set the dependencies that you are concerned with to be “changing”? Otherwise, the “cacheChangingModulesFor” directive won’t affect them.

For instance:

dependencies {
  compile("some:module:1.0") { changing = true }
}

–update-dependencies will force it to resolve against the repository, but my understanding is that it will still avoid downloading if the cached artifact matches the resolved artifact in the repository. So it can appear that it is not working (no “downloading” messages) when in fact it is checking the repository and finding no changes from what is already cached and skipping the download.

Building with ‘–refresh-dependencies’ will be enough to always ensure you’re building with the latest. This is heavily tested and works for a great many people so there is probably something else going on.

Try running with ‘–info’. You will see dependency resolution logging output and you should see Gradle checking for updates.

We’ve tried that, but to no avail. Having a version that ends in “-SNAPSHOT” should always result in the changing flag being set to true.

Thanks, Luke. I’ll have to watch the developers over the shoulder and make sure that this is exactly what they’re doing. They report that this is what they’re doing, but that’s no guarantee.

A bit of exploring indicated that the developers weren’t uploading the snapshots to Artifactory in the first place, so I need to retract this question.

No problem.