SBT compilation for play framework 2.x disabled by default - intellij-idea

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.
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.

Preferences > Languages & Frameworks > Play2
Under 'Compiler' enable 'Use Play 2 compiler for this project'

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
Hope this helped.

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

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.

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

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

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

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

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.

Related

Play Framework 2.4 and IntelliJ Idea

I am trying to open a play 2.4 project in IntelliJ but since things have changed I don't know how to do this.
In previous versions I could just run
activator idea
Or use the activator UI and click on generate intelliJ project, but in 2.4 the idea command doesn't seem to exist
[error] Not a valid command: idea (similar: eval, alias)
[error] Not a valid project ID: idea
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: idea (similar: clean)
[error] idea
[error] ^
And the UI seems broken, when I click on generate intelliJ project it tries to compile the app and gives this error:
play/Play$
java.lang.NoClassDefFoundError: play/Play$
Use 'last' for the full log.
Failed to load project.
I created the project from scratch using the play java template with:
activator new
I have also tried importing the folder as a project but intelliJ doesn't seem to identify it as a project
I run into the same problem, as I used IDEA to open a project folder, it had an play 2 app in a sub folder, then I import module (play 2 app) to the system.
And it works well.
After that I have changed the module folder name, then when I run the app, it displayed:
Not a valid project ID: "project team"
I re-checked the folder, and found that in the File -> Project Structure option, the name of module is "root", and the "team" is the module for whole project (not the module imported by SBT), so apparently, the module wasn't functional after I changed the module folder name.
So I found and removed all .idea folder, which is IDEA configureation, then re-open/re-import the module, still not work. I thought it's IDEA cache issue, it do have cache for the opened project, so I changed the project folder from team to something else, clean the .idea folders, and re-open/re-import it. It worked.
If the play app is in the project folder as a sub folder, to import the module at File -> Project Structure.
The project name should be "root" when running it in IDEA. So in this case, you should rename "project team" to "root" in the name field.
Solution 1
In my case (IDEA 2018.2), I changed the lazy val variable in build.sbt, it had the name "root" when my project name was "top", changed "root" to "top".
Before:
lazy val root = (project in file(".")).enablePlugins(PlayScala)
After:
lazy val top = (project in file(".")).enablePlugins(PlayScala)
Change project variable
Solution 2
The method proposed by Tom solved my problem partially, because after rebooting the IDEA I returned the project name back, it was necessary to change the variable from "top" to "root" in build.sbt.
Before:
name: = "top"
After:
name := "root"
Intellij IDEA lets you quickly create a Play application without using a command prompt. You don’t need to configure anything outside of the IDE, the SBT build tool takes care of downloading appropriate libraries, resolving dependencies and building the project.
Before you start creating a Play application in IntelliJ IDEA, make sure that the latest Scala Plugin is installed and enabled in IntelliJ IDEA. Even if you don’t develop in Scala, it will help with the template engine and also resolving dependencies.
Basically, install Play Framework, Scala plugins and import project into Intellij as SBT project. Don't use activator to create IDEA project files. More details here.
It seems I had not updated scala/sbt to the latest version in intelliJ
Once I had done this it noticed that it was a valid project, though the docs don't seem to mention you can import it as an SBT project, just how to create it as a new sbt project (which I did not want to do as I wanted to create it via activator)
I also had the project/play-fork-run.sbt file issue
I use Intellij Idea 16.3.3 and this problem appears sometimes. How I fixed it? You just need to open your SBT plugin and under your project get the context menu then you should choose "Ignore SBT project". After a current process is finished you should turn on this option again. This is work for me:)

How to use gradle in intellij idea plugin project?

I am developing an idea plugin, and it is an intellij idea project.
I want to use gradle to manage the dependency.
How to config?
There is now a Gradle plugin for building IntelliJ Platform Plugins. In order to use it, you will need to add the following snippet to your build.gradle file.
plugins {
id "org.jetbrains.intellij" version "0.0.31"
}
apply plugin: 'org.jetbrains.intellij'
For more information, please see this guide to help you get started.
Ok, there are multiple ways to create an IntelliJ project, "templates" if you like, and unfortunately you can only pick one of them (IntelliJ plugin or gradle).
Thankfully, it's easy to configure a project for gradle in IntelliJ.
First, create a new project from the IntelliJ Platform Plugin template. You don't need to choose any Additional Libraries and Frameworks. This will give you a project structure including META-INF/plugin.xml and the Project SDK should be something like IDEA IU-129.451.
From here, simply create a new file named build.gradle at the top level of your project, including for example this line:
apply plugin: 'java'
Now, close the project. You can now use File -> Import Project..., choose the build.gradle file that you just created, and import the project. Accept the defaults for importing and hit OK.
The project is now opened with both gradle and intellij plugin enabled!
Notice that the source root src has disappeared and you will need to right click on src in the Project pane and select Mark Directory As -> Source Root.
To prepare the plugin for deployment, there is still the menu option in the Build menu for that - if you want to automate that part via gradle, good luck and please let us know how it's done ;)

