Play Framework 2.4 and IntelliJ Idea

RichyHBM picture RichyHBM · Jun 2, 2015 · Viewed 14.6k times · Source

I am trying to open a play 2.4 project in IntelliJ but since things have changed I don't know how to do this.

In previous versions I could just run

activator idea

Or use the activator UI and click on generate intelliJ project, but in 2.4 the idea command doesn't seem to exist

[error] Not a valid command: idea (similar: eval, alias)
[error] Not a valid project ID: idea
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: idea (similar: clean)
[error] idea
[error]     ^

And the UI seems broken, when I click on generate intelliJ project it tries to compile the app and gives this error:

play/Play$
java.lang.NoClassDefFoundError: play/Play$
Use 'last' for the full log.
Failed to load project.

I created the project from scratch using the play java template with:

activator new

I have also tried importing the folder as a project but intelliJ doesn't seem to identify it as a project

Answer

Tom picture Tom · Dec 23, 2015

I run into the same problem, as I used IDEA to open a project folder, it had an play 2 app in a sub folder, then I import module (play 2 app) to the system.

And it works well.

After that I have changed the module folder name, then when I run the app, it displayed:

Not a valid project ID: "project team"

I re-checked the folder, and found that in the File -> Project Structure option, the name of module is "root", and the "team" is the module for whole project (not the module imported by SBT), so apparently, the module wasn't functional after I changed the module folder name.

So I found and removed all .idea folder, which is IDEA configureation, then re-open/re-import the module, still not work. I thought it's IDEA cache issue, it do have cache for the opened project, so I changed the project folder from team to something else, clean the .idea folders, and re-open/re-import it. It worked.

If the play app is in the project folder as a sub folder, to import the module at File -> Project Structure.

The project name should be "root" when running it in IDEA. So in this case, you should rename "project team" to "root" in the name field.

enter image description here

enter image description here