diff --git a/build.gradle b/build.gradle index 3063e0ff..943ce577 100644 --- a/build.gradle +++ b/build.gradle @@ -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? diff --git a/core/build.gradle b/core/build.gradle index 110aac5a..d1316f9f 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -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') diff --git a/core/src/main/java/com/sekwah/advancedportals/core/module/AdvancedPortalsModule.java b/core/src/main/java/com/sekwah/advancedportals/core/module/AdvancedPortalsModule.java index 6883b6e1..9f9c8695 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/module/AdvancedPortalsModule.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/module/AdvancedPortalsModule.java @@ -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 void addInstanceBinding(Class clazz, T instance) { delayedBindings.add(new DelayedBinding<>(clazz, instance)); } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/DestinationRepositoryImpl.java b/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/DestinationRepositoryImpl.java index 28d29e33..eebb2de0 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/DestinationRepositoryImpl.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/DestinationRepositoryImpl.java @@ -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 { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/ReflectiveConstructor.java b/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/ReflectiveConstructor.java index 84cb4035..f970707a 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/ReflectiveConstructor.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/ReflectiveConstructor.java @@ -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.*; diff --git a/core/src/main/java/com/sekwah/advancedportals/core/services/DestinationServices.java b/core/src/main/java/com/sekwah/advancedportals/core/services/DestinationServices.java index 73abe4db..566044d2 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/services/DestinationServices.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/services/DestinationServices.java @@ -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 { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/services/PlayerDataServices.java b/core/src/main/java/com/sekwah/advancedportals/core/services/PlayerDataServices.java index 3236ecda..c4a383e6 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/services/PlayerDataServices.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/services/PlayerDataServices.java @@ -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 { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/services/PortalServices.java b/core/src/main/java/com/sekwah/advancedportals/core/services/PortalServices.java index 3a3be6a7..0170ff52 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/services/PortalServices.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/services/PortalServices.java @@ -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 { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/tags/CommandTag.java b/core/src/main/java/com/sekwah/advancedportals/core/tags/CommandTag.java index 8fbfb492..4db91791 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/tags/CommandTag.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/tags/CommandTag.java @@ -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 { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/tags/PermissionTag.java b/core/src/main/java/com/sekwah/advancedportals/core/tags/PermissionTag.java index 8a2baacc..636cde6b 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/tags/PermissionTag.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/tags/PermissionTag.java @@ -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 diff --git a/core/src/main/java/com/sekwah/advancedportals/core/tags/PortalEventTag.java b/core/src/main/java/com/sekwah/advancedportals/core/tags/PortalEventTag.java index f6194c13..24ce7aba 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/tags/PortalEventTag.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/tags/PortalEventTag.java @@ -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 { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/util/GameScheduler.java b/core/src/main/java/com/sekwah/advancedportals/core/util/GameScheduler.java index 56ebd7de..8d20ce4b 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/util/GameScheduler.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/util/GameScheduler.java @@ -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. diff --git a/proxycore/build.gradle b/proxycore/build.gradle index 1b12be2f..5be9adf9 100644 --- a/proxycore/build.gradle +++ b/proxycore/build.gradle @@ -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) diff --git a/proxycore/src/main/java/com/sekwah/advancedportals/proxycore/AdvancedPortalsProxyCore.java b/proxycore/src/main/java/com/sekwah/advancedportals/proxycore/AdvancedPortalsProxyCore.java index 5da980fb..abd72eef 100644 --- a/proxycore/src/main/java/com/sekwah/advancedportals/proxycore/AdvancedPortalsProxyCore.java +++ b/proxycore/src/main/java/com/sekwah/advancedportals/proxycore/AdvancedPortalsProxyCore.java @@ -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 { diff --git a/spigot/build.gradle b/spigot/build.gradle index c3471820..11cb35d7 100644 --- a/spigot/build.gradle +++ b/spigot/build.gradle @@ -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) diff --git a/spigot/src/main/java/com/sekwah/advancedportals/spigot/AdvancedPortalsPlugin.java b/spigot/src/main/java/com/sekwah/advancedportals/spigot/AdvancedPortalsPlugin.java index 9fe80e0f..fb806036 100644 --- a/spigot/src/main/java/com/sekwah/advancedportals/spigot/AdvancedPortalsPlugin.java +++ b/spigot/src/main/java/com/sekwah/advancedportals/spigot/AdvancedPortalsPlugin.java @@ -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; diff --git a/spigot/src/main/java/com/sekwah/advancedportals/spigot/Listeners.java b/spigot/src/main/java/com/sekwah/advancedportals/spigot/Listeners.java index e4397880..ed116554 100644 --- a/spigot/src/main/java/com/sekwah/advancedportals/spigot/Listeners.java +++ b/spigot/src/main/java/com/sekwah/advancedportals/spigot/Listeners.java @@ -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; diff --git a/spigot/src/main/java/com/sekwah/advancedportals/spigot/commands/subcommands/portal/ImportPortalSubCommand.java b/spigot/src/main/java/com/sekwah/advancedportals/spigot/commands/subcommands/portal/ImportPortalSubCommand.java index 6e3ae5b2..b02ce3e0 100644 --- a/spigot/src/main/java/com/sekwah/advancedportals/spigot/commands/subcommands/portal/ImportPortalSubCommand.java +++ b/spigot/src/main/java/com/sekwah/advancedportals/spigot/commands/subcommands/portal/ImportPortalSubCommand.java @@ -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; diff --git a/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotEntityContainer.java b/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotEntityContainer.java index 043eab7a..e651bc2c 100644 --- a/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotEntityContainer.java +++ b/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotEntityContainer.java @@ -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; diff --git a/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotPlayerContainer.java b/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotPlayerContainer.java index c93bfc02..f42d9d1f 100644 --- a/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotPlayerContainer.java +++ b/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotPlayerContainer.java @@ -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; diff --git a/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotServerContainer.java b/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotServerContainer.java index 36605ced..d7ec3633 100644 --- a/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotServerContainer.java +++ b/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotServerContainer.java @@ -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; diff --git a/spigot/src/main/java/com/sekwah/advancedportals/spigot/warpeffects/SpigotWarpEffects.java b/spigot/src/main/java/com/sekwah/advancedportals/spigot/warpeffects/SpigotWarpEffects.java index d6534d22..aea3b7e2 100644 --- a/spigot/src/main/java/com/sekwah/advancedportals/spigot/warpeffects/SpigotWarpEffects.java +++ b/spigot/src/main/java/com/sekwah/advancedportals/spigot/warpeffects/SpigotWarpEffects.java @@ -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