Gradle does not fetch new SNAPSHOT of dependency


(Sverre Moe) #1

I have now officially moved our new projects to gradle. It builds just like it did with Maven.

However one caveat.
After a change in our API, which also builds with gradle, published to Nexus then now our application using it are getting compile error. It does not seem to use the latest SNAPSHOT of the API.

I have removed a deprecated interface method in the API, but our application is still complaining that this interface method is not implemented.

MyServiceMock is not abstract and does not override abstract methodd serviceCall(boolean,String...) in MyService
public class MyServiceMock implements MyService {

When I was running gradle eclipseClasspath it downloaded the latest SNAPSHOT of the API, but “gradle build” still failed.

I have not run initially run gradle publish of the API locally for this latest change. It was built by our CI and published to Nexus.
I later tried with running gradle publish locally, but it would not solve it.

repositories {
    maven {
        url nexusUrl + "/public"
    }
    mavenLocal()
}

dependencies {
    compile group: 'com.company', name: 'server-api', version:'1.0.0-SNAPSHOT'
}

The only thing that worked was to delete ~/.gradle/caches, but that is not a viable solution. I cannot go into each and every build system and delete the gradle caches. Which I now will have to do (only this once). What about next time, If I cannot rely on Gradle to fetch the latest SNAPSHOT of a dependency. Something seems to be wrong with its caches.

I also had to killed the running Gradle Daemon, because after deleting the cache it failed

Task :compileJava FAILED
Error occurred during initialization of VM
java.lang.InternalError: Could not create SecurityManager: worker.org.gradle.process.internal.worker.child.BootstrapSecurityManager


(Dimitar Dimitrov) #2

Next time use --refresh-dependencies - no need to poke in the cache.


(Sverre Moe) #3

Thanks for that. I looked at gradle --help twice but I must have tunnel vision because I didn’t notice that one.

How can I get gradle to refresh automatically? I am used to this with Maven. I need to be assured that I am building against the latest SNAPSHOT of our API.


(Dimitar Dimitrov) #4

Thereis a property for how long to cache dynamic versions (use google). The default is 24h.

You may stick it in your user properties or in project properties.