--refresh-dependencies should fetch from local if newer than remote


(tulsoba) #1

I am using gradle 1.4+artifactory. All my projects build with:

gradle clean --refresh-dependencies install

But it seems that --refresh-dependencies always use artifacts deployed to artifactory even though these might be much older than artifacts in my local .m2 repo.

Would it make sense that --refresh-dependencies uses the latest artifact independently of local vs remote maven repo?


(Luke Daley) #2

The current behaviour is that the first instance of the dependency that is found is used, not the newest.


#3

gradle clean --refresh-dependencies install

Why is it necessary for you to use ‘–refresh-dependencies’ on every build? This will certainly slow things down, and it should be possible for you to use cache timeouts to avoid needing this.

Would it make sense that --refresh-dependencies uses the latest artifact independently of local vs remote maven repo?

I assume you’re referring to a ‘changing module’ (like a Maven snapshot?). As it stands, Gradle has no concept of a ‘newer’ or ‘older’ to differentiate between these modules. The publication date requires inspection of the dependency descriptor (or POM) which would slow things down, and the timestamp reported by an HTTP repository is not really something we can rely on.

One thing that we’d like to do is to treat Maven snapshots as ‘dynamic versions’ instead of ‘changing modules’. This would permit us to differentiate between different snapshots in different repositories, choosing the ‘latest’ (by version number). Our gradual move away from using Ivy under the covers is making this option more feasible, but I don’t have a timeframe for when this will be implemented.

As Luke mentioned, placing ‘mavenCentral()’ higher in your list of repositories may suffice for your needs.