Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle idea modules not using the project build path. #1201

Merged
merged 1 commit into from
Oct 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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