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

Dyi*_*yin 4 versioning scala compilation snapshot sbt

从 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
Run Code Online (Sandbox Code Playgroud)
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)
Run Code Online (Sandbox Code Playgroud)

hub\common_2.12\0.5.0-SNAPSHOT本地.coursier目录下有一个 CHECKED 文件hub,当使用~test:compile.

COURSIER_TTL在 1.3.8 中没有影响。有没有其他方法可以设置 SBT 以经常检查新SNAPSHOT版本?

Mar*_*lic 5

尝试forceUpdatePeriodbuild.sbt

forceUpdatePeriod := Some(5 minutes)
Run Code Online (Sandbox Code Playgroud)

哪个控制

Duration after which to force a full update to occur
Run Code Online (Sandbox Code Playgroud)

因为根据运行的文档update应该可以解决 SNAPSHOT 的问题

显式运行更新。这通常会解决过时的快照或本地发布的工件的问题。


编辑:尝试更新到SBT 1.3.9哪些

更新 lm-coursier-shaded 2.0.0-RC6-2

其中2.0.0-RC6-2公开 TTL 配置

现在可以通过 CoursierConfiguration 调整 TTL、详细级别、校验和和缓存策略,可通过 sbt 中的 csrConfiguration 访问。

因此尝试设置 build.sbt

import scala.concurrent.duration.DurationInt
import lmcoursier.definitions.CachePolicy

csrConfiguration := csrConfiguration.value
  .withTtl(1.minute)
  .withCachePolicies(Vector(CachePolicy.LocalOnly))
Run Code Online (Sandbox Code Playgroud)