A very simple SBT plugin for creating tasks that require a Play application to run one-off tasks within the sbt/activator console.
Play SBT tasks is available on maven central. Just add the following to project/plugins.sbt:
addSbtPlugin("com.jaroop" %% "play-sbt-tasks-plugin" % "2.0.0")
and Build.scala, or build.sbt:
libraryDependencies += "com.jaroop" %% "play-sbt-tasks" % "2.0.0"
To create a new task, extend the abstract class RunnableTask
, and implement the execute
method:
package com.example
class MyTask(args: String) extends RunnableTask(args) {
def execute: Unit = println("This is my new task.. it doesn't really do anything.")
}
Then register the task in Play's Build.scala:
import com.jaroop.play.sbt.Task
...
val main = play.Project(appName, appVersion, appDependencies).settings(
Task.register("myTask", "com.example.MyTask", "Displays a test message.")
)
Or build.sbt:
import com.jaroop.play.sbt.Task
Task.register("myTask", "com.example.MyTask", "Displays a test message.")