我正在使用插件sbt-assembly
(版本0.13.0),我想根据assemblyPackageDependency
1}将appendContentHash
与InputKey
联系起来lazy val isGlobalCached = InputKey[Boolean]("")
lazy val myTask = taskKey[sbt.File]("myTask")
myTask := {
if (isGlobalCached.value)
//run with the modified assemblyOption
//assemblyOption in assemblyPackageDependency ~= { x => x.copy(appendContentHash = true) }
assemblyPackageDependency.value
else
assemblyPackageDependency.value
}
p>
基本上,我想做这样的事情:
assemblyOption
但我不知道如果条件为真,而不是全局
,如何设置lazy val isGlobalCached = InputKey[Boolean]("")
lazy val myTask = taskKey[sbt.File]("myTask")
lazy val assemblyPackageDependencyWithHash = taskKey[sbt.File]("assemblyPackageDependencyWithHash")
assemblyPackageDependencyWithHash <<= assemblyPackageDependency
assemblyOption in assemblyPackageDependencyWithHash ~= { x => x.copy(appendContentHash = true) }
myTask := {
//run with the modified assemblyOption
if (isGlobalCached.value)
assemblyPackageDependencyWithHash.value
else
assemblyPackageDependency.value
}
以下是我试过的一些不起作用的事情:
lazy val isGlobalCached = InputKey[Boolean]("")
lazy val myTask = taskKey[sbt.File]("myTask")
lazy val globalCacheConf = config("globalCacheConf")
assemblyOption in globalCacheConf := (assemblyOption in assemblyPackageDependency).value.copy(appendContentHash = true)
myTask := {
//run with the modified assemblyOption
if (isGlobalCached.value)
assemblyPackageDependency.in(globalCacheConf).value
else
assemblyPackageDependency.value
}
和
a.push(ts.Read(1));