Fix client only sources missing from sources jar registered after enabling split sourcesets.

This commit is contained in:
modmuss50
2022-06-20 20:23:39 +01:00
parent 78db6145fd
commit ac0917e9cb

View File

@@ -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());
});
}