Skip to content

Commit

Permalink
Handle idea modules not using the project build path. (#1201)
Browse files Browse the repository at this point in the history
  • Loading branch information
modmuss50 authored Oct 26, 2024
1 parent 6b18a7b commit 050eb5a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/main/java/net/fabricmc/loom/util/gradle/SourceSetHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public static List<File> getClasspath(SourceSetReference reference, Project proj
final List<File> classpath = getGradleClasspath(reference, project);

classpath.addAll(getIdeaClasspath(reference, project));
classpath.addAll(getIdeaModuleCompileOutput(reference));
classpath.addAll(getEclipseClasspath(reference, project));
classpath.addAll(getVscodeClasspath(reference, project));

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

private static List<File> 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();
Expand Down

0 comments on commit 050eb5a

Please sign in to comment.