andrewe
andrewe

Reputation: 162

Gradle cacheDynamicVersionsFor having no effect

I'm trying to configure Gradle to always pull in the latest version of another project I host on artifactory. On artifactory I have two versions of the library built in the last 24 hours.

In my build.gradle I have

configurations {
    all*.resolutionStrategy {
      cacheDynamicVersionsFor 0, 'seconds'
    }
}

dependencies {
    compile "org:library:+"
}

I expect it to always pull in the latest version of the dynamic dependency, but instead it always pulls in the oldest version in the last 24 hours (the default behaviour). Also, when I delete the most recent cached version, it downloads from artifactory the oldest version in the last 24 hours instead of the latest version.

Upvotes: 1

Views: 1328

Answers (1)

katoquro
katoquro

Reputation: 336

If you are using spring gradle dependency-management-plugin you have to have additional resolution strategy in dependency management section:

dependencyManagement {
    resolutionStrategy {
        cacheDynamicVersionsFor 0, 'seconds'
    }
}

p.s. in any case you should't use groovy spread operator with alias all try to rewrite this in another way (docs):

configurations.all {
    resolutionStrategy {
      cacheDynamicVersionsFor 0, 'seconds'
    }
}

Upvotes: 4

Related Questions