How do I always use the latest version of a changing module

(Pranav K Varshney) #1


Lets say my module is dependent on artifact ‘A.jar’ with version ‘1.0’. I run my build script, the artifact is downloaded from binary repository and is cached on my machine. If someone updated the same artifact ‘A.jar’ and uploaded it with same version ‘1.0’ in the binary repository. Running build script again does not download the latest artifact. It seems once the artifact for a given version is cached locally build scripts do not try to download it again.

Shouldn’t there be some check (may be based on timestamp and md5sum) if the cached artifact and that available in binary repository are same or not and if different download the latest one.

Regards, Pranav


By default, Gradle treats a module version (eg “myorg:myproj:1.0”) as unchanging over time, allowing us to cache the module meta-data and artifacts indefinitely. If you have a module version that has content (meta-data or artifacts) that can change over time, you can mark the module as ‘changing’.

dependencies {
    compile group: "group", name: "projectA", version: "1.1", changing: true

Normally, Gradle will still cache changing modules for a 24 hour period. You can configure this cache timeout using something like:

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

You can read more about dynamic versions and changing modules here.

(Pranav K Varshney) #3

Thanks Daz,

Is resolutionStrategy.cacheChangingModulesFor available under 1.0-milestone-5?


No, sorry. I should have pointed out that this is a new feature in Milestone 6. In M5, you’ll get no caching at all, so Gradle will check for a new version every time.