In sbt 0.13 and recent versions, the use case can also be achieved using macros := and .value (which should be simpler than <<= ):
doc in Compile := { val f = (doc in Compile).value // execute a shell script if you want with sbt Process API // http://www.scala-sbt.org/0.13/docs/Process.html val ec = (baseDirectory.value / "myBashScript.sh").getAbsolutePath ! val log = streams.value.log log.debug(s"Exit code: $ec") f }
You may also like the triggeredBy method for tasks as follows:
lazy val runMyBashScriptTask = taskKey[Unit]("Run myBashScript") runMyBashScriptTask := { val ec = (baseDirectory.value / "myBashScript.sh").getAbsolutePath ! val log = streams.value.log log.debug(s"Exit code: $ec") } runMyBashScriptTask <<= runMyBashScriptTask triggeredBy (doc in Compile)
myBashScript.sh is assumed to be located in the main project directory, as indicated by setting baseDirectory .
source share