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

前端 未结 2 723
梦毁少年i
梦毁少年i 2021-01-30 23:11

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

  • Why are there 3 modules for every gradle subp
相关标签:
2条回答
  • 2021-01-31 00:02

    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.

    0 讨论(0)
  • 2021-01-31 00:08

    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.

    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.

    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.

    Hope this helps.

    0 讨论(0)
提交回复
热议问题