Add option to disable deprecated POM generation and the warnings together with it (#487)

dev/0.11
Juuxel 2021-09-05 19:55:42 +03:00 committed by GitHub
parent 1a060df4bf
commit ea8ee4c21a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 1 deletions

View File

@ -34,6 +34,7 @@ import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.publish.maven.MavenPublication;
import org.jetbrains.annotations.ApiStatus;
import net.fabricmc.loom.api.decompilers.LoomDecompiler;
@ -184,4 +185,15 @@ public interface LoomGradleExtensionAPI {
* @return the property controlling the setup of remapped variants
*/
Property<Boolean> getSetupRemappedVariants();
/**
* Disables the deprecated POM generation for a publication.
* This is useful if you want to suppress deprecation warnings when you're not using software components.
*
* <p>Experimental API: Will be removed in Loom 0.12 together with the deprecated POM generation functionality.
*
* @param publication the maven publication
*/
@ApiStatus.Experimental
void disableDeprecatedPomGeneration(MavenPublication publication);
}

View File

@ -25,10 +25,12 @@
package net.fabricmc.loom.configuration;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.WeakHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import groovy.util.Node;
@ -49,6 +51,7 @@ public final class MavenPublication {
JavaPlugin.API_ELEMENTS_CONFIGURATION_NAME, "compile",
JavaPlugin.RUNTIME_ELEMENTS_CONFIGURATION_NAME, "runtime"
);
private static final Set<Publication> EXCLUDED_PUBLICATIONS = Collections.newSetFromMap(new WeakHashMap<>());
private MavenPublication() {
}
@ -88,7 +91,7 @@ public final class MavenPublication {
continue;
}
if (hasSoftwareComponent(publication)) {
if (hasSoftwareComponent(publication) || EXCLUDED_PUBLICATIONS.contains(publication)) {
continue;
} else if (!reportedDeprecation.get()) {
var deprecationHelper = LoomGradleExtension.get(project).getDeprecationHelper();
@ -142,4 +145,8 @@ public final class MavenPublication {
}
});
}
public static void excludePublication(Publication publication) {
EXCLUDED_PUBLICATIONS.add(publication);
}
}

View File

@ -32,6 +32,7 @@ import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.publish.maven.MavenPublication;
import net.fabricmc.loom.api.LoomGradleExtensionAPI;
import net.fabricmc.loom.api.MixinApExtensionAPI;
@ -152,6 +153,11 @@ public abstract class LoomGradleExtensionApiImpl implements LoomGradleExtensionA
protected abstract LoomFiles getFiles();
@Override
public void disableDeprecatedPomGeneration(MavenPublication publication) {
net.fabricmc.loom.configuration.MavenPublication.excludePublication(publication);
}
// This is here to ensure that LoomGradleExtensionApiImpl compiles without any unimplemented methods
private final class EnsureCompile extends LoomGradleExtensionApiImpl {
private EnsureCompile() {

View File

@ -31,6 +31,7 @@ import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.publish.maven.MavenPublication;
import net.fabricmc.loom.api.LoomGradleExtensionAPI;
import net.fabricmc.loom.api.MixinApExtensionAPI;
@ -137,4 +138,10 @@ public class MinecraftGradleExtension implements LoomGradleExtensionAPI {
reportDeprecation();
return parent.getSetupRemappedVariants();
}
@Override
public void disableDeprecatedPomGeneration(MavenPublication publication) {
reportDeprecation();
parent.disableDeprecatedPomGeneration(publication);
}
}