Skip to content

Commit 050eb5a

Browse files
authored
Handle idea modules not using the project build path. (#1201)
1 parent 6b18a7b commit 050eb5a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/main/java/net/fabricmc/loom/util/gradle/SourceSetHelper.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ public static List<File> getClasspath(SourceSetReference reference, Project proj
128128
final List<File> classpath = getGradleClasspath(reference, project);
129129

130130
classpath.addAll(getIdeaClasspath(reference, project));
131+
classpath.addAll(getIdeaModuleCompileOutput(reference));
131132
classpath.addAll(getEclipseClasspath(reference, project));
132133
classpath.addAll(getVscodeClasspath(reference, project));
133134

@@ -192,6 +193,25 @@ public static List<File> getIdeaClasspath(SourceSetReference reference, Project
192193
return Collections.singletonList(outputDir);
193194
}
194195

196+
private static List<File> getIdeaModuleCompileOutput(SourceSetReference reference) {
197+
final File dotIdea = new File(reference.project().getRootDir(), ".idea");
198+
199+
if (!dotIdea.exists()) {
200+
// Not an intellij project
201+
return Collections.emptyList();
202+
}
203+
204+
final String name = reference.sourceSet().getName();
205+
final File projectDir = reference.project().getProjectDir();
206+
final File outDir = new File(projectDir, "out");
207+
final File sourceSetOutDir = new File(outDir, name.equals(SourceSet.MAIN_SOURCE_SET_NAME) ? "production" : name);
208+
209+
return List.of(
210+
new File(sourceSetOutDir, "classes"),
211+
new File(sourceSetOutDir, "resources")
212+
);
213+
}
214+
195215
@Nullable
196216
private static String evaluateXpath(File file, @Language("xpath") String expression) {
197217
final XPath xpath = XPathFactory.newInstance().newXPath();

0 commit comments

Comments
 (0)