Skip to content

Commit

Permalink
Support shadow plugin forks
Browse files Browse the repository at this point in the history
  • Loading branch information
avaruus1 committed May 19, 2024
1 parent bee3af7 commit e263e91
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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<String> 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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public void execute(final Task a) {

this.project.afterEvaluate(p -> {
final TaskProvider<AbstractArchiveTask> 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);
Expand Down

0 comments on commit e263e91

Please sign in to comment.