从 SBT 1.3.0 开始,Coursier 是默认解析器引擎,因此我们从依赖项中删除了 Coursier SBT 插件。
在 Coursier-plugin 时代,我们使用了 COURSIER_TTL="5 min"
控制频率 SNAPSHOT
版本应该自动获取,即使是在 sbt ~test:compile
时在开发过程中使用。
对于依赖项 SNAPSHOT
项目,这里是输出:
sbt:hub> show isSnapshot
[info] common / isSnapshot
[info] true
[info] isSnapshot
[info] true
sbt:hub> show packagedArtifacts
[info] Wrote C:\Users\Ehnalis\Projects\hub\common\target\scala-2.12\common_2.12-0.5.0-SN
APSHOT.pom
[info] Wrote C:\Users\Ehnalis\Projects\hub\target\scala-2.12\hub_2.12-0.5.0-SNAPSHOT.pom
[info] common / packagedArtifacts
[info] Map(Artifact(common, jar, jar, None, Vector(compile), None, Map(), None, false)
-> C:\Users\Ehnalis\Projects\hub\common\target\scala-2.12\common_2.12-0.5.0-SNAPSHOT.jar
, Artifact(common, src, jar, Some(tests-sources), Vector(test), None, Map(), None, false
) -> C:\Users\Ehnalis\Projects\hub\common\target\scala-2.12\common_2.12-0.5.0-SNAPSHOT-t
ests-sources.jar, Artifact(common, jar, jar, Some(tests), Vector(test), None, Map(), Non
e, false) -> C:\Users\Ehnalis\Projects\hub\common\target\scala-2.12\common_2.12-0.5.0-SN
APSHOT-tests.jar, Artifact(common, src, jar, Some(sources), Vector(compile), None, Map()
, None, false) -> C:\Users\Ehnalis\Projects\hub\common\target\scala-2.12\common_2.12-0.5
.0-SNAPSHOT-sources.jar, Artifact(common, pom, pom, None, Vector(pom), None, Map(), None
, false) -> C:\Users\Ehnalis\Projects\hub\common\target\scala-2.12\common_2.12-0.5.0-SNA
PSHOT.pom)
[info] packagedArtifacts
[info] Map(Artifact(hub, src, jar, Some(sources), Vector(compile), None, Map(), None, f
alse) -> C:\Users\Ehnalis\Projects\hub\target\scala-2.12\hub_2.12-0.5.0-SNAPSHOT-sources
.jar, Artifact(hub, jar, jar, Some(tests), Vector(test), None, Map(), None, false) -> C:
\Users\Ehnalis\Projects\hub\target\scala-2.12\hub_2.12-0.5.0-SNAPSHOT-tests.jar, Artifac
t(hub, jar, jar, None, Vector(compile), None, Map(), None, false) -> C:\Users\Ehnalis\Pr
ojects\hub\target\scala-2.12\hub_2.12-0.5.0-SNAPSHOT.jar, Artifact(hub, src, jar, Some(t
ests-sources), Vector(test), None, Map(), None, false) -> C:\Users\Ehnalis\Projects\hub\
target\scala-2.12\hub_2.12-0.5.0-SNAPSHOT-tests-sources.jar, Artifact(hub, pom, pom, Non
e, Vector(pom), None, Map(), None, false) -> C:\Users\Ehnalis\Projects\hub\target\scala-
2.12\hub_2.12-0.5.0-SNAPSHOT.pom)
在
hub\common_2.12\0.5.0-SNAPSHOT
下有一个 CHECKED 文件在本地 .coursier
目录,并且在另一个依赖于 hub
的项目中更改代码时不会更新, 同时使用 ~test:compile
.COURSIER_TTL
在 1.3.8 中没有影响。有没有其他方法可以设置 SBT 经常检查新的 SNAPSHOT
版本?
最佳答案
尝试设置 forceUpdatePeriod
持续时间 build.sbt
forceUpdatePeriod := Some(5 minutes)
哪个控制
Duration after which to force a full update to occur
因为根据 docs运行
update
应该解决 SNAPSHOT 的问题Run update explicitly. This will typically fix problems with out of date SNAPSHOTs or locally published artifacts.
编辑:尝试更新到 sbt 1.3.9哪一个
Updates to lm-coursier-shaded 2.0.0-RC6-2
哪里2.0.0-RC6-2公开 TTL 配置
One can now adjust the TTL, the verbosity level, the checksums, and the cache policies via CoursierConfiguration, accessible via csrConfiguration in sbt.
因此尝试在
build.sbt
中设置import scala.concurrent.duration.DurationInt
import lmcoursier.definitions.CachePolicy
csrConfiguration := csrConfiguration.value
.withTtl(1.minute)
.withCachePolicies(Vector(CachePolicy.LocalOnly))
关于scala - 即使在增量编译中,SBT 1.3.8 也会自动更新 SNAPSHOT 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60723139/