Reputation: 1868
I have a project with 3 common jars shared across multiple repositories. I'm using Intellij 2019.4. In my gradle build, I included the following method:
dependencyManagement {
resolutionStrategy {
// don't cache SNAPSHOT modules; always retrieve them from the maven cache
cacheChangingModulesFor 0, 'seconds'
}
}
That's supposed to tell Gradle not to cache snapshots, but mine are still being cached. I build and install one of the common jars, and the maven repo has it, but the Gradle cache still has a jar from over 24 hours ago. Is there a different method I should be using? I want Gradle to ALWAYS use what's in the .m2 repo.
Upvotes: 4
Views: 4198
Reputation: 76849
Try to add changing = true
into individual SNAPSHOT
dependencies' configClosure
.
implementation("group:module:1.0-SNAPSHOT") {changing = true}
Then cacheChangingModulesFor
should apply to them:
configurations.all() {
resolutionStrategy {
cacheChangingModulesFor 0, "seconds"
}
}
With version latest.integration
, this would require the build-number added into the version - but, this would keep the build reproducible, since one can switch back to the previous build of the library.
There also is a CLI option --refresh-dependencies
, which refreshes them all.
The Gradle manual explains it, too: Declaring a changing version.
Forcibly deleting them before build would be another option.
Upvotes: 1
Reputation: 14510
Gradle will only search for modules in the declared repositories.
This means that if you need a library, SNAPSHOT
or not, from you local Maven repository, you need to declare it as a repository in Gradle.
repositories {
mavenLocal() {
content {
includeModule("my.org", "someLib")
}
}
// other repositories
}
However, there are caveats in adding mavenLocal()
to your repositories, so make sure to use repository content filtering to only search your local Maven repo for those SNAPSHOT
dependencies, as shown above.
Upvotes: 2