scala - 即使在增量编译中,SBT 1.3.8 也会自动更新 SNAPSHOT 版本

标签 scala compilation sbt versioning snapshot

从 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/

相关文章:

list - 为什么Buffer和List对象相等(即使它们来自不同的类)?

scala - Scala中的函数对象的varargs错误?

java - 文本域监听器

scala - Scala 中的增量编译速度是否取决于每个文件的类数?

scala - 如何将Scala案例类定义转换为Haskell?

C++ boost compilation 灾难

c++ - 没有在C++枚举上命名的类型

scala:在 Ubuntu 12.04 上初始化 VM 时发生错误

scala - IntelliJ : what difference between "SBT Console" and "SBT Shell"?

sbt - 为什么在 Play 2.3 项目中编译 sbt 后,sbt 会失败并显示 NoClassDefFoundError : play/Play$ in Play 2. 2.x 项目?