Intellij project files are missing scala facet for multi module projects with gradle 1.5

With gradle 1.5, running gradle idea to generate intellij project files does not properly add the scala facet to modules that apply the scala plugin within a multi module project. This prevents any scala from being compiled in intellij (and thus prevents the project from building there)

Manually adding the framework support in intellij causes the scala to be compiled within intellij, but there are too many modules for it to be feasible to do this each time gradle idea is run.

gradle build works fine for the project from the command line (ubuntu 12.04)

According to this page, applying the scala plugin should automatically configure intellij:

“When the IDEA plugin encounters a Scala project, it adds additional configuration to make the project work with IDEA out of the box. Specifically, the plugin adds a Scala facet and a Scala compiler library that matches the Scala version on the project’s class path.”

http://www.gradle.org/docs/current/userguide/scala_plugin.html

Everything works as expected using gradle 1.4 and the idea-scala-project plugin.

How can I get the scala facet to be added when running gradle idea on a multi module mixed scala and java project? Is there some way to work around this? Is there some other plugin I should use instead?

Works fine for me. Can you provide a self-contained example that demonstrates the problem?

I am having this same problem with gradle 1.5 and IDEA 12.1.2.

I can reproduce the problems with Peter Walker’s example found here: https://github.com/peterwalker/scala-samples

Note that I found that example from a gradle JIRA issue (http://issues.gradle.org/browse/GRADLE-1018), which seems to indicate a similar problem that was resolved in a 1.5 RC.

The following works just fine for me:

  • git clone git@github.com:peterwalker/scala-samples.git * gradle idea * open scala-samples.ipr * IDEA project has Scala facet configured and builds without errors.

This is with Gradle 1.5 and IDEA 12.1.3 EAP on a Mac. I’m pretty sure that earlier IDEA versions will work as well, since that’s what I used when I developed the feature.

Peter,

Thanks for the fast reply. Your step 3 was exactly my problem. I’m migrating from Eclipse to IDEA at the same time I’m learning Gradle, so I’m still an IDEA novice as well.

I was attempting to “Open Project” with IDEA on the folder, which doesn’t work (of course), so then I was choosing “Import Project” which was what led to my ruin.

For anyone else having troubles here, just be sure to open the .ipr file and not attempt to do a project open on the folder, and you should be fine.

Thanks again.