sbt Directory Structure


Example

The standard structure for a project built by SBT is:

projectName/
    build.sbt
    project/
      <SBT sub-build information>
    src/
      main/
        scala/
           <Scala source files>
        java/
           <Java source files>
        resources/
           <Resource files>
      test/
        scala/
           <Scala test files>
        java/
           <Java test files>
        resources/
           <Resource files>

Other directories may exist, but the build deals primarily with these. In the base directory build.sbt is placed, whose contents at a minimum are:

  • name := <name of build>: This is the name of the project.
  • version := <version number>: This is the version of the project for downstream code to reference.
  • scalaVersion := <version of Scala>: This is the version of Scala that the project's bytecode is built against.

The project directory is where the meta-build (as opposed to the proper-build) files are placed. This directory can have it's own build.sbt file that executes in exactly the same manner, creating an environment for the proper-build SBT build to execute. This is recursive, so the project directory can have it's own project directory where a meta-meta-build occurs, and so on.

Upon building, SBT will create a target directory in which class files and other components are placed.