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 && sbt update
But if I use scala.sys.process
within my code, it won't remember the cd
therefore sbt
is called in the wrong directory. Code like this:
import scala.sys.process._ ("cd /path/to/project" #&& "sbt update").!!
And I didn't find in the documentation any possibility to set sbt's project path via console. It would be nice if something like this works:
"sbt -projectPath /path/to/project update".!!
If something like that is possible, this would save me a lot of mess! (Especially that it runs on UNIX and Windows.)
To change directories, use the command cd followed by the name of the directory (e.g. cd downloads ). Then, you can print your current working directory again to check the new path.
The working directory. The shell always identifies a particular directory within which you are assumed to be working. This directory is known as the working directory (also known as the current working directory). To work with a file within your working directory, you need specify only the file name with a command.
The chdir command is a system function (system call) which is used to change the current working directory. On some systems, this command is used as an alias for the shell command cd. chdir changes the current working directory of the calling process to the directory specified in path.
By default, bash shows just your current directory, not the entire path. To determine the exact location of your current directory within the file system, go to a shell prompt and type the command pwd.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With