I want to automatically build documentation for my Java Play 2.3 application. At the moment, I use a Makefile to generate images from *.dot
files and combine Markdown sources together into Html/PDF:
dot diagram1.dot -Tpdf -o diagram1.pdf dot diagram2.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.
In order to run a Bash script on your system, you have to use the “bash” command and specify the script name that you want to execute, with optional arguments. Alternatively, you can use “sh” if your distribution has the sh utility installed.
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 yourshell.sh
- mind the eval
command and the quotes around the name of the script:
eval "yourshell.sh" !
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 := { "yourshell.sh" ! }
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