Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get newest snapshot of a dependency without changing version in gradle?

Tags:

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?

like image 918
n00bst3r Avatar asked Feb 05 '17 23:02

n00bst3r


People also ask

How do I refresh Gradle dependencies?

Simply open the gradle tab (can be located on the right) and right-click on the parent in the list (should be called "Android"), then select "Refresh dependencies". This should resolve your issue.

What is snapshot in Gradle?

An example of this type of changing module is a Maven SNAPSHOT module, which always points at the latest artifact published. In other words, a standard Maven snapshot is a module that is continually evolving, it is a "changing module". Using dynamic versions and changing modules can lead to unreproducible builds.


1 Answers

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.

like image 187
MartinTeeVarga Avatar answered Sep 19 '22 20:09

MartinTeeVarga