From cf8cbb245b806eb101279f4236b053ddf1439bff Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Sat, 9 Dec 2023 22:27:06 +0000 Subject: [PATCH] Fix data gen folder not being added to resources. Closes https://github.com/FabricMC/fabricmc.net/issues/69 --- .../fabricmc/loom/configuration/FabricApiExtension.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/fabricmc/loom/configuration/FabricApiExtension.java b/src/main/java/net/fabricmc/loom/configuration/FabricApiExtension.java index 702a535b5..5a82ffbc5 100644 --- a/src/main/java/net/fabricmc/loom/configuration/FabricApiExtension.java +++ b/src/main/java/net/fabricmc/loom/configuration/FabricApiExtension.java @@ -28,7 +28,9 @@ import java.io.UncheckedIOException; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import javax.inject.Inject; import javax.xml.parsers.DocumentBuilder; @@ -104,7 +106,6 @@ public void configureDataGeneration(Action action) { DataGenerationSettings settings = getProject().getObjects().newInstance(DataGenerationSettings.class); settings.getOutputDirectory().set(getProject().file("src/main/generated")); settings.getCreateRunConfiguration().convention(true); - settings.getCreateSourceSet().convention(true); settings.getCreateSourceSet().convention(false); settings.getStrictValidation().convention(false); settings.getAddToResources().convention(true); @@ -117,7 +118,9 @@ public void configureDataGeneration(Action action) { if (settings.getAddToResources().get()) { mainSourceSet.resources(files -> { // Add the src/main/generated to the main sourceset's resources. - files.getSrcDirs().add(outputDirectory); + Set srcDirs = new HashSet<>(files.getSrcDirs()); + srcDirs.add(outputDirectory); + files.setSrcDirs(srcDirs); }); }