Gradle not picking up latest library/version from

2019-09-10 03:55发布

问题:

I have project A and B. Project B depends on A.

If I build a snapshot for B, it will trigger a snapshot build on A. The issue is that when the latest snapshot of A gets pushed, B doesn't pick up the latest snapshot. Rather, it picks up the one before that.

Is there any reason why? And can I pull the latest snapshot every time ?

回答1:

If your dependencies do not have the "-SNAPSHOT", you can specifically tell gradle that the dependency is a changing one like this:

dependencies {
    compile group: "group", name: "artifact", version: "1.0", changing: true
}

However even changing dependencies are cached for 24 hours by default. To make sure you will always get the latest one, use:

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