IDEA module dependency issue - Gradle composite builds with project having multiple sourcesets

Answered

Hi,

The IDEA support for Gradle composite build seems to be not able to properly identify all the inter-module dependencies if:

  1. one of the dependency project have more than one sourcesets, and
  2. create separate module for different sourcesets is checked.

To demonstrate the issue, I have created two sample projects: project-a and project-b, where project-b is setup as composite build having a dependency on project-a. project-a has an extra util sourceset in addition to main. However, the compilation of main depends on util, and the output of util is also included in the output of main. Once project-b is imported into IDEA, the module project-b_main only has a module dependency on project-a_main, but not on project-a_util, hence the project cannot be built using IDEA.

project-b/settings.gradle:

    rootProject.name = "project-b"
    includeBuild '../project-a'

project-b/build.gradle:

    ...
    dependencies {
        compile group: 'org.demo', name: 'project-a', version: '0.0.1-SNAPSHORT'
    }
 
project-a/build.gradle:

    sourceSets {
        util {
            java.srcDir 'src/util/java'
            resources.srcDir 'src/util/resources'
        }
    }

    configurations {
        compile {
            extendsFrom utilCompile
        }
    }

    dependencies {
        compile sourceSets.util.output
    }

    jar {
        from sourceSets.util.output
    }

    compileJava {
        dependsOn(compileUtilJava)
    }
 

Did I miss anything in the setup? Or if there is a workaround ?
 
Issue created here with sample projects: https://youtrack.jetbrains.com/issue/IDEA-181187
 
Thanks,
Xinchao
2

Please sign in to leave a comment.