How to run bash script after generating scaladoc using doc task?

前端 未结 2 920
灰色年华
灰色年华 2021-01-13 11:45

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 t

2条回答
  •  一向
    一向 (楼主)
    2021-01-13 12:30

    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 on build.sbt:

    doc in Compile <<= doc in Compile map { (file) =>
      Seq("bash", "-c", "ls >tmp.log").! // CWD is sbt's current dir
      file
    }
    

    That thing I used to execute bash is the same library as scala.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.

提交回复
热议问题