Problem with the idea plugin

I have a multi-module project in gradle which I open in Idea.

I use OSGi, and I need the Idea modules to have the Osmorc facet applied.

For this, I use the gradle Idea plugin, and I have some success modifying the module iml files to apply the facet. My problem is, that it’s the wrong iml-file I’m modifying!

My project is structured like this


  • m1

  • m2

  • m3

When I open the toplevel (Step) gradle build file, Idea/Gradle creates corresponding iml files in the Step root directory.

However, when I use the idea.module.iml construct, what I modify is iml files in the sub-directories, which isn’t the module files Idea is using.

I have solved the problem by changing the module.outputFile to point to the iml file Idea has created, but there seems to be something out of sync between the structure opened and created by idea, and the model used by the gradle idea plugin.

How are you opening the project in IDEA? Are you maybe importing it using the IDEA Gradle plugin? If you just open the Gradle-generated ‘.ipr’ file, IDEA shouldn’t generate anything, but just use the ‘.iws’, ‘.ipr’, and ‘.iml’ files generated by IDEA.

I begun with the build.gradle file, as I expected this to work much like opening a pom.xml - which it does. I’ve abandoned this approach now, and start by running the idea task. After that, I open the generated ipr file.

I do feel it’s wrong that opening the top level build.gradle results in a different module file structure than just running the gradle idea task, especially when the structure Idea generates by itself is not compatible with the gradle idea task.

You have to decide on whether to use Gradle’s IDEA plugin (and the file generation approach that comes with it) or IDEA’s Gradle plugin. Over time, the latter will become the preferred approach, but currently it’s still in an early state (seems like IDEA 12.1 will contain a major update).