Unresolved references across different Gradle srcDirs

I have a Gradle project with subprojects “server” and “client” plus a “common” dir that’s included as a srcDir via the build.gradle files of both subprojects. This was the best way I could think of to share code across separate server/client builds of a game.

I am sometimes unable to import the “common” packages from Kotlin code. For me it works on client but not on server, despite identical code and identical build.gradle files between the two. It works fine from Java code as well.

Minimal project demonstrating bug: GitHub - sf17k/kt-bug-multi-source-dir: For a bug report

Project root build.gradle:

buildscript {
    ext {
        kotlinVersion = '1.0.5'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
    }
}


allprojects {
    apply plugin: "idea"
    apply plugin: "java"
    apply plugin: "kotlin"

    repositories {
        mavenCentral()
    }

    dependencies {
        compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
    }
}

Subproject-specific build.gradle for both client and server:

sourceSets.main.java.srcDirs = [ "src/", "../common/src/" ]
sourceSets.main.kotlin.srcDirs = [ "src/", "../common/src/" ]

Screenshot, unresolved references when importing from common:

IntelliJ IDEA 2016.2.5
Build #IC-162.2228.15, built on October 14, 2016
JRE: 1.8.0_112-release-287-b2 x86
JVM: OpenJDK Server VM by JetBrains s.r.o