Custom run task for subproject with arguments from build.sbt?

sbt, scala

Solution

The answer is given in the sbt FAQ section "How can I create a custom run task, in addition to run?". Basically:

lazy val customMigrate = taskKey[Unit]("custom run task")

fullRunTask(customMigrate, Test, "foo.Main", "migrate")

Problem

I have a subproject named `oppenheimer` in my project. It's very simple to run this project from the sbt console. ``` [myproject] $ oppenheimer/run ``` I can also pass in a command line argument as such: ``` [myproject] $ oppenheimer/run migrate [myproject] $ oppenheimer/run clean ``` How can I do this from `build.sbt`? Is it possible to define a task that does this? It would suffice to have something like this: ``` val customMigrate = ... val customClean = ... ``` And this is so that I could use it elsewhere in the project, like such: ``` (test in Test) <<= (test in Test).dependsOn(customMigrate) ```

Original source