This tutorial will show how to add SBT wrapper to a project, so we don’t have to install either Sbt or Scala in order to build it.
Similarly to Gradle Wrapper, SBT users also have the ability to add a wrapper to their projects, thanks to the excellent sbt-extras project maintained by a group of more than 50 contributors up to this date. This project provides a sbt
bash script that works similarly to gradlew
for Gradle projects.
According to the documentation, the script will automatically detect and download the required Scala and Sbt versions on runtime. This means you can work on multiple projects with different version combinations without having to update your environment settings.
First, download the sbt script from the repository and put it in the root folder of your project, then rename it to sbtx
to avoid clashing with any real Sbt installations. You can do all of it by using a single shell command on the root folder of your project:
curl -Ls https://git.io/sbt > sbtx && chmod 0755 sbtx
Then it should appear like the following in your project:
Now you just run it like any other bash scripts. From the root folder of the project that would be
./sbtx compile
And as you watch the output, you’ll notice it downloads the correct Scala and Sbt versions if necessary.
Downloading sbt launcher for 1.2.8: From https://repo.scala-sbt.org/scalasbt/maven-releases/org/scala-sbt/sbt-launch/1.2.8/sbt-launch-1.2.8.jar To /home/bgasparotto/.sbt/launchers/1.2.8/sbt-launch.jar Downloading sbt launcher 1.2.8 md5 hash: From https://repo.scala-sbt.org/scalasbt/maven-releases/org/scala-sbt/sbt-launch/1.2.8/sbt-launch-1.2.8.jar.md5 To /home/bgasparotto/.sbt/launchers/1.2.8/sbt-launch.jar.md5 /home/bgasparotto/.sbt/launchers/1.2.8/sbt-launch.jar: OK [info] Loading settings for project global-plugins from idea.sbt ... [info] Loading global plugins from /home/bgasparotto/.sbt/1.0/plugins [info] Loading project definition from /home/bgasparotto/git/learning-scala/project [info] Loading settings for project learning-scala from build.sbt ... [info] Set current project to learning-scala (in build file:/home/bgasparotto/git/learning-scala/) [info] Executing in batch mode. For better performance use sbt's shell [info] Compiling 12 Scala sources to /home/bgasparotto/git/learning-scala/target/scala-2.11/classes ... [info] Done compiling. [success] Total time: 4 s, completed Nov 18, 2020 1:13:07 AM
Hope it helps. See ya!
This guide will show you how to create a Python function decorator with a few…
This guide will show you how to fix the error Got permission denied while trying…
This guide will show you how to create a Python virtual environment on Intellij IDEA…
This tutorial will quickly show you how to to find and kill processes on Linux,…
This guide shows a possible solution for Python error Relocation R_X86_64_PC32 against symbol can not…
I condensed below a cheat sheet of Kubernetes useful commands. I will keep updating this…