I have a gradle project that has a dependency on another gradle project. The dependency is being published to our in-house nexus server and can be resolved just fine.
Once the dependency has been cached locally I cannot get it to be refreshed unless I pass in --refresh-dependencies to the gradle command (or delete it manually from the cache).
Having searched the internet I found a lot of people with the same problem and the suggestion was to mark the dependency as changing (although this is not strictly necessary as it is implicit from the name -SNAPSHOT) and to add this:
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
however this does not work for me, it will always used the cached version until the gradle default 24 hours is up and then it will re-download it.
Does anyone have any idea what else I may be missing, or how I can diagnose what gradle is doing and why it is not going to nexus to download new versions?
After some trial and error I found that the reason the feature wasn't working as expected was because we were using the spring-boot
plugin. The spring-boot
plugin uses its own dependency management plugin which has its own configuration for the changing modules:
dependencyManagement {
resolutionStrategy {
cacheChangingModulesFor 0, 'seconds'
}
}
Adding this snippet to the gradle file forces changing modules to always be downloaded.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With