Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ Play2 and Scala plugins are not compatible. Makes IntelliJ 12 no longer work as expected

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?

like image 549
jakob Avatar asked Jun 26 '13 20:06

jakob


People also ask

How do I add Scala plugin to IntelliJ disk?

Open IntelliJ IDEA, go to File Menu --> Plugins --> [ Or directly press Ctrl+Alt+S ] Click on "Browse repositories" button and enter "Scala". Select Scala plugin to install it.

How do I change the Scala version in IntelliJ?

 In most cases your project JDK is not compatible with Scala or sbt version, try to change the Scala Compile Server SDK. Press Ctrl+Alt+S to open Settings/Preferences dialog. From the options on the left, select Build, Execution, Deployment | Compiler | Scala | Scala Compiler Server.

How do I enable Scala in IntelliJ?

To install Scala plugin, press Ctrl+Alt+S , open the Plugins page, browse repositories to locate the Scala plugin, click Install and restart IntelliJ IDEA. Now you can successfully check out from VCS, create, or import Scala projects.


2 Answers

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

like image 136
MrIveck Avatar answered Sep 21 '22 13:09

MrIveck


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 :-)

like image 30
stefan.schwetschke Avatar answered Sep 22 '22 13:09

stefan.schwetschke