From 38332bfbe3fe78c5f07233ee544c9a3274746de4 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Mon, 6 May 2024 17:21:12 -0700 Subject: [PATCH 1/3] Add support for shadow under forked plugin id fixes #145 I also considered checking for the existence of the ShadowPlugin class instead, however it wouldn't work due to the classloader isolation we already work around. --- .../gradle/vanilla/VanillaGradle.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/subprojects/gradle-plugin/src/main/java/org/spongepowered/gradle/vanilla/VanillaGradle.java b/subprojects/gradle-plugin/src/main/java/org/spongepowered/gradle/vanilla/VanillaGradle.java index a12a4fb..da8bd12 100644 --- a/subprojects/gradle-plugin/src/main/java/org/spongepowered/gradle/vanilla/VanillaGradle.java +++ b/subprojects/gradle-plugin/src/main/java/org/spongepowered/gradle/vanilla/VanillaGradle.java @@ -61,6 +61,8 @@ import java.lang.reflect.InvocationTargetException; import java.net.URL; import java.net.URLClassLoader; +import java.util.Arrays; +import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Stream; @@ -71,6 +73,10 @@ public final class VanillaGradle implements Plugin { private static final String SHADOW_JAR_TASK_CLASS_NAME = "com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar"; + private static final List SHADOW_PLUGIN_IDS = Arrays.asList( + "com.github.johnrengelman.shadow", + "io.github.goooler.shadow" + ); private static final AtomicBoolean VERSION_ANNOUNCED = new AtomicBoolean(); @Override @@ -107,10 +113,12 @@ private void applyToProject(final Project project) { }); }); - project.getPlugins().withId("com.github.johnrengelman.shadow", plugin -> { - final Provider> provider = project.provider(new ResolveMinecraftLibNames(minecraftConfig)); - VanillaGradle.applyShadowConfiguration(project.getTasks(), provider, plugin); - }); + for (final String shadowPluginId : SHADOW_PLUGIN_IDS) { + project.getPlugins().withId(shadowPluginId, plugin -> { + final Provider> provider = project.provider(new ResolveMinecraftLibNames(minecraftConfig)); + VanillaGradle.applyShadowConfiguration(project.getTasks(), provider, plugin); + }); + } this.createDumpClass(project, minecraftConfig); this.createDisplayMinecraftVersions(project.getPlugins().getPlugin(MinecraftRepositoryPlugin.class).service(), project.getTasks()); From 3ac9712a4384ff8f5e8308c4e101d8df17a530ed Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Mon, 6 May 2024 19:19:37 -0700 Subject: [PATCH 2/3] Make shadow ids unmodifiable --- .../java/org/spongepowered/gradle/vanilla/VanillaGradle.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/subprojects/gradle-plugin/src/main/java/org/spongepowered/gradle/vanilla/VanillaGradle.java b/subprojects/gradle-plugin/src/main/java/org/spongepowered/gradle/vanilla/VanillaGradle.java index da8bd12..62c31cd 100644 --- a/subprojects/gradle-plugin/src/main/java/org/spongepowered/gradle/vanilla/VanillaGradle.java +++ b/subprojects/gradle-plugin/src/main/java/org/spongepowered/gradle/vanilla/VanillaGradle.java @@ -24,6 +24,7 @@ */ package org.spongepowered.gradle.vanilla; +import java.util.Collections; import org.checkerframework.checker.nullness.qual.NonNull; import org.gradle.api.GradleException; import org.gradle.api.NamedDomainObjectProvider; @@ -73,10 +74,10 @@ public final class VanillaGradle implements Plugin { private static final String SHADOW_JAR_TASK_CLASS_NAME = "com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar"; - private static final List SHADOW_PLUGIN_IDS = Arrays.asList( + private static final List SHADOW_PLUGIN_IDS = Collections.unmodifiableList(Arrays.asList( "com.github.johnrengelman.shadow", "io.github.goooler.shadow" - ); + )); private static final AtomicBoolean VERSION_ANNOUNCED = new AtomicBoolean(); @Override From 5dba2c3eab5134a965e59e8a98e913e420b27d63 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Mon, 6 May 2024 19:20:14 -0700 Subject: [PATCH 3/3] fix import order --- .../java/org/spongepowered/gradle/vanilla/VanillaGradle.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/gradle-plugin/src/main/java/org/spongepowered/gradle/vanilla/VanillaGradle.java b/subprojects/gradle-plugin/src/main/java/org/spongepowered/gradle/vanilla/VanillaGradle.java index 62c31cd..e1ee49d 100644 --- a/subprojects/gradle-plugin/src/main/java/org/spongepowered/gradle/vanilla/VanillaGradle.java +++ b/subprojects/gradle-plugin/src/main/java/org/spongepowered/gradle/vanilla/VanillaGradle.java @@ -24,7 +24,6 @@ */ package org.spongepowered.gradle.vanilla; -import java.util.Collections; import org.checkerframework.checker.nullness.qual.NonNull; import org.gradle.api.GradleException; import org.gradle.api.NamedDomainObjectProvider; @@ -63,6 +62,7 @@ import java.net.URL; import java.net.URLClassLoader; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean;