0

We have one gradle dependency, that has the same name but is changing a lot, so we want to always get it anew. The dependency is stored in artifactory, and the contents are:

entity-configurator-0.6.2-staging-sources.jar   12-Jun-2019 09:33  110.19 KB
entity-configurator-0.6.2-staging.jar           12-Jun-2019 09:33  147.37 KB
entity-configurator-0.6.2-staging.pom           12-Jun-2019 09:33  3.01 KB

We used the resolution strategy described here https://stackoverflow.com/a/14804849. This is the build.gradle code.

configurations.all {
    resolutionStrategy {
        cacheDynamicVersionsFor 0, "seconds"
        cacheChangingModulesFor 0, "seconds"
    }
}
...
...
compile ('com.***:entity-configurator:0.6.2-staging') { changing = true }

This should force the gradle to always check if the dependency is up to date. Which is probably doing, but not correctly, as when I run

./gradlew build --info

the output is

> Task :compileJava
Cached resource https://artifactory.***.net/artifactory/libs-staging-local/com/***/entity-configurator/0.6.2-staging/entity-configurator-0.6.2-staging.pom is up-to-date (lastModified: Wed Jun 12 11:33:33 CEST 2019).
Cached resource https://artifactory.***.net/artifactory/libs-staging-local/com/***/entity-configurator/0.6.2-staging/entity-configurator-0.6.2-staging.jar is up-to-date (lastModified: Wed Jun 12 12:12:36 CEST 2019).
Skipping task ':compileJava' as it is up-to-date.

In this case, the dependency itself was updated in artifactory, but is not updated in my project after I refresh gradle. The problem here is, they are 2 different parts of the wanted dependency ( the .jar and .pom), and both have different lastModified time.

Cached resource https://artifactory.***.net/artifactory/libs-staging-local/com/***/0.6.2-staging/entity-configurator-0.6.2-staging.pom is up-to-date (lastModified: Wed Jun 12 11:33:33 CEST 2019).

vs

Cached resource https://artifactory.***.net/artifactory/libs-staging-local/com/***/0.6.2-staging/entity-configurator-0.6.2-staging.jar is up-to-date (lastModified: Wed Jun 12 12:12:36 CEST 2019).

The .jar file time of last modified is correct, the pom is apparently from previous version of the dependency. When I check the .gradle/cache folder after refreshing the project, there is the new .jar file, but .pom is still from the previous version. Anybody knows what the problem here is and how to resolve it? I really don't understand why the .pom file is not being updated.

  • I am a Maven guy, so correct me if Gradle has a different philosophy here, but changing an artifact whose version is _not_ ending with `-SNAPSHOT` would cause huge trouble. Maven silently assumes that an artifact with a version like `0.6.2-staging` is built only once, and replacing it is not a good idea. – J Fabian Meier Jun 12 '19 at 11:11
  • That should be resolved by having `{ changing = true }`. It should be the same as postfix -SNAPSHOT, from what I've read. – Bugoš Jozef Jun 12 '19 at 11:47
  • 1
    You can use `gradle clean build --refresh-dependencies`, though this will refresh all dependencies. – Daniele Jun 12 '19 at 18:40
  • @Daniele this command does magic. Thanks! – MoOoG Aug 09 '22 at 08:15

0 Answers0