Further improve the backend-rpc-core gradle project

This commit is contained in:
lax1dude 2025-05-11 19:34:54 -07:00
parent ff34d7bad1
commit 4cc9a9d5f2
23 changed files with 33 additions and 74 deletions

View File

@ -1,11 +0,0 @@
plugins {
id "java-library"
}
dependencies {
api project(":backend-rpc-api")
compileOnly project(":api")
compileOnly(libs.guava)
compileOnly(libs.jsr305)
}

View File

@ -1,36 +0,0 @@
/*
* Copyright (c) 2025 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.lax1dude.eaglercraft.backend.rpc.base;
import net.lax1dude.eaglercraft.backend.rpc.adapter.IBackendRPCImpl;
/**
* Class to invoke the EaglerXBackendRPC constructor without a static dependency
*/
public class EaglerXBackendRPCFactory {
@SuppressWarnings("unchecked")
public static <PlayerObject> IBackendRPCImpl<PlayerObject> create() {
try {
Class<?> clz = Class.forName("net.lax1dude.eaglercraft.backend.rpc.base.EaglerXBackendRPCBase");
return (IBackendRPCImpl<PlayerObject>) clz.getMethod("init").invoke(null);
} catch (ReflectiveOperationException ex) {
throw new RuntimeException(ex);
}
}
}

View File

@ -4,8 +4,8 @@ plugins {
}
dependencies {
implementation project(":backend-rpc-api-bukkit")
implementation project(":backend-rpc-core:backend-rpc-core-common")
api project(":backend-rpc-api-bukkit")
api project(":backend-rpc-core")
compileOnly project(":api-bukkit")
compileOnly(libs.paper.api)
compileOnly(libs.bungeecord.chat)

View File

@ -50,7 +50,7 @@ import net.lax1dude.eaglercraft.backend.rpc.adapter.IPlatformScheduler;
import net.lax1dude.eaglercraft.backend.rpc.adapter.JavaLogger;
import net.lax1dude.eaglercraft.backend.rpc.adapter.event.IEventDispatchAdapter;
import net.lax1dude.eaglercraft.backend.rpc.api.bukkit.EaglerXBackendRPC;
import net.lax1dude.eaglercraft.backend.rpc.base.EaglerXBackendRPCFactory;
import net.lax1dude.eaglercraft.backend.rpc.base.EaglerXBackendRPCBase;
import net.lax1dude.eaglercraft.backend.rpc.base.EaglerXBackendRPCVersion;
import net.lax1dude.eaglercraft.backend.rpc.bukkit.event.BukkitEventDispatchAdapter;
import net.lax1dude.eaglercraft.backend.server.api.bukkit.EaglerXServerAPI;
@ -171,7 +171,7 @@ public class PlatformPluginBukkit extends JavaPlugin implements IPlatform<Player
};
}
};
EaglerXBackendRPCFactory.<Player>create().load(init);
EaglerXBackendRPCBase.<Player>init().load(init);
}
@Override

View File

@ -1,34 +1,41 @@
plugins {
id "java"
id "java-library"
id "com.gradleup.shadow" version "8.3.6"
}
configurations {
platformBukkit
}
dependencies {
implementation project(":voice-rpc-protocol")
implementation project(":backend-rpc-api-bukkit")
implementation project(":backend-rpc-protocol")
implementation project(":backend-rpc-core:backend-rpc-core-common")
runtimeOnly project(":backend-rpc-core:backend-rpc-core-platform-bukkit")
api project(":backend-rpc-api")
api project(":backend-rpc-protocol")
api project(":voice-rpc-protocol")
platformBukkit project(":backend-rpc-core:backend-rpc-core-platform-bukkit")
compileOnly project(":api")
compileOnly(libs.paper.api)
compileOnly(libs.bungeecord.chat)
compileOnly(libs.bundles.netty.all)
compileOnly(libs.guava)
compileOnly(libs.snakeyaml)
compileOnly(libs.jsr305)
}
jar {
dependsOn ":voice-rpc-protocol:jar" // Workaround
dependsOn ":backend-rpc-api:jar" // Workaround
dependsOn ":backend-rpc-api-bukkit:jar" // Workaround
dependsOn ":backend-rpc-protocol:jar" // Workaround
dependsOn ":backend-rpc-core:backend-rpc-core-common:jar" // Workaround
dependsOn ":backend-rpc-core:backend-rpc-core-platform-bukkit:jar" // Workaround
tasks.named("shadowJar", com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
group "shadow"
description "Builds the JAR for all supported platforms"
configurations = [
project.configurations.runtimeClasspath,
project.configurations.platformBukkit
]
archiveFileName = "EaglerXBackendRPC.jar"
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}
tasks.register("shadowJarBukkit", com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
group "shadow"
description "Builds the JAR for Bukkit platforms"
configurations = [
project.configurations.runtimeClasspath,
project.configurations.platformBukkit
]
archiveFileName = "EaglerXBackendRPC-Bukkit.jar"
}

View File

@ -37,7 +37,6 @@ include "eaglerweb:eaglerweb-platform-velocity"
include "backend-rpc-api"
include "backend-rpc-api-bukkit"
include "backend-rpc-core"
include "backend-rpc-core:backend-rpc-core-common"
include "backend-rpc-core:backend-rpc-core-platform-bukkit"
include "backend-rpc-protocol"
include "voice-rpc-protocol"