Posts Creating a skeleton project
Post
Cancel

Creating a skeleton project

Generate a skeleton with giter8

In terminal, in your repos directory, create a new project using a giter8 template for play-scala-seed:

1
2
cd ~/repos
sbt new playframework/play-scala-seed.g8

You will be asked for more information.
Fill out the following:

FieldValue
nameplayground
organizationcom.example

This will create a new project skeleton with the latest play version inside ~/repos/playground based on Play’s gitter8 template, which sets up your project folders, build structure, and development environment - all with one command.

Use sbt to build the project

We will switch to IntelliJ soon, but for now let’s open an sbt shell inside the project dir:

1
2
cd playground
sbt

sbt is a build tool - you can compile, test, package, run your app, and define other tasks using sbt. At your company, you will probably use sbt in your CI server (e.g Travis CI) to do such tasks.

let’s compile (first time may take a few minutes):

>compile

sbt compile

The first time should take a few minutes since sbt downloads the dependencies of your application.

Side note: The command above runs all the sbt tasks up to and including compile.
This includes many other tasks, such as updating the dependencies.
Verify with:

>inspect tree compile

Tasks can be incremental, and therefore invoking compile again without changing any source files should take less than a second.

Running update will update our library dependencies (if necessary).

Let’s run the app by typing run in sbt shell.
It will serve the app in Dev mode (more on modes later) on port 9000.
Browse to http://localhost:9000 - You should see a “Welcome to Play!” message.
Go back to the sbt console and press Enter to stop the server. Press ctrl+D to shut down sbt.