From e263e91e27ce626ea5311a66a4a13c8ac12d85bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ossi=20Erkkil=C3=A4?= Date: Sun, 19 May 2024 15:02:25 +0300 Subject: [PATCH 1/2] Support shadow plugin forks --- .../java/org/spongepowered/gradle/common/Constants.java | 9 ++++++++- .../spongepowered/gradle/plugin/SpongePluginGradle.java | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/plugin-development/src/main/java/org/spongepowered/gradle/common/Constants.java b/plugin-development/src/main/java/org/spongepowered/gradle/common/Constants.java index b12c7de..1cef3db 100644 --- a/plugin-development/src/main/java/org/spongepowered/gradle/common/Constants.java +++ b/plugin-development/src/main/java/org/spongepowered/gradle/common/Constants.java @@ -24,6 +24,10 @@ */ package org.spongepowered.gradle.common; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + public final class Constants { public static final String NAME = "SpongeGradle"; @@ -48,7 +52,10 @@ private Dependencies() { } public static final class Plugins { - public static final String SHADOW_PLUGIN_ID = "com.github.johnrengelman.shadow"; + public static final List SHADOW_PLUGIN_IDS = Collections.unmodifiableList(Arrays.asList( + "com.github.johnrengelman.shadow", + "io.github.goooler.shadow" + )); public static final String SHADOW_JAR_TASK_NAME = "shadowJar"; private Plugins() { diff --git a/plugin-development/src/main/java/org/spongepowered/gradle/plugin/SpongePluginGradle.java b/plugin-development/src/main/java/org/spongepowered/gradle/plugin/SpongePluginGradle.java index d19329f..a692cc8 100644 --- a/plugin-development/src/main/java/org/spongepowered/gradle/plugin/SpongePluginGradle.java +++ b/plugin-development/src/main/java/org/spongepowered/gradle/plugin/SpongePluginGradle.java @@ -279,7 +279,7 @@ public void execute(final Task a) { this.project.afterEvaluate(p -> { final TaskProvider archiveTask; - if (p.getPlugins().hasPlugin(Constants.Plugins.SHADOW_PLUGIN_ID)) { + if (Constants.Plugins.SHADOW_PLUGIN_IDS.stream().anyMatch(id -> p.getPlugins().hasPlugin(id))) { archiveTask = p.getTasks().named(Constants.Plugins.SHADOW_JAR_TASK_NAME, AbstractArchiveTask.class); } else { archiveTask = p.getTasks().named(JavaPlugin.JAR_TASK_NAME, AbstractArchiveTask.class); From c7afa6ba1908aa5aed872258c01ab72d034d144b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ossi=20Erkkil=C3=A4?= Date: Sun, 26 May 2024 22:08:04 +0300 Subject: [PATCH 2/2] Stream -> loop --- .../gradle/plugin/SpongePluginGradle.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugin-development/src/main/java/org/spongepowered/gradle/plugin/SpongePluginGradle.java b/plugin-development/src/main/java/org/spongepowered/gradle/plugin/SpongePluginGradle.java index a692cc8..6dac2b4 100644 --- a/plugin-development/src/main/java/org/spongepowered/gradle/plugin/SpongePluginGradle.java +++ b/plugin-development/src/main/java/org/spongepowered/gradle/plugin/SpongePluginGradle.java @@ -279,7 +279,15 @@ public void execute(final Task a) { this.project.afterEvaluate(p -> { final TaskProvider archiveTask; - if (Constants.Plugins.SHADOW_PLUGIN_IDS.stream().anyMatch(id -> p.getPlugins().hasPlugin(id))) { + + boolean hasShadow = false; + for (String id : Constants.Plugins.SHADOW_PLUGIN_IDS) { + if (p.getPlugins().hasPlugin(id)) { + hasShadow = true; + break; + } + } + if (hasShadow) { archiveTask = p.getTasks().named(Constants.Plugins.SHADOW_JAR_TASK_NAME, AbstractArchiveTask.class); } else { archiveTask = p.getTasks().named(JavaPlugin.JAR_TASK_NAME, AbstractArchiveTask.class);