0
votes

I have this minimal project structure, where core is supposed to depend on common:

myproj/
    core/
        build.gradle.kts
    common/
        build.gradle.kts
    build.gradle.kts
    settings.gradle.kts

myproj/build.gradle.kts:

allprojects {
    repositories {
        jcenter()
    }
}

subprojects {
    version = "0.1"
}

myproj/settings.gradle.kts:

rootProject.name = "myproj"

include("myproj-common")
project(":myproj-common").projectDir = File("common")
include("myproj-core")
project(":myproj-core").projectDir = File("core")

myproj/core/build.gradle.kts:

plugins {
    kotlin("jvm") version "1.3.11"
}

dependencies {
    compile(project(":myproj-common"))
}

myproj/common/build.gradle.kts:

plugins {
    kotlin("jvm") version "1.3.11"
}

When I import this setup into IntelliJ, it finishes successfully, but if I open the module settings for myproj-core, myproj-common is not in the dependencies. What am I missing here?

I'm using IntelliJ 2018.3 Community, and Gradle 5.0.

1

1 Answers

0
votes

I figured out what the "problem" was - I wasn't looking at the right place.

When importing a project, by default IntelliJ creates one module per source set. For example, under module myproj.myproj-core, it creates two separate modules myproj.myproj-core.main and myproj.myproj-core.test, each corresponding to one of the source sets. The module dependencies are then added at these sub-submodule levels. So myproj.myproj-core.main depends on myproj.myproj-common.main, and similarly for the test module.

If I import the project with the "create separate module per source set" cleared off, it won't create those sub-submodules, and myproj.myproj-core simply depends on myproj.myproj-common.