Skip to content

Commit

Permalink
Make sure all the ClassesDirs are added to sourceDirs
Browse files Browse the repository at this point in the history
  • Loading branch information
jmini committed Mar 22, 2024
1 parent 5ceb6a0 commit 57183eb
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.Objects;
import java.util.Properties;
import java.util.Set;
import java.util.stream.Collectors;

import org.gradle.api.Project;
import org.gradle.api.Task;
Expand Down Expand Up @@ -532,6 +533,26 @@ private static void initProjectModule(Project project, WorkspaceModule.Mutable m

maybeConfigureKotlinJvmCompile(project, allClassesDirs, sourceDirs);

// some classesDir might be missing because the task was not found:
// see https://github.com/quarkusio/quarkus/issues/35577
final List<Path> existingSourceDirs = sourceDirs.stream().map(SourceDir::getOutputDir).collect(Collectors.toList());
allClassesDirs.getFiles().stream()
.filter(f -> f.exists())
.filter(f -> !existingSourceDirs.contains(f.toPath()))
.forEach(f -> {
((org.gradle.api.file.ConfigurableFileCollection) allClassesDirs).getBuiltBy().forEach(t -> {
Task task = (Task) (((org.gradle.api.tasks.TaskProvider<?>) t).get());
task.getInputs().getSourceFiles().getAsFileTree().visit(a -> {
// we are looking for the root dirs containing sources
if (a.getRelativePath().getSegments().length == 1) {
final File srcDir = a.getFile().getParentFile();
sourceDirs.add(
new DefaultSourceDir(srcDir.toPath(), f.toPath(), Map.of("compiler", task.getName())));
}
});
});
});

final LinkedHashMap<File, Path> resourceDirs = new LinkedHashMap<>(1);
final File resourcesOutputDir = sourceSet.getOutput().getResourcesDir();
project.getTasks().withType(ProcessResources.class, t -> {
Expand Down

0 comments on commit 57183eb

Please sign in to comment.