You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
src/
main/
resources/
<files to include in main jar here>
scala/
<main Scala sources>
java/
<main Java sources>
test/
resources
<files to include in test jar here>
scala/
<test Scala sources>
java/
<test Java sources>
What is sbt?
sbt (aka Simple Build Tool) is a general purpose build tool written in Scala for JVM developers. It took advantage of previous ideas developed by other similar tools like Maven, Gradle and Ant.
Default project layouts
Built-in tasks
Plugin architecture
Declarative Dependency management
Code over Configuration: A DSL for build tool
Interactive
Scala REPL integration
In order to have a better understanding of the main tool you'll use programming with Scala you must read:
At first, you've to create the new project folder (e.g. myproject). Then, put inside the new folder a file named build.sbt, which contains the build settings that sbt will use. to house the build script (how build.sbt defines settings). This file, at the very beginning, will look like the following:
name :="myproject"
version :="0.1.0"
scalaVersion :="2.12.2"
where := is a function defined in the sbt library. It is used to define a setting that overwrites any previous value without referring to other settings. In order to define the version of Scala that sbt will pick up it's possible to define a specific scalaVersion, but before doing so it's better to verify your environment configuration and the current version of your Scala compiler (scala -version).
If the Scala version is not specified, the version sbt was built against is used. It is recommended to explicitly specify the version of Scala.
Please note that because compile is a dependency of run, you don’t have to run compile before each run; just type sbt run.
@see sbt documentation
What's more, in the interactive modesbt has a list of useful commands that guide you in the day to day work like help and tasks. One of the most useful things of sbt is the automatic and continous execution of a task fired by the changes saved to a source file you're editing. To trigger this kind of behaviour a task must be prepended with ~. So, to execute all the tests that either failed during the previous execution or whose transitive dependencies changed the task is ~testQuick, to stop its execution just hit Enter.
Add ScalaTest
Starting from sbt 0.10 it's possible to add the ScalaTest framework to a sbt project adding the following line to the build.sbt: