Reputation: 8936
I am trying to use the dynamic versions in gradle for my app as mentioned in the gradle documentation.
But it is not working as expected.
My local nexus has the following library versions.
<metadata>
<groupId>in.test</groupId>
<artifactId>test</artifactId>
<versioning>
<release>1.0.1</release>
<versions>
<version>0.0.2</version>
<version>0.0.3</version>
<version>0.0.7</version>
<version>0.0.8</version>
<version>0.0.9</version>
<version>0.0.10</version>
<version>1.0.0</version>
<version>1.0.1</version>
</versions>
<lastUpdated>20170407231704</lastUpdated>
</versioning>
</metadata>
But when I try to use the dynamic version like below, it always picks 1.0.0 not the 1.0.1.
compile group: "in.test", name: "test", version: "1.0.+"
PS: I read that using dynamic versions is not good for stable build, to know how it exactly works I am trying this out.
Upvotes: 0
Views: 1343
Reputation: 8936
After reading the gradle docs, I found about the dependency caching.
https://docs.gradle.org/current/userguide/userguide_single.html#sec:controlling_caching
Till the cache expiration time, it looks for the best candidate for the dynamic version artifact from cache. After the cache expires it searches in the repository.
If we tell gradle that for dynamic version, always look for the repository not the cache, problem will be solved. I solved this with the below script.
configurations.all {
resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds'
}
Upvotes: 1