From 956f48d8e96402a558ad1b1b819830843714e706 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Sat, 26 Oct 2024 17:19:06 +0100 Subject: [PATCH] Handle idea modules not using the project build path. --- .../loom/util/gradle/SourceSetHelper.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) 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();