Documentation

You are viewing the documentation for the 2.1.x release series. The latest stable release series is 3.0.x.

§The Build System

The Play build system is based on sbt, a minimally non-intrusive build tool for Scala and Java projects.

§The /project directory

All the build configuration is stored in the project directory. This folder contains 3 main files:

Note that build.properties and plugins.sbt have to be manually updated when you are changing the play version.

§Default build for a Play 2.1 application

The default build description generated by the play new command looks like this:

import sbt._
import Keys._
import play.Project._

object ApplicationBuild extends Build {

  val appName         = "Your application"
  val appVersion      = "1.0-SNAPSHOT"

  val appDependencies = Seq(
    // Add your project dependencies here,
    jdbc,
    anorm
  )


  val main = play.Project(appName, appVersion, appDependencies).settings(
    // Add your own project settings here      
  )

}

It is written this way to make it easy to define standard options like application name, version and dependencies.

Note that every sbt feature is available in a Play 2.1 project.

§Play plugin for sbt

The Play console and all development features like live reloading are implemented via a sbt plugin. It is registred in the plugins.sbt file:

addSbtPlugin("play" % "sbt-plugin" % "2.1.x")

You might need to add the Typesafe repository in your list of resolvers, see : http://www.playframework.com/documentation/2.1.x/Repositories

§Adding dependencies and resolvers

Adding dependencies is simple:

val appDependencies = Seq(
  "group" % "name" % "version number",
)

So is adding resolvers:

val main = play.Project(
  appName, appVersion, appDependencies
).settings(
  // Add custom repository: 
  resolvers += "Repository name" at "http://url.to/repository" 
)

Next: About SBT Settings


Found an error in this documentation? The source code for this page can be found here. After reading the documentation guidelines, please feel free to contribute a pull request. Have questions or advice to share? Go to our community forums to start a conversation with the community.