Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play Framework 2.4 and IntelliJ Idea

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

like image 956
RichyHBM Avatar asked Jun 02 '15 20:06

RichyHBM


2 Answers

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

like image 72
Tom Avatar answered Oct 04 '22 15:10

Tom


Solution 1

In my case (IDEA 2018.2), I changed the lazy val variable in build.sbt, it had the name "root" when my project name was "top", changed "root" to "top".

Before:

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

After:

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

Change project variable

Solution 2

The method proposed by Tom solved my problem partially, because after rebooting the IDEA I returned the project name back, it was necessary to change the variable from "top" to "root" in build.sbt.

Before:

name: = "top" 

After:

name := "root"
like image 31
Key Avatar answered Oct 04 '22 15:10

Key