Dependency caching and update: dynamic, changing, with unreliable maven repository


(rupert THURNER) #1

i am wondering what the reliable strategy is to update a snapshot dependency coming out of a maven repository: * check every 10 minutes * if the maven respository is not reachable, use what is in the cache even if it is older than 10 minutes

i saw “cacheDynamicVersionsFor” and “cacheChangingModulesFor” but i could not find any documentation what a dynamic version or a changing module would be. is -SNAPSHOT automatically “changing” or is it included in “dynamic version”, or is it necessary to state “changing” at the dependency and add "cacheChangingModulesFor 10, ‘minutes’ " ?

i saw: * http://www.gradle.org/docs/current/userguide/dependency_management.html * http://stackoverflow.com/questions/14979856/gradle-dependency-versions-sign * http://www.gradle.org/docs/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html * http://ant.apache.org/ivy/history/latest-milestone/ivyfile/dependency.html * http://forums.gradle.org/gradle/topics/downloading_locally_cached_artifact


#2

A maven SNAPSHOT module is automatically considered a changing module (this does not apply to an ivy module named *-SNAPSHOT). So you don’t need to do anything to tell Gradle that the module is changing, but you do need to configure the cache timeout as you specified.

The complication is that Gradle won’t automatically use what’s in the cache if the timeout has expired and the remote repository is not available. If this is an infrequent case, you could run the build with ‘–offline’ when this occurs. If you need this to be automatically handled, it’s going to be a bit trickier: you’ll probably need to ping the repository separately before resolving…