【发布时间】:2015-07-08 13:49:10
【问题描述】:
我重新定义了我的测试以提供一些从配置到测试套件的参数:
这是我的 Build.scala 的摘录:
object Build extends Build {
lazy val myProject = (project in file("my_project")).settings(
test in Test := myProjectTest.value
)
val myProjectTest = Def.task {
(testOnly in Test).toTask(" tests.Suites -- " +
s"-Ddbserver=localhost " +
s"-Ddbport=3306 ").value
}
}
这没问题。
现在,我想给我的测试套件起一个这样的工件名称:
val myProjectTest = Def.task {
val art = (Keys.artifactPath in (Compile, packageBin)).value
(testOnly in Test).toTask(" tests.Suites -- " +
s"-Dartifact=${art.getCanonicalPath} " +
s"-Ddbserver=localhost " +
s"-Ddbport=3306").value
}
但它显示以下错误消息:
[error] /tmp/aa/project/Build.scala:17: Illegal dynamic reference: art
[error] s"-Dartifact=${art.getCanonicalPath} " +
[error] ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
我了解一些关于 SBT 内部结构、宏、任务依赖图的知识,我什至设法使用范围解决了我的一些任务。在这里,我尝试在(Keys.artifactPath in (Compile, packageBin)) 上使用 map 或 flatMap 但无法达到预期的结果。每当我尝试访问.value 时,我都会得到Illegal dynamic reference。
请指导我。我只需要将任务的值传递给其他任务(inputKey)参数即可。
SBT 版本:0.13.5
【问题讨论】:
-
编写有效且有助于重现问题的代码将极大地帮助您解决问题。
-
这是代码。我不期望任何研究工作,任何编写自定义构建的 sbt 用户宁愿找到足够的信息。顺便说一句,你的反对票降低了我得到快速答复的机会。