In this post we will be discussing about the set up of SBT(simple build tool) in cent os and will be running a sample program using SBT.
Let’s start with the features of SBT.
Sbt is an open source build tool for Scala and Java projects, similar to Java’s Maven or Ant.
Its main features are:
It gives native support for compiling Scala code and also integrating with many Scala test frameworks
It builds descriptions written in Scala using a DSL
It supports dependency management using Ivy (which supports Maven-format repositories)
It has the ability for continuous compilation, testing, and deployment
It can integrate with the Scala interpreter for rapid iteration and debugging
It also supports mixed Java/Scala projects
In this blog we will be learning how to get started with Sbt in CentOS
Sbt is build tool for the Scala community used by the Lift web framework and Play Framework.
Two most prominent key features are incremental compilation and an interactive shell. When continuous compilation mode is entered, the Scala compiler is instantiated only once which eliminates subsequent startup costs, and source file changes are tracked so that only affected dependencies are recompiled. The interactive console allows modifying build settings on the fly and entering the Scala REPL (Read-Evaluate-Print Loop) along with all class files of the project. The popularity of the incremental compilation has prompted Typesafe to extract this feature in the form of an independent component called Zinc.
Sbt was already fed back into the Scala standard library before, when its process API was adopted in Scala 2.9.
Maven is a very popular build tool that has the following advantages:
There are plugins for everything
There is a lot of information and knowledgeable people
It integrates well with the IDEs
Mark Harrah created a build tool, sbt (simple build tool) especially for Scala. It has its own advantages:
It is configured in Scala. This is shorter and more powerful than Maven’s XML.
It supports continuous compilation.
It supports continuous testing.
To reap the benefits of sbt, it is advisable to abandon Maven completely. For legacy projects, Maven POM (The POM was renamed from project.xml in Maven 1 to pom.xml in Maven 2) has to be ported to sbt, which is not always possible.
Step by Step sbt Installation in Centos
Installing sbt is a simple procedure and the only requirements are:
1) Java 1.7 and above
2) Internet connection inside centos – 64bit
Download file from the link given below:
Refer the below screenshot:
Once the file is downloaded, change the directory where it has been saved. Now, run the installation command below:
sudo yum localinstall sbt-0.13.5.rpm
You are propted for missing dependencies and supportive files. Grant the permission by pressing Y.
Once all dependencies are downloaded, it should look like below screenshot.
NOTE: Reboot the system for sbt installation to get affected
Testing if sbt Shell is Installed
Invoke sbt to get the version, using the command:
Sbt makes current directory, a temporary project directory.
We can enter the sbt shell from any directory by typing sbt
NOTE: This may take some time. Ensure that the internet connection is ON while downloading more missing dependencies needed, which might take several minutes.
Now here we run SBT to execute Scala program. Refer the below screenshot.
Hello SBT is printed as output.
Congratulations! sbt is now installed in your CentOS.
We hope this blog was helpful in understanding sbt installation in CentOS.