diff --git a/src/main/java/net/fabricmc/loom/util/gradle/SourceSetHelper.java b/src/main/java/net/fabricmc/loom/util/gradle/SourceSetHelper.java index 209703d64..a49cac45b 100644 --- a/src/main/java/net/fabricmc/loom/util/gradle/SourceSetHelper.java +++ b/src/main/java/net/fabricmc/loom/util/gradle/SourceSetHelper.java @@ -128,6 +128,7 @@ public static List getClasspath(SourceSetReference reference, Project proj final List classpath = getGradleClasspath(reference, project); classpath.addAll(getIdeaClasspath(reference, project)); + classpath.addAll(getIdeaModuleCompileOutput(reference)); classpath.addAll(getEclipseClasspath(reference, project)); classpath.addAll(getVscodeClasspath(reference, project)); @@ -192,6 +193,25 @@ public static List getIdeaClasspath(SourceSetReference reference, Project return Collections.singletonList(outputDir); } + private static List getIdeaModuleCompileOutput(SourceSetReference reference) { + final File dotIdea = new File(reference.project().getRootDir(), ".idea"); + + if (!dotIdea.exists()) { + // Not an intellij project + return Collections.emptyList(); + } + + final String name = reference.sourceSet().getName(); + final File projectDir = reference.project().getProjectDir(); + final File outDir = new File(projectDir, "out"); + final File sourceSetOutDir = new File(outDir, name.equals(SourceSet.MAIN_SOURCE_SET_NAME) ? "production" : name); + + return List.of( + new File(sourceSetOutDir, "classes"), + new File(sourceSetOutDir, "resources") + ); + } + @Nullable private static String evaluateXpath(File file, @Language("xpath") String expression) { final XPath xpath = XPathFactory.newInstance().newXPath();