feat: switch jar to shadow the dependencies to avoid clashes with other plugins

This commit is contained in:
Sekwah 2024-11-19 05:22:38 +00:00
parent d672954b4b
commit c2b250c2a5
22 changed files with 66 additions and 35 deletions

View File

@ -49,6 +49,7 @@ allprojects {
}
apply from: 'env-variables.gradle'
@ -90,6 +91,9 @@ apply from: 'env-variables.gradle'
println "Branch ${ext.branch}${ext.shaRef} isRelease: '${ext.isRelease}'"
tasks.named('jar') {
dependsOn(':core:shadowJar')
}
jar {
// Filters the files out that are in the build folders. Look to see if there is a better way to do this?

View File

@ -1,13 +1,12 @@
plugins {
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'maven-publish'
id 'idea'
id 'eclipse'
}
configurations {
// configuration that holds jars to copy into lib
includeLibs
}
repositories {
@ -18,21 +17,41 @@ repositories {
// includeLibs just says to include the library in the final jar
dependencies {
includeLibs group: 'com.google.code.gson', name: 'gson', version: '2.8.9'
implementation group: 'com.google.code.gson', name: 'gson', version:'2.8.9'
includeLibs group: 'com.google.inject', name: 'guice', version:'5.0.1'
implementation group: 'com.google.inject', name: 'guice', version:'5.0.1'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.9'
implementation group: 'com.google.inject', name: 'guice', version: '5.0.1'
implementation group: 'org.yaml', name: 'snakeyaml', version: '2.2'
includeLibs group: 'org.yaml', name: 'snakeyaml', version: '2.2'
implementation group: 'com.google.guava', name: 'guava', version: '33.2.0-jre'
implementation group: 'io.netty', name: 'netty-buffer', version: '4.1.109.Final'
implementation group: 'io.netty', name: 'netty-codec', version: '4.1.109.Final'
}
jar {
from configurations.includeLibs.collect {
it.isDirectory() ? it : zipTree(it)
}
shadowJar {
relocate 'com.google.code.gson', 'com.sekwah.advancedportals.shadowed.gson'
relocate 'com.google.inject', 'com.sekwah.advancedportals.shadowed.inject'
relocate 'com.google.errorprone', 'com.sekwah.advancedportals.shadowed.errorprone'
relocate 'org.yaml.snakeyaml', 'com.sekwah.advancedportals.shadowed.snakeyaml'
relocate 'com.google.common', 'com.sekwah.advancedportals.shadowed.guava'
relocate 'io.netty', 'com.sekwah.advancedportals.shadowed.netty'
relocate 'javax.annotation', 'com.sekwah.advancedportals.shadowed.javax.annotation'
relocate 'javax.inject', 'com.sekwah.advancedportals.shadowed.javax.inject'
relocate 'org.aopalliance', 'com.sekwah.advancedportals.shadowed.aopalliance'
relocate 'org.checkerframework', 'com.sekwah.advancedportals.shadowed.checkerframework'
minimize()
archiveClassifier.set('')
}
tasks.named('jar') {
enabled = false
}
tasks.named('build') {
dependsOn tasks.named('shadowJar')
}
artifacts {
runtimeOnly shadowJar
}
def templateSource = file('src/main/templates')

View File

@ -20,9 +20,10 @@ import com.sekwah.advancedportals.core.serializeddata.DataStorage;
import com.sekwah.advancedportals.core.serializeddata.config.Config;
import com.sekwah.advancedportals.core.serializeddata.config.ConfigProvider;
import com.sekwah.advancedportals.core.util.InfoLogger;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
public class AdvancedPortalsModule extends AbstractModule {
private Injector injector;
@ -72,7 +73,6 @@ public class AdvancedPortalsModule extends AbstractModule {
}
}
// TODO change it so that it'll set these up during the injector.
public <T> void addInstanceBinding(Class<T> clazz, T instance) {
delayedBindings.add(new DelayedBinding<>(clazz, instance));
}

View File

@ -1,13 +1,13 @@
package com.sekwah.advancedportals.core.repository.impl;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.sekwah.advancedportals.core.destination.Destination;
import com.sekwah.advancedportals.core.repository.IDestinationRepository;
import com.sekwah.advancedportals.core.serializeddata.DataStorage;
import com.sekwah.advancedportals.core.tags.NameTag;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Singleton;
@Singleton
public class DestinationRepositoryImpl implements IDestinationRepository {

View File

@ -1,5 +1,6 @@
package com.sekwah.advancedportals.core.serializeddata;
import com.google.inject.Inject;
import com.sekwah.advancedportals.core.util.InfoLogger;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
@ -7,7 +8,6 @@ import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.constructor.Constructor;
import org.yaml.snakeyaml.nodes.*;

View File

@ -1,6 +1,7 @@
package com.sekwah.advancedportals.core.services;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
import com.sekwah.advancedportals.core.destination.Destination;
import com.sekwah.advancedportals.core.effect.WarpEffect;
@ -16,7 +17,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.inject.Singleton;
@Singleton
public class DestinationServices {

View File

@ -1,6 +1,7 @@
package com.sekwah.advancedportals.core.services;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
import com.sekwah.advancedportals.core.repository.ConfigRepository;
import com.sekwah.advancedportals.core.repository.IPlayerDataRepository;
@ -10,7 +11,6 @@ import com.sekwah.advancedportals.core.util.Lang;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.inject.Singleton;
@Singleton
public final class PlayerDataServices {

View File

@ -1,6 +1,7 @@
package com.sekwah.advancedportals.core.services;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
import com.sekwah.advancedportals.core.portal.AdvancedPortal;
import com.sekwah.advancedportals.core.registry.TagRegistry;
@ -16,7 +17,6 @@ import com.sekwah.advancedportals.core.util.PlayerUtils;
import com.sekwah.advancedportals.core.warphandler.Tag;
import com.sekwah.advancedportals.core.warphandler.TriggerType;
import java.util.*;
import javax.inject.Singleton;
@Singleton
public class PortalServices {

View File

@ -10,6 +10,7 @@ import com.sekwah.advancedportals.core.repository.ConfigRepository;
import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.core.warphandler.ActivationData;
import com.sekwah.advancedportals.core.warphandler.Tag;
import javax.annotation.Nullable;
public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation {

View File

@ -1,5 +1,6 @@
package com.sekwah.advancedportals.core.tags;
import com.google.inject.Inject;
import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
import com.sekwah.advancedportals.core.registry.TagTarget;
import com.sekwah.advancedportals.core.repository.ConfigRepository;
@ -9,7 +10,6 @@ import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.core.warphandler.ActivationData;
import com.sekwah.advancedportals.core.warphandler.Tag;
import javax.annotation.Nullable;
import javax.inject.Inject;
public class PermissionTag implements Tag.Activation {
@Inject

View File

@ -1,5 +1,6 @@
package com.sekwah.advancedportals.core.tags;
import com.google.inject.Inject;
import com.sekwah.advancedportals.core.connector.containers.GameMode;
import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
import com.sekwah.advancedportals.core.registry.TagTarget;
@ -13,7 +14,6 @@ import com.sekwah.advancedportals.core.warphandler.TriggerType;
import java.util.List;
import java.util.Objects;
import javax.annotation.Nullable;
import javax.inject.Inject;
public class PortalEventTag implements Tag.Activation, Tag.AutoComplete,
Tag.DenyBehavior, Tag.OrderPriority {

View File

@ -1,8 +1,9 @@
package com.sekwah.advancedportals.core.util;
import com.google.inject.Singleton;
import java.util.ArrayList;
import java.util.Iterator;
import javax.inject.Singleton;
/**
* For all delayed and repeating tasks.

View File

@ -8,19 +8,21 @@ configurations {
}
repositories {
maven { url "https://repo.maven.apache.org/maven2" }
maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
// includeLibs just says to include the library in the final jar
dependencies {
// This is here just for referencing the proxy message strings
implementation project(":core")
implementation group: 'com.google.guava', name: 'guava', version: '33.2.0-jre'
runtimeOnly project(path: ':core', configuration: 'shadow')
}
tasks.named('compileJava') {
dependsOn(':core:shadowJar')
}
jar {
from configurations.includeLibs.collect {
it.isDirectory() ? it : zipTree(it)

View File

@ -1,6 +1,5 @@
package com.sekwah.advancedportals.proxycore;
import com.google.common.io.ByteStreams;
import com.sekwah.advancedportals.core.ProxyMessages;
import com.sekwah.advancedportals.core.network.ProxyCommandPacket;
import com.sekwah.advancedportals.core.network.ProxyTransferDestiPacket;
@ -12,6 +11,8 @@ import com.sekwah.advancedportals.proxycore.connector.container.ProxyContainer;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyJoinData;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerContainer;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyServerContainer;
import com.sekwah.advancedportals.shadowed.guava.io.ByteStreams;
import java.util.HashMap;
public class AdvancedPortalsProxyCore {

View File

@ -14,18 +14,21 @@ repositories {
// includeLibs just says to include the library in the final jar
dependencies {
implementation project(":core")
runtimeOnly project(path: ':core', configuration: 'shadow')
// For spigot api
// We are using an older version to try and ensure that we are not using anything new older versions cant use.
implementation "org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT"
implementation "net.md-5:bungeecord-api:1.16-R0.4"
implementation "com.mojang:authlib:3.5.41"
implementation "com.google.inject:guice:5.0.1"
// Be careful to only use what you need to from paper, otherwise it will become incompatible with spigot.
// compileOnly 'com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT'
}
tasks.named('compileJava') {
dependsOn(':core:shadowJar')
}
jar {
from configurations.includeLibs.collect {
it.isDirectory() ? it : zipTree(it)

View File

@ -1,11 +1,11 @@
package com.sekwah.advancedportals.spigot;
import com.google.inject.Injector;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.connector.commands.CommandRegister;
import com.sekwah.advancedportals.core.module.AdvancedPortalsModule;
import com.sekwah.advancedportals.core.permissions.Permissions;
import com.sekwah.advancedportals.core.util.GameScheduler;
import com.sekwah.advancedportals.shadowed.inject.Injector;
import com.sekwah.advancedportals.spigot.commands.subcommands.portal.ImportPortalSubCommand;
import com.sekwah.advancedportals.spigot.connector.command.SpigotCommandRegister;
import com.sekwah.advancedportals.spigot.connector.container.SpigotServerContainer;

View File

@ -1,10 +1,10 @@
package com.sekwah.advancedportals.spigot;
import com.google.inject.Inject;
import com.sekwah.advancedportals.core.CoreListeners;
import com.sekwah.advancedportals.core.repository.ConfigRepository;
import com.sekwah.advancedportals.core.serializeddata.BlockLocation;
import com.sekwah.advancedportals.core.services.PortalServices;
import com.sekwah.advancedportals.shadowed.inject.Inject;
import com.sekwah.advancedportals.spigot.connector.container.SpigotEntityContainer;
import com.sekwah.advancedportals.spigot.connector.container.SpigotPlayerContainer;
import com.sekwah.advancedportals.spigot.connector.container.SpigotWorldContainer;

View File

@ -1,6 +1,5 @@
package com.sekwah.advancedportals.spigot.commands.subcommands.portal;
import com.google.inject.Inject;
import com.sekwah.advancedportals.core.commands.SubCommand;
import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer;
import com.sekwah.advancedportals.core.permissions.Permissions;
@ -10,6 +9,7 @@ import com.sekwah.advancedportals.core.serializeddata.PlayerLocation;
import com.sekwah.advancedportals.core.services.DestinationServices;
import com.sekwah.advancedportals.core.services.PortalServices;
import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.shadowed.inject.Inject;
import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.spigot.commands.subcommands.portal.importer.ConfigAccessor;
import java.util.ArrayList;

View File

@ -1,12 +1,12 @@
package com.sekwah.advancedportals.spigot.connector.container;
import com.google.inject.Inject;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.connector.containers.EntityContainer;
import com.sekwah.advancedportals.core.connector.containers.WorldContainer;
import com.sekwah.advancedportals.core.serializeddata.BlockLocation;
import com.sekwah.advancedportals.core.serializeddata.PlayerLocation;
import com.sekwah.advancedportals.core.serializeddata.Vector;
import com.sekwah.advancedportals.shadowed.inject.Inject;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Entity;

View File

@ -1,12 +1,12 @@
package com.sekwah.advancedportals.spigot.connector.container;
import com.google.inject.Inject;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.connector.containers.GameMode;
import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
import com.sekwah.advancedportals.core.connector.containers.ServerContainer;
import com.sekwah.advancedportals.core.serializeddata.BlockLocation;
import com.sekwah.advancedportals.core.serializeddata.PlayerLocation;
import com.sekwah.advancedportals.shadowed.inject.Inject;
import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.spigot.reflection.MinecraftCustomPayload;
import java.util.Arrays;

View File

@ -1,11 +1,11 @@
package com.sekwah.advancedportals.spigot.connector.container;
import com.google.inject.Inject;
import com.sekwah.advancedportals.core.CoreListeners;
import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
import com.sekwah.advancedportals.core.connector.containers.ServerContainer;
import com.sekwah.advancedportals.core.connector.containers.WorldContainer;
import com.sekwah.advancedportals.core.tags.CommandTag;
import com.sekwah.advancedportals.shadowed.inject.Inject;
import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin;
import java.util.Arrays;
import java.util.List;

View File

@ -1,7 +1,7 @@
package com.sekwah.advancedportals.spigot.warpeffects;
import com.sekwah.advancedportals.core.registry.WarpEffectRegistry;
import javax.inject.Inject;
import com.sekwah.advancedportals.shadowed.inject.Inject;
public class SpigotWarpEffects {
@Inject