Setting current working directory when executing a shell process

前端 未结 1 655
死守一世寂寞
死守一世寂寞 2020-12-28 16:40

I would like to call sbt update within my source-code, to update multiple sbt projects. In the shell this is easy:

cd /path/to/project &&         


        
相关标签:
1条回答
  • 2020-12-28 17:04

    Use one of the ProcessBuilder factory methods on the Process object:

    sys.process.Process(Seq("sbt","update"), new java.io.File("/path/to/project")).!!
    

    For more documentation, see the scaladoc file for the sys.process package. Unfortunately, it does not mention the 'current working directory' arguments, but they are in the documentation of object Process.

    0 讨论(0)
提交回复
热议问题