5

As far as I can tell when you run the sbt executable it looks for your build configuration within the current directory structure (build.sbt or build scala files). Is there a way to specify an alternate location for the sbt executable to look for the build.sbt or build scala files? Also is there a way to similarly specify a working directory?

For example, could I run sbt from any directory but specify a commandline argument to indicate which build.sbt file I want to run and where the working directory should be?

Something like:

sbt -b /some/dir1/with/build.sbt -w /tmp/sbt/working/dir

I want to do this outside of a build.sbt file, just through the commandline.

ssanj
  • 2,169
  • 3
  • 19
  • 28
  • Possible duplicate of [With SBT, how do I a specify an alternate project root other than the current directory for running a main class?](http://stackoverflow.com/questions/16600119/with-sbt-how-do-i-a-specify-an-alternate-project-root-other-than-the-current-di) – rtfpessoa Apr 11 '16 at 18:10
  • Similar but different. This question is not about running a main class. I want to run the whole build in another directory with a specified working dir. – ssanj Apr 11 '16 at 22:31
  • Could you clarify what you mean by "working directory" in this context? Would it be like a working directory of Git checkout, containing all sources? – Eugene Yokota Apr 12 '16 at 15:59
  • @EugeneYokota I was thinking the working directory would be where the sources are built to, like the target directory etc. The sources could live with the directory that contains the build.sbt as per usual. In hindsight I guess that can be controlled through build.sbt, so is unnecessary. I just didn't want the project artefacts to be created in the directory I ran SBT from. So the scenario would be to specify a build location to SBT, have it run that build from the location of build.sbt, creating artefacts there as well. But once that completes you should be in the directory you ran SBT from – ssanj Apr 12 '16 at 20:59
  • @EugeneYokota something like what gradle does: https://docs.gradle.org/current/userguide/tutorial_gradle_command_line.html#sec:selecting_build. It would be handy to have your project sources built and written out some else though. That way you can have your build (build.sbt & sources) in one directory and then specify that the output of that build should go to some other "working" directory. Some gradle discussions here: https://discuss.gradle.org/t/change-gradle-working-directory-in-a-standard-operating-system-way-where-gradle-is-launched-and-not-where-the-build-gradle-is-located/7153/10 – ssanj Apr 13 '16 at 01:44

1 Answers1

2

It is not possible. build.sbt needs to be on the same folder where you run the sbt command

pedrorijo91
  • 7,635
  • 9
  • 44
  • 82