Reputation: 734
When publishing snapshots to artifactory/mavenLocal, projects won't pick up the latest snapshot. This requires deleting the jar from ~/.gradle/cache
Maven has a feature to set timestamps for snapshots. how would this work with gradle cache?
Upvotes: 3
Views: 1428
Reputation: 86
There are two things to consider in resolving your issue:
By default, Gradle will refresh a snapshot dependency every 24 hours.
Gradle will automatically recognize a dependency as a snapshot if the version ends with the -SNAPSHOT
suffix. For example:
dependencies {
compile group: "aGroup", name: "anArtifact", version: "1.0-SNAPSHOT"
}
However, if the dependency's version string does not end with -SNAPSHOT
Gradle needs to be told it's a snapshot with the changing
parameter. For example:
dependencies {
compile group: "aGroup", name: "anArtifact", version: "1.0", changing: true
}
The only mechanism for overriding the default 24 hour policy is to configure Gradle to invalidate dependency cache (and thus download a new SNAPSHOT) more frequently. For example:
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
If you're using any dynamic versions, such as:
dependencies {
compile group: "aGroup", name: "anArtifact", version: "1.+", changing: true
}
You'll need to configure cache invalidation for those dependencies separately, like this:
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds'
}
One thing to note is that the shorter the period of time a dependency is cached the more frequently Gradle will retrieve that artifact. If caching is disabled altogether, it will grab the dependency during each execution.
Upvotes: 3