This page assumes you’veinstalled sbt and seen theHello, World example.
In sbt’s terminology, the “base directory” is the directory containingthe project. So if you created a projecthello containinghello/build.sbt as in theHello, Worldexample,hello is your base directory.
sbt uses the same directory structure asMaven for source files by default (all pathsare relative to the base directory):
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>Other directories insrc/ will be ignored. Additionally, all hiddendirectories will be ignored.
Source code can be placed in the project’s base directory ashello/app.scala, which may be for small projects,though for normal projects people tend to keep the projects inthesrc/main/ directory to keep things neat.The fact that you can place*.scala source code in the base directory might seem likean odd trick, but this fact becomes relevantlater.
The build definition is described inbuild.sbt (actually any files named*.sbt) in the project’s base directory.
build.sbtIn addition tobuild.sbt,project directory can contain.scala filesthat defines helper objects and one-off plugins.Seeorganizing the build for more.
build.sbtproject/ Dependencies.scalaYou may see.sbt files insideproject/ but they are not equivalent to.sbt files in the project’s base directory. Explaining this willcomelater, since you’ll need some background information first.
Generated files (compiled classes, packaged jars, managed files, caches,and documentation) will be written to thetarget directory by default.
Your.gitignore (or equivalent for other version control systems) shouldcontain:
target/Note that this deliberately has a trailing/ (to match only directories)and it deliberately has no leading/ (to matchproject/target/ inaddition to plaintarget/).