SBT 在 clean
之后每次都运行依赖项解析即使项目依赖管理配置没有改变。在 CI 服务器上运行时,这很耗时。
但是文档says :
- Normally, if no dependency management configuration has changed since the last successful resolution and the retrieved files are still present, sbt does not ask Ivy to perform resolution.
每次使用
sbt clean publish-local
构建项目时,如何阻止 sbt 执行依赖项解析?
更新
我发现当我使用
sbt
进入交互模式时,sbt 也会运行分辨率。 .
更新 2
如
@Ezhik
指出如果我可以保留
target/resolution-cache
那么 sbt 将不会在清理后解析依赖项。
所以我试着移动
resolution-cache
从目标目录输出:
ivyConfiguration <<= (externalResolvers, ivyPaths, offline, checksums, appConfiguration, target, streams) map { (rs, paths, off, check, app, t, s) =>
val resCacheDir = t / ".." / "resolution-cache"
new InlineIvyConfiguration(paths, rs, Nil, Nil, off, Option(lock(app)), check, Some(resCacheDir), s.log)
}
现在在
Build.scala
中使用此代码分辨率缓存放置在项目根目录中,因此在
clean
之后保留,但无论如何都在解决。所以我认为这种方法是错误的或不足的。
请您参考如下方法:
因为目录target/resolution-cache
包含 Ivy 报告。很明显你删除了所有target
内容同时 clean
手术。
恕我直言,您必须在您的项目中将其指向 target
以外的某个地方。如果要保留分辨率状态。
更新。
对比 SBT.0.12.4.RC1
resolution-cache
用于 - 在 IvyConfiguration > inspect ivy-configuration
[info] Task: sbt.IvyConfiguration
[info] Description:
[info] General dependency management (Ivy) settings, such as the resolvers and paths to use.
[info] Provided by:
[info] {file:/home/ezh/projects/sbt/}xsbt/*:ivy-configuration
[info] Dependencies:
[info] xsbt/*:offline
ivyConfiguration <<= (ivyConfiguration, baseDirectory) map {
case (c: InlineIvyConfiguration, b) => import c._
new InlineIvyConfiguration(paths, resolvers, otherResolvers, moduleConfigurations,
localOnly, lock, checksums, resolutionCacheDir.map(_ => b / "123"), log)
case (other, _) => other // something unknown
}
4 测试... Ups... 分辨率仍然有效... 调查。 ->
target/scala-2.10/cache/default-920e5d/global/update/output
缓存包含指向
resolution-cache
的指针:)
cacheDirectory <<= baseDirectory / "234"
测试。知道了。分辨率被跳过。
所需配置的摘要更改:
ivyConfiguration <<= (ivyConfiguration, baseDirectory) map {
case (c: InlineIvyConfiguration, b) => import c._
new InlineIvyConfiguration(paths, resolvers, otherResolvers, moduleConfigurations,
localOnly, lock, checksums, resolutionCacheDir.map(_ => b / "123"), log)
case (other, _) => other // something unknown
}
cacheDirectory <<= baseDirectory / "234"
对比 SBT.0.13.x
@deprecated("Use the cacheDirectory provided by streams.", "0.13.0")
https://github.com/sbt/sbt/issues/1208