-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure that reverse routing works with vanilla play idea from Java project in IntelliJ #969
Comments
What is the exact problem? I can open a plain play-java project into idea and access the reverse routing without problem. But I see some other problems:
|
I just happened to notice this too (the original request I made was for someone else). It seems that IntelliJ 12.1 isn't able to infer the return type of Scala methods invoked from Java code if they return a generic type. |
The reason that the controller is complaining because the project is not compiled hence no reverse route files generated. So if you compile the project before opening in the IDE that error should go away. The second problem is if you try to build the project it fails because we don't add Scala Facet for Java projects. I think the proper fix for this should be to run the compile task before generating the IDEA project files automatically(we do that for eclipse) and add the Scala facet for both Scala and Java projects. The problem is there is no mechanism to assign preTasks for SbtIdeaPlugin and I cannot find a way to hook into the "idea" command. So for the time being we can add the Scala facet and mention in the docs to run compile to fix any additional compilation problems. Thoughts? |
It seems to be more than this. I had the scala facet enabled (I think), and I still get the highlighting error. In a Scala project it seems to work, but the routes.java generated file has errors in it. I think this is actually caused by an IntelliJ issue. |
Opened issue with IntelliJ: http://youtrack.jetbrains.com/issue/IDEA-106570 |
It seems like on my machine this only affects
So, my hypothesis is: might the issue be caused by the fact that many packages and classes are defined in the single Scala file Not sure about how to solve this, but can we synchronize folder structure with package structure here? The file |
Haha, even simpler workaround: I created empty directories |
I'm running a Scala project and actually have the same problem. It looks like my controllers don't have any methods defined (apart from those derived from java.lang.Object). |
I'm unable to reproduce this issue with IntelliJ 12.1.4 and the Scala plugin 0.16.293. Please note that I also have the Play 2.0 Support plugin from JetBrains: 0.16.294 |
Exactly the same problem. IDEA 12.1.5 can't recognise controller methods from reverse routing. Tried recompiling and creating ref and javascript folders. |
this is still an issue even for scala projects with latest intellij-scala plugin and play 2.2.1-RC1 |
@OlegYch Including IntelliJ 13? |
On Thursday, December 5, 2013 2:52:23 AM, Christopher Hunt wrote:
yep Thanks, Aleh |
The IntelliJ issue remains open so I think we can keep this as closed for now. |
Why don't you just generate ref and javascript folders to workaround it? |
Sure, add this to your build: sourceGenerators in Compile <+= sourceManaged in Compile map { dir: File =>
val dirs = Seq(dir / "ref", dir / "javascript")
dirs.foreach(_.mkdirs)
dirs
} |
I think that should be: val dirs = Seq(dir / "main" / "controllers" / "ref", dir / "main" / "controllers" / "javascript") right? Anyways, compilation ends in error:
|
Yeah, it doesn't work. |
this should work
|
why is that so hard to release? |
Easier fix-- unmark "controllers" and "views" as source roots in IntelliJ, and mark "main" as a source root. That fixes syntax highlighting/completion/etc. |
+10 (1 for each module in which I have to change it manually) |
Please note that http://youtrack.jetbrains.com/issue/SCL-5635 remains open. If you feel we can work around this then please open an associated PR. Thanks. |
I found the solution to this issue by changing the source paths in the Module Settings of the IDEA project as explained here: |
This is an issue with sbt-idea. The workaround is to unmark the controllers directory (e.g. target/scala-2.11/src_managed/main/controllers) as a source root, and mark the main folder (e.g. target/scala-2.11/src_managed/main) as a source root. Then IntelliJ will find everything properly. This really should be fixed, either by changing where Play puts the compiled routes files (since sbt-idea expects everything to be put into subfolders within compile:managedSources), or to submit this as a bug in sbt-idea. |
The bug is in sbt-idea. Play must put the compiled routes files in Note though that in master (Play 2.4), we're now using a completely different directory outside of |
Note that this is kind of a non-issue with IntelliJ 13 and the updated SBT support. Reverse routing support gets automatically picked up. |
@NIA's workaround works even in IntelliJ IDEA 14. |
This issue is very very confusing and I'm surprised it still hasn't been fixed. Yes, NIAs workaround works, but it took me quite some time until I found this issue. So for the sake of any future Play Java dev (and the chance is high they are using IntelliJ Idea), I really hope it'll go away with Play 2.4. |
This is still going on in latest Intellij 14.1; NIAs workaround is still OK |
I put @OlegYch 's answer in my Build.scala and reload the project. So I have to add source folder manually every time after project reload : ( |
FWIW, none of these solutions work for me with Play 2.3.8 and IJ 14.1.x :( |
I'm not sure if this is the same problem, but when trying to perform a I'm attempting to follow the basic play framework example (YouTube video on front page of playframework.com) with IntelliJ 14.0.4 and latest version of Play (2.3.8?). |
I should have provided a screen shot, I'm having the exact same issue. Everything compiles and runs fine, just annoying to look at in IntelliJ. |
Yep, I have the same problem using intellij idea 14 |
I had the same problem with Intellij Idea 14.1.4 and play framework 2.4.2 but I managed to solve the issue with the help of the link @ghost added but it was old so I had to make little changes, here is what I did. |
@hossamahamid I can't exclude the "./target" directory but I can exclude "project->target", nevertheless, the file "scala-2.11/routes/main" is in the "./target" directory. When you refer to "target" are you referring to the "target" directory placed at the root directory of the project? Maybe I can't do the expected operations because I added a related project in the build.sbt: name := """WHTTP-front"""
version := "1.0-SNAPSHOT"
lazy val wcommon = RootProject(file("../WCommon"))
val root = (project in file(".")).enablePlugins(PlayScala).dependsOn(wcommon)
scalaVersion := "2.11.6"
//val whttp_front = Project(id = "root", base = file("."))
libraryDependencies ++= Seq(
jdbc,
cache,
ws,
specs2 % Test
)
libraryDependencies +=
"com.typesafe.akka" %% "akka-remote" % "2.4-SNAPSHOT"
resolvers += "Akka Snapshot Repository" at "http://repo.akka.io/snapshots/"
resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"
// 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 have cancelled exlusion for the |
@vicaba yes I mean the target directory at the root. That's weird but try to exclude the target directory from the module settings window. You can open it by right click on the project directory and choosing "Open Module Settings", or by selecting "Project Structure" from "File" menu then "Modules". |
@hossamahamid I've tried it and nothing changes. I've tried several combinations too, but I can't get it working. Change the inspections configuration by clicking on the man with a hat at the bottom right. I'll give it another try in a few days after doing a OS clean install. Thank you all for the support anyway. |
@vicaba I have the same issue, I think we need to wait for Jetbrans to fix this (in the ultimate version) because I don't see how it could work without some form of "hack" from the tool vendor. As controllers are now classes the statement route..method will always be invalid because in Scala you can't call a method on a class. |
@thobson Yep, that's just what I was thinking... We will have to wait. |
@vicaba I just found an EAP version of the plugin which seems to work in most cases. Take a look here and download the 1.5.2.3.EAP version of the plugin. You will need to uninstall the exisiting Scala plugin then copy this new version into the plugins directory, giving it the folder name "Scala". Of course it's EAP software so it's not perfect but it does seem to work ok for me (so far!) |
@thobson Thanks, I'll try it as soon as I can :) |
Scala plugin 1.5.2.3.EAP version didn't work for me. I went with disabling disabiling the play routing action inspection rather. |
It's closed because it's a problem with the way IntelliJ imports projects, not with Play, so the issue doesn't belong in Play's issue tracker. |
In a Java project, IntelliJ seems to consider reverse routes as syntax errors in.
The text was updated successfully, but these errors were encountered: