4
votes

I checked out project from Github, then run sbt gen-idea and opened this project in IDEA. One of the project modules uses Play 2.0 Framework.

But IDEA don't recognize symbols specific to Play!. I.e. I get following error: cannot resolve symbol index in the following statement views.html.index.

Same errors on other specific to Play! Framework features, for example I get same error on routes variable.

P.S. I have installed Play 2.0, Scala, SBT plugins and also configured Play 2.0 framework root directory (in Project Settings - Play configuration)

2

2 Answers

1
votes

Personally, I don't use the Play addon from IntelliJ. It's always far quicker and reliable to use command-line in order to compile/generate the different elements including the famous *.template.scala, at the origin of your cannot resolve symbol index notification.

All you have to do is to run this command-line based on your app's root folder: play then compile. Of course, do not then any Rebuild project from IntelliJ, otherwize you'd erase the generated class files from command-line. When dealing with non-managed resources (like templates), just make a cmd+F9 to compile.

Making sure you output compilation from IntelliJ is configured to map the same folder than your app's target folder (what sbt gen-idea (although I use playthen idea with-sources=yes) normally auto-configures).

Then your IntelliJ project would not complain any more about some views.html.index unresolved.

Of course, if you really want to benefit from your IntelliJ IDE, make sure you have installed the last Play 2.X plugin.

Alternatively, create a custom runcommand in IntelliJ in order to take in account SBT compilation.

1
votes

For anyone using Java Play 2.4.x and IntelliJ 15, my colleagues at work kept running into this issue as well. We had the Scala plugin installed (which comes with SBT built in) and all of our dependencies were fine. Turns out the issue arose from the way that they were opening the project (don't ask me why).

Do: File -> New -> Project from Existing Sources...

Do Not: File -> Open