How to execute a bash script as sbt task


I want to automatically build documentation for my Java Play 2.3 application.
At the moment, I use a Makefile to generate images from *.dotfiles and combine Markdown sources together into Html/PDF:

dot -Tpdf -o diagram1.pdf
dot -Tpdf -o diagram2.pdf
pandoc doc1.markdown -o doc1.pdf
# ...

Now I want to run these simple bash commands directly from SBT.
What's the best way to do this?

I found some SBT Documentation plugins in the SBT reference, but nothing to run a simple shell script.

Best Solution

You can find some answers in External Processes in the official documentation of sbt, e.g.

To run an external command, follow it with an exclamation mark !:

 "find project -name *.jar" !

Don't forget to use import scala.sys.process._ so ! can be resolved as a method of String.

Do the following in activator console (aka sbt shell) to execute - mind the eval command and the quotes around the name of the script:

eval "" !

To have it available as a task add the following to build.sbt of your project:

lazy val execScript = taskKey[Unit]("Execute the shell script")

execScript := {
  "" !
Related Question