Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SBT compilation for play framework 2.x disabled by default

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.

like image 408
dazito Avatar asked Oct 18 '15 21:10

dazito


3 Answers

Preferences > Languages & Frameworks > Play2

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

enter image description here

like image 178
tgk Avatar answered Oct 07 '22 11:10

tgk


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.

like image 20
Suleka_28 Avatar answered Oct 07 '22 09:10

Suleka_28


Similar answer to user3384225's answer was posted here:

  • https://devnet.jetbrains.com/message/5560914

They say:

  • Settings -> Langauges & Frameworks -> Play2 -> Compiler -> User Play 2 compiler for this project
like image 43
PeteH32 Avatar answered Oct 07 '22 09:10

PeteH32