Fix remapped sources publishing (#1084)

This commit is contained in:
modmuss
2024-04-01 21:13:50 +01:00
committed by GitHub
parent ba8124e2d6
commit e96c0e2fbd

View File

@@ -163,11 +163,14 @@ public abstract class RemapTaskConfiguration implements Runnable {
}
if (getConfigurations().getNames().contains(JavaPlugin.SOURCES_ELEMENTS_CONFIGURATION_NAME)) {
getArtifacts().add(JavaPlugin.SOURCES_ELEMENTS_CONFIGURATION_NAME, remapSourcesTask);
// Remove the dev sources artifact
Configuration configuration = getConfigurations().getByName(JavaPlugin.SOURCES_ELEMENTS_CONFIGURATION_NAME);
configuration.getArtifacts().removeIf(a -> a.getFile().equals(sourcesJarTask.getArchiveFile().get().getAsFile()));
configuration.getArtifacts().removeIf(a -> "sources".equals(a.getClassifier()));
// Add the remapped sources artifact
getArtifacts().add(JavaPlugin.SOURCES_ELEMENTS_CONFIGURATION_NAME, remapSourcesTask.map(AbstractArchiveTask::getArchiveFile), artifact -> {
artifact.setClassifier("sources");
});
} else {
// Sources jar may not have been created with withSourcesJar
getProject().getLogger().warn("Not publishing sources jar as it was not found. Use java.withSourcesJar() to fix.");