我想在执行gulp
命令时自动运行sbt test
命令。
为此,我将以下代码添加到我的build.sbt
文件中:
lazy val cleanWebAssetsTask = TaskKey[Unit]("cleanWebAssets", "Clean web assets with gulp")
cleanWebAssetsTask := {
"gulp --cwd rest_project clean" !
}
lazy val buildWebAssetsTask = TaskKey[Unit]("buildWebAssets", "Build web assets with gulp")
buildWebAssetsTask := {
"gulp --cwd rest_project build" !
}
lazy val testWebAssetsTask = TaskKey[Unit]("testWebAssets", "Run JavaScript tests with gulp")
testWebAssetsTask := {
"gulp --cwd rest_project test" !
}
// This does not work
test <<= test dependsOn testWebAssetsTask
// This works fine
clean <<= clean dependsOn cleanWebAssetsTask
dist <<= dist dependsOn buildWebAssetsTask
但是我收到以下错误: 参考未定义的设置:
rest_project/*:test from rest_project/*:test (/Users/ivanmushketyk/Development/project/rest_project-rest/build.sbt:41)
Did you mean rest_project/web-assets-test:test ?
at sbt.Init$class.Uninitialized(Settings.scala:270)
at sbt.Def$.Uninitialized(Def.scala:10)
at sbt.Init$class.delegate(Settings.scala:191)
at sbt.Def$.delegate(Def.scala:10)
at sbt.Init$class.compiled(Settings.scala:138)
at sbt.Def$.compiled(Def.scala:10)
at sbt.Init$class.make(Settings.scala:144)
at sbt.Def$.make(Def.scala:10)
at sbt.Load$$anonfun$8.apply(Load.scala:161)
at sbt.Load$$anonfun$8.apply(Load.scala:156)
at sbt.Load$.timed(Load.scala:1025)
at sbt.Load$.apply(Load.scala:156)
at sbt.Load$.defaultLoad(Load.scala:39)
at sbt.BuiltinCommands$.liftedTree1$1(Main.scala:548)
at sbt.BuiltinCommands$.doLoadProject(Main.scala:548)
at sbt.BuiltinCommands$$anonfun$loadProjectImpl$2.apply(Main.scala:540)
at sbt.BuiltinCommands$$anonfun$loadProjectImpl$2.apply(Main.scala:540)
at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:59)
at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:59)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)
at sbt.Command$.process(Command.scala:93)
at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:96)
at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:96)
at sbt.State$$anon$1.doX$1(State.scala:183)
at sbt.State$$anon$1.process(State.scala:190)
at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:96)
at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:96)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.MainLoop$.next(MainLoop.scala:96)
at sbt.MainLoop$.run(MainLoop.scala:89)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:68)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:63)
at sbt.Using.apply(Using.scala:24)
at sbt.MainLoop$.runWithNewLog(MainLoop.scala:63)
at sbt.MainLoop$.runAndClearLast(MainLoop.scala:46)
at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:30)
at sbt.MainLoop$.runLogged(MainLoop.scala:22)
at sbt.StandardMain$.runManaged(Main.scala:109)
at sbt.xMain.run(Main.scala:38)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
at xsbt.boot.Launch$.run(Launch.scala:109)
at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
at xsbt.boot.Launch$.launch(Launch.scala:117)
at xsbt.boot.Launch$.apply(Launch.scala:18)
at xsbt.boot.Boot$.runImpl(Boot.scala:41)
at xsbt.boot.Boot$.main(Boot.scala:17)
at xsbt.boot.Boot.main(Boot.scala)
[error] Reference to undefined setting:
[error]
[error] rest_project/*:test from rest_project/*:test (/Users/ivanmushketyk/Development/project/rest_project/build.sbt:41)
[error] Did you mean rest_project/web-assets-test:test ?
这是否意味着我需要使用rest_project/web-assets-test:test
任务?如果是,如何访问它?