Fabian Zeindl
Fabian Zeindl

Reputation: 5988

IntelliJ IDEA and Gradle: Why there are 3 modules per sub-module?

I am rather confused by IntelliJ IDEA's gradle integration and the mapping of gradle subprojects to IDEA's modules.

Project Structure

UPDATE

enter image description here

Upvotes: 24

Views: 19070

Answers (2)

Robert Golusiński
Robert Golusiński

Reputation: 358

If you want to just disable this option for a previously imported project you can do so by editing idea gradle configuration file located in .idea/gradle.xml.

Add this line that sets resolveModulePerSourceSet to false:

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  ...
  <component name="GradleSettings">
    <option name="linkedExternalProjectsSettings">
      <GradleProjectSettings>
        ...
        <option name="resolveModulePerSourceSet" value="false" />
      </GradleProjectSettings>
    </option>
  </component>
</project>

And then refresh the gradle project.

Upvotes: 16

Sri Harsha Chilakapati
Sri Harsha Chilakapati

Reputation: 11940

It is now possible to deselect that option when importing the gradle project in IDEA, checked in 2016.1.2 Ultimate IDE. First go to the import gradle option and select your gradle file.

Project Import Dialog

Then in the dialog that appears, make sure you deselect the option that says create separate module per source set. This is selected by default. Now continue with importing the project as you normally would.

Gradle configuration dialog

And that's it, you can enjoy your project, just one module will be created for each sub project in the multi project gradle build.

This option is only useful if you are having a separate sub project in gradle for the tests like me. Otherwise, the default way works pretty much good, as I found it more easy to launch unit tests.

Imported project, package view

Hope this helps.

Upvotes: 22

Related Questions