How to get gradle to download newer -SNAPSHOTs to .gradle/cache when using an Ivy repository?


(hw.kirk) #1

Will gradle download newer -SNAPSHOTs to .gradle/cache when using an Ivy repository?

This syntax below does work and downloads all the artifacts but does NOT detect NEWER -SNAPSHOT files in the remote repo.

Is there a way to accomplish that objective?

Thanks in advance for any advice

repositories {

ivy { // maven 1 format ?

url “http://spectrum.shawsystems.com/maven

artifactPattern “http://spectrum.shawsystems.com/maven/[organisation]/[ext]s/[artifact]-[revision].[ext]”

} }


#2

Since SNAPSHOTs are a Maven concept, they aren’t treated as anything special in an ‘ivy’ repository. Unfortunately, there’s not (yet) any way to specify a custom pattern for a ‘maven’ repository, so you’re a bit stuck.

The best way to tell Gradle to check for updated versions of a dependency is to flag the dependency as ‘changing’. Gradle will then check for updates every 24 hours, but this can be configured using the resolutionStrategy DSL.

configurations.all {
    // check for updates every build
    resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
  dependencies {
    compile group: "group", name: "projectA", version: "1.1-SNAPSHOT", changing: true
}

(Matias Bjarland) #3

Just out of curiosity, where would I find documentation on the { changing = true } or changing: true syntax? For example, are snapshot releases (in a maven repo) changing = true implicitly and is using a { changing = true } block for them therefore redundant?

The DSL docs at:

http://gradle.org/docs/current/dsl/org.gradle.api.artifacts.dsl.DependencyHandler.html

do not seem to cover this as far as I can tell.

edit: I did find it in the javadocs at:

http://gradle.org/docs/current/javadoc/org/gradle/api/artifacts/ExternalModuleDependency.html

but both the user guide and the DSL reference seem to be lacking it.


(hw.kirk) #4

I have the same question about documentation.


(hw.kirk) #5

Thanks for the Javadoc link.


#6

Doesn’t look like there are any other docs for this important attribute. I agree that both the User Guide and DSL docs would benefit from examples.


(Luke Daley) #7

From a comment on here

is a dependency which has a -SNAPSHOT version already implicitly “{ changing = true }” or are these concepts orthogonal and have nothing to do with each other? I know “changing = true” can be used to force snapshotness for ivy dependencies where as far as I understand ivy does not really support the snapshot concept and we can force the behavior with this setting. Is that the only time we should use “changing true”? The user guide and dsl docs are a bit thin on this specific setting.

If a version number ends in -SNAPSHOT it is implicitly changing when looking for it in a maven repository, because this is a maven convention.

Ivy has not implicit equivalent, so if you have an artifact that can change without it’s content changing and it lives in an ivy repository you want to set ‘changing = true’.


(Matias Bjarland) #8

Thanks Luke.

I can see clearly now, the rain is gone…


(hw.kirk) #9

OK.

Good.

I have resolved the problem of downloading SNAPSHOTs.

Now, the new problem will be (soon) the growing disk space used by having every SNAPSHOT zip in its own SHA1 folder.

Q:

How can I prevent or minimize the use of a SHA1 file for EVERY download?

These are 300MB downloads and will fill the disk quickly…

PS I really like the gradle documentation.

That alone is helping the slow migration from maven.

Thanks!


(Peter Niederwieser) #10

Please create a new forum topic. What exactly is the problem with the sha’s?


(hw.kirk) #11

http://forums.gradle.org/gradle/topics/how_to_minimize_creation_of_cached_sha1_folders_for_uneeded_old_downloads