How to execute a bash script as sbt task?

前端 未结 2 726
悲&欢浪女
悲&欢浪女 2020-12-13 04:18

I want to automatically build documentation for my Java Play 2.3 application. At the moment, I use a Makefile to generate images from *.dotfiles and combine Mar

2条回答
  •  情歌与酒
    2020-12-13 05:04

    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" !
    }
    

提交回复
热议问题