In sbt 0.13 and the latest releases the use case can also be achieved with :=
and .value
macros (that are both aimed at being simpler than <<=
):
doc in Compile := {
val f = (doc in Compile).value
// execute a shell script if you want with sbt's 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 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)
It assumes that myBashScript.sh
is in the main directory of the project as pointed by baseDirectory
setting.