Have you ever wondered why you no longer play on the command line, but execute
activator? And why is Play only ever referred to in
plugins.sbt and not your
libraryDependencies, but still, you can use its API in your code? And how does Play – run?
The sbt Plugin
The Playframework is separated into multiple modules, and with each new version, more parts of it are factored out into their own modules. The best known is simply called play – it contains the API that you as a developer interact with when developing a Play application.
The part that is running your application is actually an sbt plugin, and you can find it in the aptly named module sbt-plugin.
All plugins that your build uses must be specified in
project/plugins.sbt, and are then in scope in each sub-project. To be more precise, Play is an auto-plugin. As the name suggests, auto plugins can enable themselves automatically. Play does not use this feature however – because you want to specifically enable either the Scala or the Java plugin.
// Use Play with Scala
lazy val root = (project in file(".")).enablePlugins(PlayScala)
// Use Play with Java
lazy val root = (project in file(".")).enablePlugins(PlayJava)