IntelliJ: Importing only some of the modules

I work with a large project with over 100 subprojects. Our developers want to use IntelliJ projects which load only the current project and its dependencies.

For example, suppose we have the following projects: Base: no dependencies Log: depends on Base Lib: depends on Log and Base App1: depends on Lib, Log, and Base App2: depends on Log and Base

If I import App1 in IntelliJ, I should end up with a project containing Base, Log, Lib, and App1, ignoring App2. If I import App2, I should end up with a project containing Base, Log, and App2, ignoring Lib and App1.

Until now, I’ve had the developers generate the IntelliJ projects by hand. I used the default IdeaModule task to generate the IML files along with a completely custom task to hand-generate .idea/modules.xml. Now, I’m trying to use IntelliJ’s native Gradle importer. Unfortunately, since my custom tasks don’t change the model, when I tell IntelliJ to import my Gradle build, it imports everything (Base, Log, Lib, App1, and App2).

I’ve hacked up code to set project.ideaModule.enabled to false for projects that aren’t depended on by the project (I found that property in another forum post - is that even documented?), but it’s very inefficient, since Idea still does all the work (fetching dependencies, etc) for the modules that end up getting disabled.

What’s the most efficient way to do this?

You could try only applying the IDEA plugin to the projects that you want to import. I think the IDEA Gradle support will respect this.

Actually, Idea will import a project even if it doesn’t have the Idea plugin applied.

Unfortunately there is no solution to this on the Gradle side then.

You’ll have to raise an issue with JetBrains if there isn’t already one existing.