我想在Play 2.3应用程序编译之前运行自定义任务。 在我的build.sbt
文件中,我有以下内容:
lazy val helloTask = TaskKey[Unit]("hello", "hello")
helloTask := {
println("hello test")
}
(compile in Compile) <<= (compile in Compile) dependsOn helloTask
当我运行
activator ~run
然后在浏览器中打开页面时,我会得到以下输出:C:\Development\test>activator ~run
[info] Loading project definition from C:\Development\test\project
[info] Set current project to play (in build file:/C:/Development/test/)
--- (Running the application from SBT, auto-reloading is enabled) ---
[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
(Server started, use Ctrl+D to stop and go back to the console...)
hello test
[success] Compiled in 418ms
hello test
hello test
[info] play - Application started (Dev)
似乎我的自定义任务运行了三次。有没有办法可以避免这种情况?
compile
两次。 我要报告一个问题。 - Jacek LaskowskitaskKey
来定义一个新任务 -lazy val hello = taskKey[Unit]("My custom hello task")
。 - Jacek Laskowskilazy val helloTask = TaskKey[Unit]("helloTask", "hello")
- 0fnt