Add option to disable deprecated POM generation and the warnings together with it (#487)
parent
1a060df4bf
commit
ea8ee4c21a
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue