Get latest snapshot version from Maven Repository in Gradle

I have project which using Gradle to publish our SNAPSHOT artifact's to remote Maven Repository.

When I publish to Maven, time stamp and build number is getting appended to Jar name. And I am trying to download the latest version ie myjar-1.6.0-20170926.190543-10.jar from one of other project. I am not able to download until unless, I remove it from my .gradle or restart my work space.

myjar-1.6.0-20170926.162756-7.jar        
myjar-1.6.0-20170926.162756-7.jar.md5    
myjar-1.6.0-20170926.162756-7.jar.sha1   
myjar-1.6.0-20170926.162756-7.pom        
myjar-1.6.0-20170926.162756-7.pom.md5    
myjar-1.6.0-20170926.162756-7.pom.sha1   
myjar-1.6.0-20170926.182639-8.jar        
myjar-1.6.0-20170926.182639-8.jar.md5    
myjar-1.6.0-20170926.182639-8.jar.sha1   
myjar-1.6.0-20170926.182639-8.pom        
myjar-1.6.0-20170926.182639-8.pom.md5    
myjar-1.6.0-20170926.182639-8.pom.sha1   
myjar-1.6.0-20170926.182748-9.jar        
myjar-1.6.0-20170926.182748-9.jar.md5    
myjar-1.6.0-20170926.182748-9.jar.sha1   
myjar-1.6.0-20170926.182748-9.pom        
myjar-1.6.0-20170926.182748-9.pom.md5    
myjar-1.6.0-20170926.182748-9.pom.sha1   
myjar-1.6.0-20170926.190543-10.jar       
myjar-1.6.0-20170926.190543-10.jar.md5   
myjar-1.6.0-20170926.190543-10.jar.sha1  
myjar-1.6.0-20170926.190543-10.pom       
myjar-1.6.0-20170926.190543-10.pom.md5   
myjar-1.6.0-20170926.190543-10.pom.sha1  

The dependency project has below

configurations.all {
  resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds'
  resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}

 compile ( group: "com.test", name:"myjar", version: "1.6.0-SNAPSHOT", changing: true ); 

Also tried with

compile ( "com.test:myjar:latest.integration); 

But nothing working out. Let me know how to fix this?

Upvotes: 3

Views: 5024

Answers (2)

TTKatrina
TTKatrina

Reputation: 541

I encounter the same situation as you.

  • Develop environment: Android Studio 4.0
  • Building tools: gradle 3.6
  • Computer: Mac

I'm at app end, while I am using a jar from server end, the jar is included by adding maven repo and adding project dependency in build.gradle, like this:

buildscript {
repositories {
    mavenLocal()
    maven { url 'http://maven.xxx.com/xxx/xxx/‘ }        
 }}
dependencies {
   ...
   implementation ‘project_group_id:artifact_id:latest.integration’
   }

Instead of using ./gradlew build --refresh-dependencies to clear cache, I directly went to the cache folder /Users/your_user_name/.gradle/caches/modules-2/files-2.1 and delete the local jar in order to download updated one.

But still failed...

Finally we found the cause is weird: we included several maven repo, one repo has the same project as the one we need, but it has only one version for each version code.It is in front of the maven repo from which we can download newest jar, therefore it blocked the update of the newest version. We exchange the sequence of these two repo, and the problem disappear.

In my case, it's nothing to do with the maven config or the cache, it is due to repo included in gradle. Further reason still need to dig.

Hope can help the ones who meet the same problem.

Upvotes: 1

Guenther
Guenther

Reputation: 2045

You can run the local build with --refresh-dependencies. See the answers to this question How can I force gradle to redownload dependencies? for more information.

Upvotes: 0

Related Questions