I'm using sbt v0.13.5
In my project, I'd like to have an sbt task that can accept some input (a single string), do some work on it and spit back some output (again, a single string). I've created a helper class in my project that does this that I can call from the terminal via sbt runMain
(sbt "runMain com.example.utils.ClassName someArgument"
).
What I'd like is to save myself some typing and have an sbt task that does this. I'd like to just be able to type sbt doThing withStuff
and have a taskKey named doThing
that calls runMain
with the name of the class to run and whatever argument was passed in.
I know how to create tasks but I can't seem to figure out how to call runMain
from a custom task definition in my build.sbt. Can anyone point me in the correct direction?
TaskKey[Unit]("myTask") := (runMain in Compile).toTask(" com.example.Main arg1 arg2").value
runMain
is an InputTask
. InputTask
has toTask
method since 0.13.1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With