Gradle How can I specify the cacheResolutionStrategy for the SNAPSHOT version in my buildscript block?

I am having trouble resolvingStrategy.cacheChangingModulesFor.

My build.gradle project is like 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?

+3


source to share


1 answer


specifying it outside the block does not work (since the buildscript block is evaluated first to generate scripts ...), so the caching strategy rules defined in the scripts have not been evaluated yet.

resolution strategy should be put in 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'
  }
}

      

+6


source







All Articles