Skip to content

koppor/intellij-issue

Repository files navigation

Demonstration of IntelliJ issue

Filed as IntelliJ issue: IDEA-240250

IntelliJ 2020.1.1 201.7223.91 has an issue if a source directory is used in two Gradle projects

The build.gradle in buildSrc has following entry:

sourceSets{
    main {
        java {
            srcDir "${project.rootDir}/../src/main/java/shared"
        }
    }
}

If a Java class in src/main/java accesses a class in that directory, it is not found by the IntelliJ compiler:

package code;

import shared.Loader;

public class App {
    public static void main(String[] args) {
        System.out.println(Loader.TARGET);
    }
}
Error:(3, 14) java: package shared does not exist

Execution using gradle works:

$ ./gradlew run

> Task :run
loader

BUILD SUCCESSFUL in 1s
2 actionable tasks: 2 executed

Releases

No releases published

Packages

No packages published