From ac0917e9cb2d9a96f7889758216a9b8caa423fbc Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Mon, 20 Jun 2022 20:23:39 +0100 Subject: [PATCH] Fix client only sources missing from sources jar registered after enabling split sourcesets. --- .../providers/minecraft/MinecraftSourceSets.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/MinecraftSourceSets.java b/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/MinecraftSourceSets.java index 1893703a..700b9b74 100644 --- a/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/MinecraftSourceSets.java +++ b/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/MinecraftSourceSets.java @@ -209,13 +209,15 @@ public abstract sealed class MinecraftSourceSets permits MinecraftSourceSets.Sin ); }); - if (project.getTasks().findByName(mainSourceSet.getSourcesJarTaskName()) == null) { - // No sources. - return; - } + // The sources task can be registered at a later time. + project.getTasks().withType(Jar.class, sources -> { + if (!mainSourceSet.getSourcesJarTaskName().equals(sources.getName())) { + // Not the sources task we are looking for. + return; + } - project.getTasks().named(mainSourceSet.getSourcesJarTaskName(), Jar.class).configure(jar -> { - jar.from(clientOnlySourceSet.getAllSource()); + // The client only sources to the combined sources jar. + sources.from(clientOnlySourceSet.getAllSource()); }); }