Scala 将SBT任务添加到播放项目';s的完整构建配置
如何将任务添加到使用完整构建配置(例如Scala 将SBT任务添加到播放项目';s的完整构建配置,scala,sbt,Scala,Sbt,如何将任务添加到使用完整构建配置(例如build.scala)的Play(SBT)项目中,使其实际可见并可以使用 显然,我所做的还不够。当我运行play tasks时,新任务未列出,我无法运行它 Build.scala如下所示: object ApplicationBuild extends Build { val hello = TaskKey[Unit]("hello", "Prints 'Hello World'") val helloTask = hello := {
build.scala
)的Play(SBT)项目中,使其实际可见并可以使用
显然,我所做的还不够。当我运行play tasks
时,新任务未列出,我无法运行它
Build.scala如下所示:
object ApplicationBuild extends Build {
val hello = TaskKey[Unit]("hello", "Prints 'Hello World'")
val helloTask = hello := {
println("Hello World")
}
val appName = "test"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
jdbc
)
val main = play.Project(appName, appVersion, appDependencies).settings(
resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"
)
}
val main = play.Project(appName, appVersion, appDependencies).settings(
resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/",
helloTask
)
将
helloTask
添加为settings
方法中的设置,如下所示:
object ApplicationBuild extends Build {
val hello = TaskKey[Unit]("hello", "Prints 'Hello World'")
val helloTask = hello := {
println("Hello World")
}
val appName = "test"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
jdbc
)
val main = play.Project(appName, appVersion, appDependencies).settings(
resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"
)
}
val main = play.Project(appName, appVersion, appDependencies).settings(
resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/",
helloTask
)
请参阅SBT0.12.4,因为您使用较旧的方法定义任务,使用
TaskKey
和双赋值(helloTask=hello:=
)。您可能会发现对的引用非常有用(在页面底部)。很好,现在我可以从控制台运行它了!还有一件事:当我运行“tasks”或“tasks-v”时,我仍然看不到它?