Gradle不会从工件回购中提取最新版本吗? [英] Gradle does not pull latest version from artifact repo?
问题描述
$ ./gradlew -v
Gradle 3.4.1
我知道旧的Gradle版本,但这是另一篇文章.
Old Gradle version, I know, but that's a different post.
我们在 build.gradle
文件中具有这样的依赖关系
We have a dependency in our build.gradle
file like this
dependencies {
compile("com.company.myservice:myservice-client:10.+")
}
我注意到有时有时无法从存储库(在我们的例子中为Nexus)中获取最新版本.换句话说,,如果我们将 myservice-client-10.9.0.jar
推送到我们的仓库中,然后运行具有上述依赖关系的构建,我们将使用和更早的版本缓存中的版本,例如 10.8.x
.为什么是这样?我知道我可以使用-refresh-dependencies
,但我不必纠正吗?
I'm noticing that sometimes, the latest version is NOT fetched from the repository (Nexus in our case). In other words, if we push myservice-client-10.9.0.jar
to our repo, and then we run a build that has the dependency above, we use and older version, e.g., 10.8.x
that is in cache. Why is this? I know I can use --refresh-dependencies
but I should not have to correct?
推荐答案
您说有时"时,可能是在上一次更新检查后的24小时内,如 Gradle默认将动态模块缓存24小时.如果要在24小时之前执行更新检查,则确实需要使用-refresh-dependencies
.
When you say "sometimes", that's probably within 24 hours of the last update check, as by default, Gradle caches dynamic modules for 24 hours. If you want to enforce an update check before 24 hours have passed, you indeed need to use --refresh-dependencies
.
或者您可以减少这样的时间(将解析的版本缓存到Kotlin DSL中):
Or you lower the time for how long resolved versions will be cached like this (in Kotlin DSL):
configurations.all {
resolutionStrategy.cacheDynamicVersionsFor(10, "minutes")
}
这篇关于Gradle不会从工件回购中提取最新版本吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!