Reputation: 647
I build an own library that I deploy on a nexus repository. This snapshot is changed very often, therefore not every change gets a new version number. My problem is that I don't get the newest code without changing the version number in project that use this library. I tried "--refresh-dependencies" and I also tried to clear the dependency from the cache by deleting the folder of this dependency under "\caches\modules-2\files-2.1\my.dependency"
I also tried this:
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
Has anyone an idea how I can force grade to download the newest status of a dependency despite the version number didn't change?
Upvotes: 29
Views: 40426
Reputation: 20521
You can use
./gradlew --refresh-dependencies run
to start the application and refresh all dependencies.
Source: https://docs.gradle.org/current/userguide/dynamic_versions.html (via a comment above by @Dmitriy Pichugin).
The --refresh-dependencies option tells Gradle to ignore all cached entries for resolved modules and artifacts.
Upvotes: 5
Reputation: 10898
First make sure your snapshot has the right version format:
dependencies {
compile group: "groupId", name: "artifactId", version: "1.0-SNAPSHOT"
}
If you have not used the -SNAPSHOT
suffix (or you are not using a Maven repository), you have to indicate that your dependency is changing:
dependencies {
compile group: "groupId", name: "artifactId", version: "1.0", changing: true
}
Then you have to tell Gradle not to cache changing dependencies, otherwise it will only update them every 24 hours:
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
In case you have also configured the dependency as a dynamic version like this:
dependencies {
compile group: "groupId", name: "artifactId", version: "1+", changing: true
}
Then you have to add:
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds'
}
Note that this might slow your build a lot.
If this doesn't help, remove the relevant parts of .gradle
directory, or simply the whole directory again.
If that doesn't help neither, I am afraid it will be an issue on your repository side.
Upvotes: 60