IntelliJ project generation for Scala projects doesn't support IntelliJ 14

.iml has changed from

<component name="FacetManager">
  <facet type="scala" name="Scala">
    <configuration>
      <option name="compilerLibraryLevel" value="Project" />
      <option name="compilerLibraryName" value="scala-compiler-2.11.5" />
    </configuration>
  </facet>
</component>

to

<component name="NewModuleRootManager" inherit-compiler-output="true">
  ...
  <orderEntry type="library" name="scala-sdk" level="project" />
  ...
</component>

Until Gradle supports the new format, one has to follow a semi-automatic conversion process after each regeneration. It’s now also possible to configure the sdk on the module rather than project level, which might be a better fit for Gradle.

Here’s my workaround:

ext.scalaVersion = ‘2.11.4’

idea.project.ipr.withXml {

Node scalaSdkLib = it.node.component.find { it.@name == “libraryTable” }

.library.find { it.@name == “scala-compiler-$scalaVersion” }

scalaSdkLib.@name = “scala-sdk-$scalaVersion”

scalaSdkLib.@type = “Scala”

Node compilerClasspath = scalaSdkLib.appendNode(“properties”).appendNode(“compiler-classpath”)

def classesRoots = scalaSdkLib.CLASSES[0].children()

classesRoots.each { compilerClasspath.appendNode(“root”, [url: it.@url - ‘!/’]) }

classesRoots.clear()

}

gradle.projectsEvaluated {

allprojects {

idea.module.iml.withXml {

def facetManager = it.node.component.find { it.@name == ‘FacetManager’ }

def scalaFacet = facetManager?.find { it.name() == ‘facet’ && it.@type == ‘scala’ }

if (scalaFacet != null) {

facetManager.remove(scalaFacet)

it.node.component.find { it.@name == “NewModuleRootManager” }

.appendNode(“orderEntry”, [type: “library”, name: “scala-sdk-$scalaVersion”, level: “project”])

}

}

}

}

Thanks. Turns out that .ipr generation needs to be changed as well.

thanks Peter