Changing module not expired when using Artifactory

Gradle Version: 2.14.1
Operating System: Ubuntu 14.04 LTS
Is this a regression? If yes, which version of Gradle do you know it last worked for? No

I have a library hosted in Artifactory, and I have it marked as changing. Here is the line in the dependent build’s build.gradle:

compile group: "com.<redacted>", name: "common-lib", version: "1.0.0-SNAPSHOT", changing: true

I believe artifactory returns the appropriate Maven metadata, this is the contents of /com/-redacted-/common-lib/1.0.0-SNAPSHOT/maven-metadata.xml:

<metadata>
  <groupId>com.-redacted-</groupId>
  <artifactId>common-lib</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <versioning>
    <snapshot>
      <timestamp>20160811.134233</timestamp>
      <buildNumber>15</buildNumber>
    </snapshot>
    <lastUpdated>20160811134622</lastUpdated>
    <snapshotVersions>
      <snapshotVersion>
        <extension>jar</extension>
        <value>1.0.0-20160811.134233-15</value>
        <updated>20160811134233</updated>
      </snapshotVersion>
      <snapshotVersion>
        <extension>pom</extension>
        <value>1.0.0-20160811.134233-15</value>
        <updated>20160811134233</updated>
      </snapshotVersion>
    </snapshotVersions>
  </versioning>
</metadata>

As you can see, the current snapshot version is “15”

I have the appropriate setting in my build.gradle, and I have tried different variations of this:

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

However, when the build runs, it is hanging on to a stale version - version “12”:

13:44:46.532 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Found cached version of changing module 'com.<redacted>:common-lib:1.0.0-SNAPSHOT' in 'maven'
13:44:46.532 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Using cached module metadata for module 'com.<redacted>:common-lib:1.0.0-SNAPSHOT' in 'maven'
...
13:44:50.493 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver] Loading https://artifactory/artifactory/<repo>/com/<redacted>/common-lib/1.0.0-SNAPSHOT/common-lib-1.0.0-20160810.195434-12.jar
13:44:50.495 [DEBUG] [org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor] Constructing external resource: https://artifactory/artifactory<repo>/com/<redacted>/common-lib/1.0.0-SNAPSHOT/common-lib-1.0.0-20160810.195434-12.jar
13:44:50.496 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Opening cache artifact-at-url.bin (/home/builder/.gradle/caches/modules-2/metadata-2.16/artifact-at-url.bin)
13:44:50.509 [DEBUG] [org.gradle.internal.resource.transport.http.HttpResourceAccessor] Constructing external resource metadata: https://artifactory/artifactory/<repo>/com/<redacted>/common-lib/1.0.0-SNAPSHOT/common-lib-1.0.0-20160810.195434-12.jar
13:44:50.512 [DEBUG] [org.gradle.internal.resource.transport.http.HttpClientHelper] Performing HTTP HEAD: https://artifactory/artifactory/<repo>/com/<redacted>/common-lib/1.0.0-SNAPSHOT/common-lib-1.0.0-20160810.195434-12.jar
...
13:44:51.057 [INFO] [org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor] Cached resource https://artifactory/artifactory/<repo>/com/<redacted>/common-lib/1.0.0-SNAPSHOT/common-lib-1.0.0-20160810.195434-12.jar is up-to-date (lastModified: Wed Aug 10 19:58:28 UTC 2016).
13:44:51.058 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Downloaded artifact 'common-lib.jar (com.<redacted>:common-lib:1.0.0-SNAPSHOT)' from resolver: maven

Note - this build was run Aug 11, so the version is clearly more than 0 seconds old. I am not using the gradle daemon.

Looks like it’s not even attempting to check for a new version. What happens if you use --refresh-dependencies?

FYI, any version string ending in -SNAPSHOT is implicitly treated as changing, no need to explicitly set changing=true in that case.

The behavior looks correct when setting the --refresh-dependencies flag, I think I will use that as a workaround for now. Here is the log output. Note that in this case, the previous build had used SNAPSHOT 18, and it correctly picks up the new build 19:

