SBT compilation for play framework 2.x disabled by default

23,863

Solution 1

Preferences > Languages & Frameworks > Play2

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

enter image description here

Solution 2

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.

Solution 3

Similar answer to user3384225's answer was posted here:

They say:

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

Solution 4

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

Solution 5

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.

Share:
23,863
dazito
Author by

dazito

Updated on July 05, 2022

Comments

  • dazito
    dazito almost 2 years

    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.