Handle no sourcesElements configuration.

dev/0.11
modmuss50 2022-01-26 14:15:44 +00:00
parent 98b87969cb
commit f1bc512eca
1 changed files with 9 additions and 4 deletions

View File

@ -125,11 +125,16 @@ public class RemapTaskConfiguration {
task.getInputFile().convention(sourcesJarTask.getArchiveFile());
if (extension.getSetupRemappedVariants().get()) {
project.getArtifacts().add(JavaPlugin.SOURCES_ELEMENTS_CONFIGURATION_NAME, task);
if (project.getConfigurations().getNames().contains(JavaPlugin.SOURCES_ELEMENTS_CONFIGURATION_NAME)) {
project.getArtifacts().add(JavaPlugin.SOURCES_ELEMENTS_CONFIGURATION_NAME, task);
// Remove the dev sources artifact
Configuration configuration = project.getConfigurations().getByName(JavaPlugin.SOURCES_ELEMENTS_CONFIGURATION_NAME);
configuration.getArtifacts().removeIf(a -> a.getFile().equals(sourcesJarTask.getArchiveFile().get().getAsFile()));
// Remove the dev sources artifact
Configuration configuration = project.getConfigurations().getByName(JavaPlugin.SOURCES_ELEMENTS_CONFIGURATION_NAME);
configuration.getArtifacts().removeIf(a -> a.getFile().equals(sourcesJarTask.getArchiveFile().get().getAsFile()));
} else {
// Sources jar may not have been created with withSourcesJar
project.getLogger().warn("Not publishing sources jar as it was not found. Use java.withSourcesJar() to fix.");
}
}
});