Gradle dependency cache does not use the latest dynamic version

… even if dependency resolution is configured as follows:

allprojects { configurations { all*.exclude module: 'log4j' all*.exclude module: 'servlet-api' all { resolutionStrategy { resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds' resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
    failOnVersionConflict()
    dependencyVersions.each { force it }
    eachDependency { DependencyResolveDetails details ->
      def forcedVersion = dependencyGroupVersions[details.requested.group]
      if (forcedVersion) {
        details.useVersion forcedVersion
      }
    }
  }
}

}
}

dependencyVersions and dependencyGroupVersions are dependencies defined in the project.

We are using Gradle 2.11, Nexus as artifact repository and do not have snapshot releases.

Even if I specify a fixed version which is newer than the version gradle found, this most recent version does not
seem to be cached. When I switch back to ‘+’ for the dependency the old one is taken into account not the most recent
one stored in the artifact repository.

Maybe someone could shed some light onto this topic.
Thanks in advance!

So it seams to be a caching issue.

If I do the following:

  1. publish a new version of a library to nexus and my local maven repo
  2. refresh dependencies using Idea (or gradlew clean build) in another project that uses this library as dynamic version
  3. -> the dynamic version is resolved to the latest version

If I disable usage of local maven repositories an older version is taken into account.
If I retrieve the latest version from nexus the latest version is returned.
Maven metadata for this library are also correct.

We are using data based versions, i,e
2016-03-16T16-34-43, 2016-03-16T16-38-49, …

Any ideas? Thanks.