Further improve the eaglerweb gradle project

This commit is contained in:
lax1dude 2025-05-11 20:38:29 -07:00
parent 7fcaa308fe
commit 63cf07ca3f
16 changed files with 60 additions and 73 deletions

View File

@ -1,29 +1,63 @@
plugins {
id "java"
id "java-library"
id "com.gradleup.shadow" version "8.3.6"
}
configurations {
platformBukkit
platformBungee
platformVelocity
}
dependencies {
implementation project(":eaglerweb:eaglerweb-common")
runtimeOnly project(":eaglerweb:eaglerweb-platform-bukkit")
runtimeOnly project(":eaglerweb:eaglerweb-platform-bungee")
runtimeOnly project(":eaglerweb:eaglerweb-platform-velocity")
platformBukkit project(":eaglerweb:eaglerweb-platform-bukkit")
platformBungee project(":eaglerweb:eaglerweb-platform-bungee")
platformVelocity project(":eaglerweb:eaglerweb-platform-velocity")
compileOnly project(":api")
compileOnly(libs.guava)
compileOnly(libs.gson)
compileOnly(libs.slf4j)
}
jar {
dependsOn ":eaglerweb:eaglerweb-common:jar" // Workaround
dependsOn ":eaglerweb:eaglerweb-platform-bukkit:jar" // Workaround
dependsOn ":eaglerweb:eaglerweb-platform-bungee:jar" // Workaround
dependsOn ":eaglerweb:eaglerweb-platform-velocity: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,
project.configurations.platformBungee,
project.configurations.platformVelocity
]
archiveFileName = "EaglerWeb.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 = "EaglerWeb-Bukkit.jar"
}
tasks.register("shadowJarBungee", com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
group "shadow"
description "Builds the JAR for Bungee platforms"
configurations = [
project.configurations.runtimeClasspath,
project.configurations.platformBungee
]
archiveFileName = "EaglerWeb-Bungee.jar"
}
tasks.register("shadowJarVelocity", com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
group "shadow"
description "Builds the JAR for Velocity platforms"
configurations = [
project.configurations.runtimeClasspath,
project.configurations.platformVelocity
]
archiveFileName = "EaglerWeb-Velocity.jar"
}

View File

@ -1,9 +0,0 @@
plugins {
id "java-library"
}
dependencies {
compileOnly project(":api")
compileOnly(libs.slf4j)
}

View File

@ -1,37 +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.eaglerweb.base;
import net.lax1dude.eaglercraft.backend.eaglerweb.adapter.IEaglerWebImpl;
import net.lax1dude.eaglercraft.backend.eaglerweb.adapter.IEaglerWebPlatform;
/**
* Class to invoke the EaglerWeb constructor without a static dependency
*/
public class EaglerWebFactory {
@SuppressWarnings("unchecked")
public static <PlayerObject> IEaglerWebImpl<PlayerObject> create(IEaglerWebPlatform<PlayerObject> platform) {
try {
Class<?> clz = Class.forName("net.lax1dude.eaglercraft.backend.eaglerweb.base.EaglerWeb");
return (IEaglerWebImpl<PlayerObject>) clz.getConstructor(IEaglerWebPlatform.class).newInstance(platform);
} catch (ReflectiveOperationException ex) {
throw new RuntimeException(ex);
}
}
}

View File

