I have a short Bash script that does a find-and-replace on my Scaladoc comments in order to generate links to external documentation of a third-party library. I would like this script to run every time I generate Scaladocs using the doc
task.
How can I achieve this?
It's actually pretty easy. First, I inspected doc to see what it was (
inspect doc
on the sbt prompt), noticed it was a task, and proceeded with declaring a dependency on itself onbuild.sbt
:That thing I used to execute
bash
is the same library asscala.sys.process
, so you can look up Scaladoc for that. This was tested on SBT 0.12.2, and I think there might be a small difference on SBT 0.11.x or 0.10.x.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<<=
):You may also like
triggeredBy
method for tasks as follows:It assumes that
myBashScript.sh
is in the main directory of the project as pointed bybaseDirectory
setting.