A simple project
Build files
Setting up a SBT build consists of two steps
- Create a
build.sbt
in your root folder - Create a folder named
project
with a single filebuild.properties
This is already a valid build with a single project. In the Projects section we will learn a bit more on projects and how to set up more sophisticated builds.
project/build.properties
Inside the build.properties
we define the sbt version. This is usually the only thing defined in this file.
sbt.version=1.0.3
build.sbt
SBT looks for *.sbt
files in your project folder. It's best practice to use a single file called build.sbt
to configure your build. We will leave this file empty at the beginning and fill it with content as we move on and learn the different concepts (task, settings, scopes and projects) of SBT in more detail.1
The content of this file is a DSL very close to Scala. However we will pretend we write Scala ;)
Application files
SBT uses the same directory layout to maven. The most important default directories are
Folder | Description |
---|---|
src/main/scala |
Application Scala source files |
src/main/java |
Application Java source files |
src/main/resources |
Application resources |
src/test/scala |
Test Scala sources |
src/test/java |
Test Java sources |
src/test/resources |
Test resources |
target |
Output directory |
Sample Application
We need a minimal application to work with. A simple hello world will be enough. Create src/main/scala/echo/MainApp.scala
and with the following content
package echo
object MainApp extends App {
println("Hello, world")
}
Now we are ready to configure our build!
1. SBT build definitions ↩