加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

scala – 为什么sbt在清洁后每次都执行依赖解析?

发布时间:2020-12-16 09:39:11 所属栏目:安全 来源:网络整理
导读:即使项目依赖关系管理配置没有改变,SBT也会在每次清理后运行相关性解析。这在CI服务器上运行是耗时的。 但文档says: Normally,if no dependency management configuration has changed since the last successful resolution and the retrieved files are
即使项目依赖关系管理配置没有改变,SBT也会在每次清理后运行相关性解析。这在CI服务器上运行是耗时的。

但文档says:

  1. 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也运行分辨率。

UPDATE2

由于@Ezhik指出,如果我可以保留目标/解析缓存,那么sbt将无法解决依赖关系清理后。
所以我试图从目标目录移动分辨率缓存:

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,Option(lock(app)),Some(resCacheDir),s.log)
      }

现在使用Build.scala解析缓存中的此代码放在项目根目录中,因此在清理后保留,但解决方案仍在进行中。所以我认为这种做法是错误的还是不够的。

解决方法

因为包含常春藤报告的目录目标/解析缓存。显然,清理操作时,您将删除所有目标内容。

如果要保留解析状态,则必须将其指向项目中某处。

更新。

与SBT.0.12.4.RC1

>在IvyConfiguration中查找使用分辨率缓存的位置
>检查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

>修复它在build.sbt。

ivyConfiguration <<= (ivyConfiguration,baseDirectory) map {
  case (c: InlineIvyConfiguration,b) => import c._
    new InlineIvyConfiguration(paths,resolvers,otherResolvers,moduleConfigurations,localOnly,lock,resolutionCacheDir.map(_ => b / "123"),log)
  case (other,_) => other // something unknown
}

4测试…上升…分辨率仍然活跃…调查。 – >

target / scala-2.10 / cache / default-920e5d / global / update / output缓存包含指向resolution-cache的指针:)

>修复它

cacheDirectory <<= baseDirectory / "234"

测试。得到它了。分辨率被跳过。

所需配置的摘要更改:

ivyConfiguration <<= (ivyConfiguration,_) => other // something unknown
}
cacheDirectory <<= baseDirectory / "234"

vs SBT.0.13.x

@deprecated("Use the cacheDirectory provided by streams.","0.13.0")

https://github.com/sbt/sbt/issues/1208

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读