Importing an "existing" Play 2 Project into Intellij 14 (IDEA)

It’s been a while since I picked up the Play Framework.  I wanted to create a new Play 2 project in IDEA.  I used the Play 2 plugin to create a new project.

**But, **I am great believer in getting a project created at the command-line.  Maybe it's something to do with production servers not running IDEA :O)

This is a step-by-step guide to importing your Play 2 project into IDEA:

First of all, check that nothing is running on http://localhost:9000  this is the default port for running Play 2 applications. _Make sure that you uninstall previous (old) versions of the Play Framework (binary), especially **before** activator was used (**pre** Play version 2)._

Create a new Play 2 project, named Foo.

Type activator foo (select** 5** for a play-java project):

Screen Shot 2015-09-03 at 10.29.15


Now start the activator ui (user-interface).  This will allow you to run the Foo project from the activator web-ui:

Screen Shot 2015-09-03 at 10.31.51


The activator web-ui will “appear” (on http://localhost:8888)

Screen Shot 2015-09-03 at 10.33.49

Click the Run icon.  Then select the Run option (on the left vertical navigation):

Screen Shot 2015-09-03 at 10.36.20

Point your web-browser at 9000.  You will see the “Welcome to Play” web-page.


**Import the Foo Play 2 application into IDEA 14**

Stop the activator ui (Java) process.  Ensure that http://localhost:9000 is not being used (by Play 2).


Start IDEA 14, and Create New Project from Existing Sources:

Screen Shot 2015-09-03 at 10.42.54


Select the build.sbt file from the Foo project:

Screen Shot 2015-09-03 at 10.44.54

Click OK.


The next screen will “confirm” that you are importing an SBT project:

Screen Shot 2015-09-03 at 10.46.10

Don’t bother ticking any of the options.  Ensure that the Project SDK (Java) is correct.


When dependencies have been imported, you will see a “typical” Play project file structure:

Screen Shot 2015-09-03 at 10.49.24


At this stage, I always select the Build -> Rebuild menu option.  This ensures that everything compiles (works).

I then select main.scala.html (this is the naming convention), right click, and select Run Play 2 App:

Screen Shot 2015-09-03 at 10.52.15


Please be patient.  It takes a while to Play 2 to be listening on port 9000.  You are looking for this text (the same as in the activator ui task - previously):

Screen Shot 2015-09-03 at 10.57.48


http://localhost:9000 will show you the same welcome message:

Screen Shot 2015-09-03 at 10.59.05


**Congratulation on getting your Play 2 application successfully imported into IDEA 14 :O)**

UPDATE


It is important to have the correct plugins installed in IDEA.

I have just been-through the tutorial, and have taken additional screen-shots of my project configuration, and the Plugins which I have installed:

Firstly, I am showing my Play 2, Edit Configurations:

Screen Shot 2015-10-21 at 14.33.35

Then my IDEA Plugins:

Screen Shot 2015-10-21 at 14.34.58

Plugins are Playframework Support, and Scala.  The Scala Plugin has the Play 2 support.

Please ensure that these plugins are installed.

Author | Miles Davenport

Career programmer, who designs, assembles, fixes, and supports customers, software and systems.