通过这段摘录,我尝试使用来自设置的一些预先应用的输入创建第二个inputKey:
val foo = inputKey[Unit]("....")
foo := { ... }
val foo2 = inputKey[Unit]("....")
foo2 := {
foo.partialInput(" "+name.value).evaluated
}
但是我收到了Illegal dynamic reference
错误,因为如果我使用partialInput
,evaluated
的参数必须是常量。
解决这个问题的最佳方法是什么?
类似的问题,我以前读过:
使用SBT 0.13.7。
此示例中显示的技术取自SBT参考文档不起作用:
lazy val run2 = inputKey[Unit]("Runs the main class twice: " +
"once with the project name and version as arguments"
"and once with command line arguments preceded by hard coded values.")
// The argument string for the first run task is ' <name> <version>'
lazy val firstInput: Initialize[String] =
Def.setting(s" ${name.value} ${version.value}")
// Make the first arguments to the second run task ' red blue'
lazy val secondInput: String = " red blue"
run2 := {
val one = (run in Compile).fullInput(firstInput.value).evaluated
val two = (run in Compile).partialInput(secondInput).evaluated
}