@ -4,7 +4,7 @@ plugins {
}
dependencies {
implementation project(":eaglerweb:eaglerweb-common")
api project(":eaglerweb")
compileOnly project(":api-bukkit")
compileOnly(libs.paper.api)
compileOnly(libs.pluginannotations)

View File

@ -32,7 +32,7 @@ import net.lax1dude.eaglercraft.backend.eaglerweb.adapter.IEaglerWebImpl;
import net.lax1dude.eaglercraft.backend.eaglerweb.adapter.IEaglerWebLogger;
import net.lax1dude.eaglercraft.backend.eaglerweb.adapter.IEaglerWebPlatform;
import net.lax1dude.eaglercraft.backend.eaglerweb.adapter.JavaLogger;
import net.lax1dude.eaglercraft.backend.eaglerweb.base.EaglerWebFactory;
import net.lax1dude.eaglercraft.backend.eaglerweb.base.EaglerWeb;
import net.lax1dude.eaglercraft.backend.eaglerweb.base.EaglerWebVersion;
import net.lax1dude.eaglercraft.backend.server.api.bukkit.EaglerXServerAPI;
@ -64,7 +64,7 @@ public class PlatformPluginBukkit extends JavaPlugin implements IEaglerWebPlatfo
@Override
public void onLoad() {
logger = new JavaLogger(getLogger());
plugin = EaglerWebFactory.create(this);
plugin = new EaglerWeb<>(this);
}
@Override

View File

@ -4,7 +4,7 @@ plugins {
}
dependencies {
implementation project(":eaglerweb:eaglerweb-common")
api project(":eaglerweb")
compileOnly project(":api-bungee")
compileOnly(libs.bungeecord.api)
compileOnly(libs.pluginannotations)

View File

@ -23,7 +23,7 @@ import net.lax1dude.eaglercraft.backend.eaglerweb.adapter.IEaglerWebImpl;
import net.lax1dude.eaglercraft.backend.eaglerweb.adapter.IEaglerWebLogger;
import net.lax1dude.eaglercraft.backend.eaglerweb.adapter.IEaglerWebPlatform;
import net.lax1dude.eaglercraft.backend.eaglerweb.adapter.JavaLogger;
import net.lax1dude.eaglercraft.backend.eaglerweb.base.EaglerWebFactory;
import net.lax1dude.eaglercraft.backend.eaglerweb.base.EaglerWeb;
import net.lax1dude.eaglercraft.backend.eaglerweb.base.EaglerWebVersion;
import net.lax1dude.eaglercraft.backend.server.api.bungee.EaglerXServerAPI;
import net.md_5.bungee.api.connection.ProxiedPlayer;
@ -52,7 +52,7 @@ public class PlatformPluginBungee extends Plugin implements IEaglerWebPlatform<P
@Override
public void onLoad() {
logger = new JavaLogger(getLogger());
plugin = EaglerWebFactory.create(this);
plugin = new EaglerWeb<>(this);
}
@Override

View File

@ -4,7 +4,7 @@ plugins {
}
dependencies {
implementation project(":eaglerweb:eaglerweb-common")
api project(":eaglerweb")
compileOnly project(":api-velocity")
compileOnly(libs.velocity.api)
annotationProcessor(libs.velocity.api)

View File

@ -36,7 +36,7 @@ import net.lax1dude.eaglercraft.backend.eaglerweb.adapter.IEaglerWebImpl;
import net.lax1dude.eaglercraft.backend.eaglerweb.adapter.IEaglerWebLogger;
import net.lax1dude.eaglercraft.backend.eaglerweb.adapter.IEaglerWebPlatform;
import net.lax1dude.eaglercraft.backend.eaglerweb.adapter.SLF4JLogger;
import net.lax1dude.eaglercraft.backend.eaglerweb.base.EaglerWebFactory;
import net.lax1dude.eaglercraft.backend.eaglerweb.base.EaglerWeb;
import net.lax1dude.eaglercraft.backend.eaglerweb.base.EaglerWebVersion;
import net.lax1dude.eaglercraft.backend.server.api.velocity.EaglerXServerAPI;
@ -73,7 +73,7 @@ public class PlatformPluginVelocity implements IEaglerWebPlatform<Player> {
logger = loggerIn;
dataDir = dataDirIn.toFile();
rewindLogger = new SLF4JLogger(loggerIn);
plugin = EaglerWebFactory.create(this);
plugin = new EaglerWeb<>(this);
}
@Subscribe

View File

@ -28,7 +28,6 @@ include "eaglermotd:eaglermotd-platform-bukkit"
include "eaglermotd:eaglermotd-platform-bungee"
include "eaglermotd:eaglermotd-platform-velocity"
include "eaglerweb"
include "eaglerweb:eaglerweb-common"
include "eaglerweb:eaglerweb-platform-bukkit"
include "eaglerweb:eaglerweb-platform-bungee"
include "eaglerweb:eaglerweb-platform-velocity"