Books

Working with Play is easy. You don’t even need a sophisticated IDE, because Play compiles and refreshes the modifications you make to your source files automatically, so you can easily work using a simple text editor.

However, using a modern Java or Scala IDE provides cool productivity features like auto-completion, on-the-fly compilation, assisted refactoring and debugging.

You then need to import the application into your Workspace with the File/Import/General/Existing project… menu (compile your project first).

To debug, start your application with sbt -jvm-debug 9999 run and in Eclipse right-click on the project and select Debug As, Debug Configurations. In the Debug Configurations dialog, right-click on Remote Java Application and select New. Change Port to 9999 and click Apply. From now on you can click on Debug to connect to the running application. Stopping the debugging session will not stop the server.

Tip: You can run your application using ~run to enable direct compilation on file change. This way scala template files are auto discovered when you create a new template in view and auto compiled when the file changes. If you use normal run then you have to hit Refresh on your browser each time.

If you make any important changes to your application, such as changing the classpath, use eclipse again to regenerate the configuration files.

Tip: Do not commit Eclipse configuration files when you work in a team!

The generated configuration files contain absolute references to your framework installation. These are specific to your own installation. When you work in a team, each developer must keep his Eclipse configuration files private.

Intellij IDEA lets you quickly create a Play application without using a command prompt. You don’t need to configure anything outside of the IDE, the SBT build tool takes care of downloading appropriate libraries, resolving dependencies and building the project.

Before you start creating a Play application in IntelliJ IDEA, make sure that the latest Scala Plugin is installed and enabled in IntelliJ IDEA. Even if you don’t develop in Scala, it will help with the template engine and also resolving dependencies.

To create a Play application:

Open New Project wizard, select Sbt under Scala section and click Next.

Enter your project’s information and click Finish.

You can also import an existing Play project.

To import a Play project:

Open Project wizard, select Import Project.

In the window that opens, select a project you want to import and click OK.

On the next page of the wizard, select Import project from external model option, choose SBT project and click Next.

On the next page of the wizard, select additional import options and click Finish.

That’s all there is to it. You should now get type-checking, completion, etc. for your Play project. Note, if you add new library dependencies to your play project, you’ll need to re-run “ensimeConfig” and re-launch ENSIME.