IntelliJ Play2 and Scala plugins are not compatibl

2019-06-21 21:52发布

I upgraded my IntelliJ(12.1.4) to the new Play 2.0 Support(0.5.54) plugin and two things happened:

  1. IntelliJ no longer recompiles my .scala classes, this meaning that if I e.g change the signature of a method from def something(s1: String) = {} to def something(s1: String, s2: String) = {} I get an error that ) is expected after the first param. I run the app from the terminal with play debug ~run and there the app recompiles without a problem.

  2. The scala.html are not evaluated properly and I get a lot of syntax errors. The color encoding is also wrong. I tried to change the Scala plugin to the nightly build(0.10.281) as suggested in the comments but it still doesn't work.

This is crazy bad since it makes working with the IntelliJ painful and counterproductive. There is a bug reported: http://youtrack.jetbrains.com/issue/SCL-5749 but what should I do in the meantime? Anybody solved this issue?

4条回答
该账号已被封号
2楼-- · 2019-06-21 22:30

Good news everyone: Play 2.0 plugin and Scala plugin versions are synchronized again! For IDEA12 there are 0.13.286 versions (of both) now. After updating I see some new highlighting errors, but at least they work, and there are no error messages about incompatibility!

So, it seems like it is safe now to update to the latest version of both through the built-in mechanism.

From now the build process of Scala and Play 2.0 plugins is common, so Play 2.0 plugin has the same build number.

— this also gives some hopes for not repeating the same problem in future.

查看更多
Emotional °昔
3楼-- · 2019-06-21 22:32

For me play2.0 version 0.2.49 with scala version 0.10.279 does the trick. With the other versions I ether get bugs, or my IDE just doesn't work correct.

link to play plugin: http://plugins.jetbrains.com/plugin/download?pr=&updateId=13272

link to scala plugin: http://plugins.jetbrains.com/plugin/download?pr=&updateId=13504

instructions:

1 download the .zip (do not extract)

2 make sure there are no play or scala plugins in your IDE folder (C:\Program Files (x86)\JetBrains\IntelliJ IDEA 12.1.2\plugins)

3 op the IDE and open the plugin menu. (file -> settings... -> plugins

4 click the button "install from disk" and select the play zip file and the scala zip file. (you don't need to disable the play and scala plugin in the plugin list, they get swapped after the IDE restart

5 restart your IDE

6(optional) report back here if it worked or not

查看更多
放我归山
4楼-- · 2019-06-21 22:47

Use the IntelliJ sbt plugin and compile your classes from sbt with "~compile". You can start play with "container:start".

Here is my own Build.scala file I run from within IntelliJ:

import sbt._
import Keys._
import play.Project._

object ApplicationBuild extends Build {

  val appName         = "Blade_Night_App"
  val appVersion      = "1.0-SNAPSHOT"

  val appDependencies = Seq(
    // Add your project dependencies here,
    jdbc,
    anorm
  )

  val main = play.Project(appName, appVersion, appDependencies).settings(
    // Add your own project settings here      
  )

}

And here the plugins.sbt:

// Comment to get more information during initialization
logLevel := Level.Warn

// The Typesafe repository 
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// Use the Play sbt plugin for Play projects
addSbtPlugin("play" % "sbt-plugin" % "2.1.0")

Additional I have a Debug configuration for a Scala application with

  1. Main class: xsbt.boot.Boot
  2. VM-Options: -Dfile.encoding=UTF8 -Dsbt.boot.properties=file:///.../play-2.1-RC4/framework/sbt/sbt.boot.properties -Dplay.version=2.1-RC4 -Dsbt.ivy.home=.../play-2.1-RC4\repository -Dplay.home=.../play-2.1-RC4/framework -Xms128M -Xmx512M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M
  3. Program argument: run

This replaces the Play plugin completely for me :-)

查看更多
孤傲高冷的网名
5楼-- · 2019-06-21 22:47

The problem here is that there is a massive incompatibility with the newer Scala plugins and the Play plugin in general. To get it to work, you have to use Scala plugin version 0.7.264 (that is the specific version number the support person gave to me anyway). I had this issue as well and, to be safe, I also reverted back to Play plugin version 0.2.26. Everything works as it did before now.

To go back to the previous version, you have to download the ZIP archive from the JetBrains plugin site and choose "install from disk" in IntelliJ IDEA. Here is the link to get the older Scala plugin version you need: http://plugins.jetbrains.com/plugin/?id=1347

This is a big compatibility issue and apparently JetBrains is aware of it, but only by contacting their help desk did I find out how to fix it for now until a more permanent solution comes along.

查看更多
登录 后发表回答