I'm using SBT with Play Framework.
I created a custom TaskKey
to run JavaScript tests in my project:
import sbt._
import sbt.Process._
import PlayProject._
object ApplicationBuild extends Build {
val testJsTask = TaskKey[Unit]("testJs", "Run javascript tests.") := {}
val main = PlayProject("xxx", 1.0, Seq())
.settings(defaultScalaSettings: _*)
.settings(testJsTask)
}
So far so good.
I want to run this testJsTask
always when someone executes the test
task.
I guess it should be something as follows:
test in Test <<= (test in Test).dependsOn(testJsTask)
I've no idea how it should be defined exactly. How to add a dependency to an existing task like 'test' or 'build'?
UPDATE
After changes proposed by @Christian the build definition looks as follows:
object ApplicationBuild extends Build {
val testJsTask = TaskKey[Unit]("testJs", "Run tests for javascript client.")
def testJs = {}
val main = PlayProject("xxx", 1.0, Seq())
.settings(defaultScalaSettings: _*)
.settings(testJsTask := testJs)
(test in Test) <<= (test in Test) dependsOn (testJs)
}
Unfortunately, the solution doesn't work either:
[error] /xxx/project/Build.scala:21: not found: value test
[error] (test in Test) <<= (test in Test) dependsOn (testJs)
[error] ^
[error] one error found
[error] {file:/xxx/project/}default-f468ae/compile:compile: Compilation failed
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…