67

I created a new Play Framework project using the activator, activator new my-project-name and then I selected the play-java template and the project is created with no errors.

Then I import the project into my IDE, IntelliJ, as a SBT project. When the project is imported a popup is shown saying: SBT compilation for play framework 2.x disabled by default.

On IntelliJ project's panel it doesn't show all (mostly the files with the code) files. Just a handful of them.

enter image description here

The build.sbt file looks like full of compilation error (pretty much all the lines are red underlined).

Here's the build.sbt file

name := """my-project-name"""

version := "1.0-SNAPSHOT"

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

scalaVersion := "2.11.6"

libraryDependencies ++= Seq(
  javaJdbc,
  cache,
  javaWs
)

// Play provides two styles of routers, one expects its actions to be injected, the
// other, legacy style, accesses its actions statically.
routesGenerator := InjectedRoutesGenerator


fork in run := true

I can compile and run the code with activator ui with no errors. So, why isn't IntelliJ fully importing the project and it shows me SBT compilation for play framework 2.x disabled by default message?

I googled around and couldn't find any hint related to this so I'm kinda lost here.

EDIT: -------------------------------------

I closed the project on IntelliJ and deleted the project folder. Closed IntelliJ and using activator I created again the same project. Using activator ui I compiled the project. Then I fired up IntelliJ and was prompted to either open a project, create a new one or import a project.

Selected import a project and did the normal "import a project steps" and IntelliJ imported the project with no hassle. But if I try to import the project while with an open project on IntelliJ I get the same problem that lead me to make this question. Maybe this is a bug on IntelliJ?

EDIT 2 ------------------------------------------

The solution to these two problems (the "SBT compilation for play framework 2.x disabled by default" and the files not showing on IntelliJ) can be fixed with user3384225 and DarkShadow answers.

dazito
  • 6,832
  • 11
  • 63
  • 107
  • 1
    Yeah, I got the same message and still not sure why? – ttt Oct 20 '15 at 00:03
  • I still get it every time. The only workaround I have is the one on my edit to my question. So far I've not found why this is happening. – dazito Oct 20 '15 at 00:28
  • This is the most frustrating bug i've come accross in an IDE, the worst part is the way IntelliJ breaks while trying to fix this – Aj Otto Jul 04 '17 at 09:19

9 Answers9

72

Preferences > Languages & Frameworks > Play2

Under 'Compiler' enable 'Use Play 2 compiler for this project'

enter image description here

tgk
  • 2,972
  • 1
  • 17
  • 35
  • 1
    That made the warning go away but IntelliJ still does not show all the files. Build - Make Project OR Build - Rebuild Project do nothing regarding the files issue. – dazito Oct 20 '15 at 21:46
  • Thanks, this one was catching me out! – Tony Day Nov 04 '15 at 08:53
  • 1
    Why this is not enabled by default? – Richard Topchii Nov 16 '15 at 17:23
  • 4
    @RichardTopchiy This setting can cause problems in incremental compilation in connection to command line compiler. Usually you don't need as running Play2 project will compile on reload. – Gaurav Kumar Nov 21 '15 at 13:35
  • @gaurav-kumar than you, it makes sense. – Richard Topchii Nov 21 '15 at 19:33
  • 13
    What are the benefits of enabling that option ? – Aphax Apr 27 '16 at 16:10
  • I'm a test first developer, when I enable "Use Play 2 compiler for this project" and try to run a test in IntelliJ then I will get "ClassNotFoundException", IntelliJ will simply not compile the test before running. Any idea how to fix this? –  Mar 06 '19 at 14:36
10

I Stumbled upon this problem myself when configuring play framework for IntelliJ IDEA IDE (version: 2017.3). I overcame this problem by following the steps below.

Navigate to:

File --> Settings --> Languages and Frameworks --> Play2 --> Compiler tab

and inside the compiler tab:

put a tick to the Use Play2 compiler for this project

enter image description here

Hope this helped.

Suleka_28
  • 2,219
  • 2
  • 17
  • 37
  • For me it was `File --> Other Settings --> Preferences For New Projects --> Languages and Frameworks --> Play2 --> Compiler tab` this is on a Mac running 2019.1.2 of IntelliJ – Flexicoder May 10 '19 at 10:24
5

Similar answer to user3384225's answer was posted here:

They say:

  • Settings -> Langauges & Frameworks -> Play2 -> Compiler -> User Play 2 compiler for this project
PeteH32
  • 51
  • 2
  • That made the warning go away but IntelliJ still does not show all the files. Build - Make Project OR Build - Rebuild Project do nothing regarding the files issue. – dazito Oct 20 '15 at 21:46
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes – Roman Marusyk Oct 20 '15 at 21:48
2

I am also a newbie and was facing the same problem till yesterday. Probably you are trying to open the project through File->open.

Try the steps below:-

File->New->Project from existing source->select the build.sbt from the project you created using the activator->Import project from external model and select SBT from the options->OK.

It will take some time to import files and to create the settings required for intellij idea project. I am using intellij idea 14.1.5. It worked for me hope it will for you also.

Henu
  • 1,332
  • 2
  • 17
  • 24
  • This did work. It is also slightly the same as I described on my first edit to my question. – dazito Oct 24 '15 at 11:51
2

For current projects, you can fix this by using File->Invalidate Caches/Restart..

serenesat
  • 4,524
  • 10
  • 32
  • 51
2

Most probably you have solved you problem, but just to help others What you just have to do is -> check the option "Use Play 2 compiler for this project" given under Preferences -> Languages & Frameworks -> Play2 -> Compiler

anonymous
  • 41
  • 6
1

Close the project and then import the project as sbt project. Intellij will automatically dump and index the project dependancies.

Yohan E
  • 129
  • 1
  • 7
0

Stumbled upon the same problem today. Solved by wiping the ~/.IntelliJIdea14 directory. Unfortunately any other things I've tried didn't help.

Ihor Kaharlichenko
  • 5,145
  • 1
  • 23
  • 30
  • 1
    It didn't work for me. Still can't load any files with the actual coding. Plus, wiping `~/.IntelliJIdea14` should be done with careful. You'll lose all your configurations and what not, so back it up! – dazito Oct 21 '15 at 21:22
0

Just use: File->New->Project from existing source->select the build.sbt from the project you created using the activator->ok. and it's done.

rkumars
  • 31
  • 5