I am having problems with resolutionStrategy.cacheChangingModulesFor.
My project build.gradle looks similar to this
apply plugin: 'base'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply from: "gradle/mixins/cachestrategy.gradle"
configurations.all {
resolutionStrategy.cacheDynamicVersionsFor 5, 'minutes'
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
buildscript {
repositories {
maven {
url artifactoryUrl
}
}
dependencies {
classpath (group: 'com.myorg', name: 'aCustomPlugin', version: '1.5.0-SNAPSHOT') {
changing = true
}
}
}
allprojects {
apply plugin: 'base'
apply plugin: 'com.myorg.aCustomPlugin'
}
my question is: How can i specify the cacheResolutionStrategy for the SNAPSHOT version in my buildscript block?
If the project requires a specific version of a dependency on a configuration-level then it can be achieved by calling the method ResolutionStrategy. force(java. lang. Object[]).
The buildScript block determines which plugins, task classes, and other classes are available for use in the rest of the build script. Without a buildScript block, you can use everything that ships with Gradle out-of-the-box.
To refresh all dependencies in the dependency cache, use the --refresh-dependencies option on the command line. The --refresh-dependencies option tells Gradle to ignore all cached entries for resolved modules and artifacts.
specifying it outside the block, doesn't work (since the buildscript block is evaluated first, in order to build the scripts... ) so the cache strategy rules defined in the scripts haven't been evaluated yet.
the resolution strategy should be placed in the buildscript block like this
buildscript {
repositories {
mavenLocal()
maven {
url artifactoryUrl
}
}
dependencies {
classpath (group: 'com.myorg', name: 'aCustomPlugin', version: '1.5.0-SNAPSHOT') {
changing = true
}
}
configurations.all {
resolutionStrategy.cacheDynamicVersionsFor 5, 'minutes'
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
}
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