67
votes

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.

9
Yeah, I got the same message and still not sure why?ttt
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
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 thisAj Otto

9 Answers

72
votes

Preferences > Languages & Frameworks > Play2

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

enter image description here

10
votes

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.

5
votes

Similar answer to user3384225's answer was posted here:

They say:

  • Settings -> Langauges & Frameworks -> Play2 -> Compiler -> User Play 2 compiler for this project
2
votes

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.

2
votes

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

2
votes

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

1
votes

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

0
votes

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

0
votes

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.