Is there a way to programatically check if a sbt build can be loaded without running the risk of sbt waiting for user input? I want to run 'sbt test' as part of an automated git/hg bisect but I got commits where sbt fails to start up because of errors in the build definition and then asks the user what it should do.
See also: Have sbt fail when project loading fails (rather than awaiting user input)?
Using the --batch
flag, one can instruct sbt
to forgo the interactive questioning. It will still exit with an exit code of 1
in case of an error:
$ sbt --batch; echo $?
[info] welcome to sbt 1.5.5 (Ubuntu Java 11.0.13)
[info] loading settings for project dl-tools-build from plugins.sbt ...
[info] loading project definition from /harddisk1/home/user/dl-tools/project
/harddisk1/home/user/dl-tools/build.sbt:63: error: not found: value asdf
asdf
^
sbt.compiler.EvalException: Type error in expression
[error] sbt.compiler.EvalException: Type error in expression
[error] Use 'last' for the full log.
[warn] Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? (default: r)
1
$