I’ve recently ran into issue where our projects were expecting to run with SBT version 0.13.12, but the only version that was installing with home-brew via brew install sbt was 1.0.1.
Global Setting
I’ve Googled and realized that I can install older version with brew install sbt@0.13 but this installed version 0.13.16 which was still incompatible with our projects.
After few hours of pulling my hair out a co-worker pointed out that I can specify needed sbt version via command line as such: sbt -sbt-version 0.13.12 and it work, but it would be very painful to run it like that every time.
I was thinking of adding an alias, but then I saw something in logs when re-installing sbt one more time.
Global settings should be placed in /usr/local/etc/sbtopts
I’ve opened the /usr/local/etc/sbtopts in editor, uncommented and edited the following:
# Sets the SBT version to use.
-sbt-version 0.13.12
Code language: CSS (css)
After that sbt ran with the needed version, even though I had version 1.0.1 installed.
Local Setting
Another way of setting sbt version (as was suggested in comments) is at project level. To do so:
- Edit
project/build.propertiesand addsbt.version=0.13.16in there. - Run
sbt sbtVersionto pick up version frombuild.propertiesfile.
This was exactly what I needed. Thanks for the concise description!
Seems once I changed SBT 1.1.1 to 0.13.12 I have some new Java error.
Loading global plugins from /Users/oly/.sbt/0.13/plugins
java.lang.NullPointerException
Any idea which Java version should I use with 0.13.12?
I am using it with Java 8.
This is a global setting, but a much better way is setting it per project (e.g. if you have few projects which use different versions).
This is done as follows:
https://github.com/scala/scala/blob/2.12.x/project/build.properties
This solution is also platform-independent, unlike your suggestion
Thanks for the comment. I just checked and my projects already have that property set, but it still did not work until I changed the global setting.
Turns out it will work if we run
sbt sbtVersionto pick it up