Auto reference d.ts files downloaded by intelliJ

I started creating a Test-Project for playing around with TypeScript in intelliJ IDEA 14. At first I added the angularjs_DefinitelyTyped TypeScript libraries in the Settings (Settings / Language & Frameworks / JavaScript / Libraries -> Download... -> TypeScript community stubs). At this point IntelliJ gave me the desired code-completition. I started creating a Controller as described here. Everything works fine.
The Problem I stumbled over occurs, when I installed the TypeScript transpiler with the "File Watchers"-Plugin as described in the IntelliJ IDEA 14 Web Help. Now I get the Error "error TS2304: cannot find name 'ng.'" when typing ... extends ng.IScope.
As i already downloaded the definition-Files I was hoping that the "File Watchers"-Plugin auto references these Files.
I tried manually referencing the these files but the TypeScript transpiler cannot resolve %userprofile%\.IntelliJIdea14\system\extLibs nor $USER_HOME$\....
Is there a solution without manually downloading and referencing all these Files in my Projects?
Does the tsc have an option to do this? I don't find anything about it.
Hope anybody can help me with this Problem ;-)
angularjs_DefinitelyTyped TypeScript libraries in the Settings (Settings / Language & Frameworks / JavaScript / Libraries -> Download... -> TypeScript community stubs).
That is how IntelliJ supports Type definitions for JavaScript projects. For TypeScript projects you need to include + reference the .d.ts files manually. TIP: create a vendor.d.ts file or use TSD : https://github.com/DefinitelyTyped/tsd/ it will create a reference tsd.d.ts file for you for all your imports

Global libraries in Intellij IDE

I have added a Java library in the Intellij IDE, but every time I start a new Java project I can't import this library, and have to set it up over again.
This is a screenshot from Intellij Project Structure:
The library is there, but when I try to import it I get an error:
Setting up a Global Library ensures that the library is defined, however it is not automatically added as a dependency to new projects.
You must go into Project Structure -> Modules, click the Dependencies tab and press the green + to add it to your project.
Or, instead, (and if IntelliJ is smart enough) after hitting F2 to navigate to one of the compile errors in your source code, Alt-enter might allow a quick fix to add the dependency (you'd have to try it...).

Can't replicate simple akka project in intelliJ

I am a new scala user and am having problems getting a development environment functional.
I downloaded the typesafe activator which launches an editor in a web browser and was able to run the akka actor tutorial script fine.
However, I have set up my intelliJ scala/akka environment, and when copying the same sample code to intelliJ, I am getting compile errors. I have added akka 2.2-M1 via maven to my project.
Initially when I copy
import akka.actor.{ActorSystem, Props, Actor, Inbox}
the last "Inbox" library is highlighted in red, and on compile I get "Error: object Inbox is not a member of package akka.actor. It suggests that I add akka.actor.dsl.Inbox. When I do that the import is greyed out because it is "not implimented", and get a compile error further down in the script when I go to implement inbox. It says "
not found: value Inbox
val inbox = Inbox.create(system)
"
What am I doing wrong? Thanks!
I would recommend you use sbt and then use the gen-idea plugin to create your intellij project.
You'll need to re-run gen-idea every time your dependencies change - intelliJ currently won't automatically discover and resolve managed dependencies for you.
here is the plugin with directions.
https://github.com/mpeltonen/sbt-idea
also, as a professional I would recommend you use the sbt console for most of your tasks.
Ctrl-tab 0 will let you hop over there without touching your mouse.
Escape brings you back to the code editor window.
You can run sbt ~test to test on change to your files etc.
Note you may need to change focus off of intellij for it to save the file in memory if you're use ~test
I managed to resolve the same issue by adding the following library from the Maven repository
com.typesafe.akka:akka-actor_2.10:2.2-M3
to File -- Project Structure -- Libraries