使用不同的设置调用TaskKey

时间:2015-09-09 12:09:44

标签: scala sbt sbt-assembly sbt-plugin sbt-0.13

我正在使用插件sbt-assembly(版本0.13.0),我想根据assemblyPackageDependency 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));

0 个答案:

没有答案