Skip to content

Commit

Permalink
Merge pull request #84 from avaruus1/forked-shadow-plugins
Browse files Browse the repository at this point in the history
Support shadow plugin forks
  • Loading branch information
zml2008 authored May 26, 2024
2 parents bee3af7 + c7afa6b commit beffdda
Show file tree
Hide file tree
Showing 2 changed files with 17 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,15 @@ public void execute(final Task a) {

this.project.afterEvaluate(p -> {
final TaskProvider<AbstractArchiveTask> archiveTask;
if (p.getPlugins().hasPlugin(Constants.Plugins.SHADOW_PLUGIN_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);
Expand Down

0 comments on commit beffdda

Please sign in to comment.