How to create a new Play Framework 2.6 Scala project (and giter8)

If you haven’t been through it yet, this what the process of creating a new project with the Play Framework version 2.6 looks like:

$ sbt new playframework/play-scala-seed.g8
WARN: No sbt.version set in project/, base directory: /Users/al/Projects/Scala/Play
[warn] Executing in batch mode.
[warn]   For better performance, hit [ENTER] to switch to interactive mode, or
[warn]   consider launching sbt without any commands, or explicitly passing 'shell'
[info] Set current project to play (in build file:/Users/al/Projects/Scala/Play/)

This template generates a Play Scala project

name [play-scala-seed]: Scrupal6
organization [com.example]: com.alvinalexander
play_version [2.6.12]:
sbt_version [1.1.1]:
scalatestplusplay_version [3.1.2]:

Template applied in ./scrupal6

That last sentence of output is slightly erroneous, the actually directory is named Scrupal6 (with a capital letter “S”).

Inside that directory this is what you see when your Play Framework project is created:

drwxr-xr-x  15 al  staff   510 Mar 31 10:54 .
drwxr-xr-x   9 al  staff   306 Mar 31 10:53 ..
drwxr-xr-x   3 al  staff   102 Mar 31 10:54 .g8
-rw-r--r--   1 al  staff    80 Mar 31 10:54 .gitignore
drwxr-xr-x   3 al  staff   102 Mar 29 14:07 Database
drwxr-xr-x   4 al  staff   136 Mar 31 10:54 app
-rw-r--r--   1 al  staff  1010 Mar 31 10:54 build.gradle
-rw-r--r--   1 al  staff   526 Mar 31 10:54 build.sbt
drwxr-xr-x   6 al  staff   204 Mar 31 10:54 conf
drwxr-xr-x   3 al  staff   102 Mar 31 10:54 gradle
-rwxr--r--   1 al  staff  5296 Mar 31 10:53 gradlew
-rw-r--r--   1 al  staff  2260 Mar 31 10:53 gradlew.bat
drwxr-xr-x   5 al  staff   170 Mar 31 10:54 project
drwxr-xr-x   5 al  staff   170 Mar 31 10:54 public
drwxr-xr-x   3 al  staff   102 Mar 31 10:54 test

This is what the Unix ‘find’ command shows the directory structure looks like:


(Interestingly, it still doesn’t create a models folder. I’m not sure what the philosophy is behind that.)

The Play Framework build.sbt file

Here’s the auto-generated Play Framework build.sbt file:

name := """Scrupal6"""
organization := "com.alvinalexander"

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayScala)

scalaVersion := "2.12.4"

libraryDependencies += guice
libraryDependencies += "" %% "scalatestplus-play" % "3.1.2" % Test

// Adds additional packages into Twirl
//TwirlKeys.templateImports += "com.alvinalexander.controllers._"

// Adds additional packages into conf/routes
// play.sbt.routes.RoutesKeys.routesImport += "com.alvinalexander.binders._"

Starting/running the new Play Framework app

You run your new Play Framework app using sbt, specifically the sbt run command. Here’s what that process looks like:

> sbt

[info] Loading settings from idea.sbt ...
[info] Loading global plugins from /Users/al/.sbt/1.0/plugins
[info] Updating ProjectRef(uri("file:/Users/al/.sbt/1.0/plugins/"), "global-plugins")...
[info] Done updating.
[info] Loading settings from plugins.sbt,scaffold.sbt ...
[info] Loading project definition from /Users/al/Projects/Scala/Play/Scrupal6/project
[info] Updating ProjectRef(uri("file:/Users/al/Projects/Scala/Play/Scrupal6/project/"), "scrupal6-build")...
[info] Done updating.
[warn] Found version conflict(s) in library dependencies; some are suspected to be binary incompatible:
[warn]     * org.webjars:webjars-locator-core:0.33 is selected over 0.32
[warn]         +- com.typesafe:npm_2.12:1.2.1                        (depends on 0.32)
[warn]         +- com.typesafe.sbt:sbt-web:1.4.3 (scalaVersion=2.12, sbtVersion=1.0) (depends on 0.32)
[warn]     * org.codehaus.plexus:plexus-utils:3.0.17 is selected over {2.1, 1.5.5}
[warn]         +- org.apache.maven:maven-settings:3.2.2              (depends on 3.0.17)
[warn]         +- org.apache.maven:maven-repository-metadata:3.2.2   (depends on 3.0.17)
[warn]         +- org.apache.maven:maven-aether-provider:3.2.2       (depends on 3.0.17)
[warn]         +- org.apache.maven:maven-model:3.2.2                 (depends on 3.0.17)
[warn]         +- org.apache.maven:maven-core:3.2.2                  (depends on 3.0.17)
[warn]         +- org.apache.maven:maven-artifact:3.2.2              (depends on 3.0.17)
[warn]         +- org.apache.maven:maven-settings-builder:3.2.2      (depends on 3.0.17)
[warn]         +- org.apache.maven:maven-model-builder:3.2.2         (depends on 3.0.17)
[warn]         +- org.sonatype.plexus:plexus-sec-dispatcher:1.3      (depends on 1.5.5)
[warn]         +- org.eclipse.sisu:org.eclipse.sisu.plexus:0.0.0.M5  (depends on 2.1)
[warn]     * is selected over {10.0.1, 16.0, 20.0}
[warn]         +- io.methvin:directory-watcher:0.3.2                 (depends on 23.0)
[warn]         +- com.fasterxml.jackson.datatype:jackson-datatype-guava:2.8.8 (depends on 10.0.1)
[warn]         +- org.eclipse.sisu:org.eclipse.sisu.plexus:0.0.0.M5  (depends on 10.0.1)
[warn]         +- com.spotify:docker-client:8.9.0                    (depends on 10.0.1)
[warn] Run 'evicted' to see detailed eviction warnings
[info] Loading settings from build.sbt ...
[info] Set current project to Scrupal6 (in build file:/Users/al/Projects/Scala/Play/Scrupal6/)
[info] sbt server started at local:///Users/al/.sbt/1.0/server/acf366110f0ed262c367/sock

[Scrupal6] $ run

[info] Updating ...
[info] Done updating.
[warn] Found version conflict(s) in library dependencies; some are suspected to be binary incompatible:
[warn]     * is selected over 19.0
[warn]         +-                 (depends on 22.0)
[warn]         +-                      (depends on 19.0)
[warn]     * com.typesafe.akka:akka-stream_2.12:2.5.11 is selected over 2.4.20
[warn]         +-         (depends on 2.5.11)
[warn]         +- com.typesafe.akka:akka-http-core_2.12:10.0.11 ()   (depends on 2.4.20)
[warn]     * com.typesafe.akka:akka-actor_2.12:2.5.11 is selected over 2.4.20
[warn]         +- com.typesafe.akka:akka-stream_2.12:2.5.11 ()       (depends on 2.5.11)
[warn]         +- com.typesafe.akka:akka-slf4j_2.12:2.5.11 ()        (depends on 2.5.11)
[warn]         +-                 (depends on 2.5.11)
[warn]         +- com.typesafe.akka:akka-parsing_2.12:10.0.11 ()     (depends on 2.4.20)
[warn] Run 'evicted' to see detailed eviction warnings

--- (Running the application, auto-reloading is enabled) ---

[info] p.c.s.AkkaHttpServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000

(Server started, use Enter to stop and go back to the console...)

One the app is running, just go to this URL to see the initial output:

  • http://localhost:9000


All of this process is very different than the old play new command, so I thought I’d show the process and output here. You can find more information about creating new Play Framework projects at this URL.