Skip to content

Commit

Permalink
feat: switch jar to shadow the dependencies to avoid clashes with oth…
Browse files Browse the repository at this point in the history
…er plugins
  • Loading branch information
sekwah41 committed Nov 19, 2024
1 parent d672954 commit 12bc87a
Show file tree
Hide file tree
Showing 22 changed files with 66 additions and 35 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ allprojects {

}


apply from: 'env-variables.gradle'


Expand Down Expand Up @@ -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?
Expand Down
41 changes: 30 additions & 11 deletions core/build.gradle
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
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;
Expand Down Expand Up @@ -72,7 +73,6 @@ protected void configure() {
}
}

// 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));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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;
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.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -16,7 +17,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.inject.Singleton;

@Singleton
public class DestinationServices {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -10,7 +11,6 @@
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.inject.Singleton;

@Singleton
public final class PlayerDataServices {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -16,7 +17,6 @@
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -9,7 +10,6 @@
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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -13,7 +14,6 @@
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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
10 changes: 6 additions & 4 deletions proxycore/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -12,6 +11,8 @@
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 {
Expand Down
7 changes: 5 additions & 2 deletions spigot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -10,6 +9,7 @@
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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 12bc87a

Please sign in to comment.