20:25:43.938 [DEBUG] [io.spring.gradle.dependencymanagement.DependencyManagementContainer] Found managed version '1.0.0-SNAPSHOT' for dependency '-group-:common-lib' in dependency management for configuration 'compileClasspath'
20:25:43.939 [INFO] [io.spring.gradle.dependencymanagement.VersionConfiguringAction] Using version '1.0.0-SNAPSHOT' for dependency '-group-:common-lib:1.0.0-SNAPSHOT'
20:25:43.942 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder] Selecting new module version -group-:common-lib:1.0.0-SNAPSHOT
20:25:43.942 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Attempting to resolve component for -group-:common-lib:1.0.0-SNAPSHOT using repositories [maven, MavenRepo]
20:25:43.947 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Cached meta-data for changing module is expired: will perform fresh resolve of '-group-:common-lib:1.0.0-SNAPSHOT' in 'maven'
20:25:43.948 [DEBUG] [org.gradle.internal.resource.transport.http.HttpResourceAccessor] Constructing external resource: https://artifactory/artifactory/-repo/-group-/common-lib/1.0.0-SNAPSHOT/maven-metadata.xml
20:25:43.948 [DEBUG] [org.gradle.internal.resource.transport.http.HttpClientHelper] Performing HTTP GET: https://artifactory/artifactory/-repo/-group-/common-lib/1.0.0-SNAPSHOT/maven-metadata.xml
20:25:43.968 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Executing request GET /artifactory/-repo/-group-/common-lib/1.0.0-SNAPSHOT/maven-metadata.xml HTTP/1.1
20:25:43.975 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.MavenMetadataLoader] parsing maven-metadata: https://artifactory/artifactory/-repo/-group-/common-lib/1.0.0-SNAPSHOT/maven-metadata.xml
20:25:43.977 [DEBUG] [org.gradle.internal.resource.transport.http.HttpResponseResource] Attempting to download resource https://artifactory/artifactory/-repo/-group-/common-lib/1.0.0-SNAPSHOT/maven-metadata.xml.
20:25:44.004 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver] Loading https://artifactory/artifactory/-repo/-group-/common-lib/1.0.0-SNAPSHOT/common-lib-1.0.0-20160812.202450-19.pom
20:25:44.004 [DEBUG] [org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor] Constructing external resource: https://artifactory/artifactory/-repo/-group-/common-lib/1.0.0-SNAPSHOT/common-lib-1.0.0-20160812.202450-19.pom
20:25:44.007 [DEBUG] [org.gradle.internal.resource.transport.http.HttpResourceAccessor] Constructing external resource metadata: https://artifactory/artifactory/-repo/-group-/common-lib/1.0.0-SNAPSHOT/common-lib-1.0.0-20160812.202450-19.pom
20:25:44.007 [DEBUG] [org.gradle.internal.resource.transport.http.HttpClientHelper] Performing HTTP HEAD: https://artifactory/artifactory/-repo/-group-/common-lib/1.0.0-SNAPSHOT/common-lib-1.0.0-20160812.202450-19.pom
20:25:44.009 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Executing request HEAD /artifactory/-repo/-group-/common-lib/1.0.0-SNAPSHOT/common-lib-1.0.0-20160812.202450-19.pom HTTP/1.1
20:25:44.013 [INFO] [org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor] Found locally available resource with matching checksum: [https://artifactory/artifactory/-repo/-group-/common-lib/1.0.0-SNAPSHOT/common-lib-1.0.0-20160812.202450-19.pom, s/modules-2/files-2.1/-group-/common-lib/1.0.0-SNAPSHOT/8adcb351763e40d25f435b5b91084c0444126a9/common-lib-1.0.0-SNAPSHOT.pom]
20:25:44.023 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] Metadata file found for module '-group-:common-lib:1.0.0-SNAPSHOT:20160812.202450-19' in repository 'maven'.
20:25:44.023 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.modulecache.DefaultModuleMetaDataCache] Recording module descriptor in cache: -group-#common-lib;1.0.0-SNAPSHOT [changing = true]
20:25:44.024 [DEBUG] [org.gradle.api.internal.file.delete.Deleter] Deleting /home/builder/.gradle/caches/modules-2/metadata-2.16/descriptors/-group-/common-lib/1.0.0-SNAPSHOT/646136fc11ce1aa944571ea53e487837/ivy.xml
20:25:44.025 [DEBUG] [org.gradle.api.internal.file.delete.Deleter] Deleting /home/builder/.gradle/caches/modules-2/metadata-2.16/descriptors/-group-/common-lib/1.0.0-SNAPSHOT/646136fc11ce1aa944571ea53e487837/ivy.xml.fslck
20:25:44.026 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Using -group-:common-lib:1.0.0-SNAPSHOT from Maven repository 'maven'

That is odd, the snippet above should have the same effect. I take it that you’ve added it to the build file of the project in question? If this is a multi-project build you may need to put that in an allprojects { } block.

It is not a multi-project build, and it is in the build file of this project.