From ba91171fbf0f52ed38b0032e48f04ed34c1e5bf3 Mon Sep 17 00:00:00 2001 From: BenCodez <17074231+BenCodez@users.noreply.github.com> Date: Sat, 12 Sep 2026 17:08:44 -0600 Subject: [PATCH] Slim shaded dependency ownership --- AdvancedCore/pom.xml | 65 ++++++++++++++++++- .../tests/packaging/PackagedArtifactTest.java | 48 ++++++++++++++ docs/jar-packaging.md | 20 ++++++ 3 files changed, 130 insertions(+), 3 deletions(-) create mode 100644 AdvancedCore/src/test/java/com/bencodez/advancedcore/tests/packaging/PackagedArtifactTest.java create mode 100644 docs/jar-packaging.md diff --git a/AdvancedCore/pom.xml b/AdvancedCore/pom.xml index d4da9904fc..5da0a89b28 100644 --- a/AdvancedCore/pom.xml +++ b/AdvancedCore/pom.xml @@ -113,8 +113,11 @@ com.tcoded.folialib - - ${project.groupId}.advancedcore.folialib + com.bencodez.simpleapi.folialib + + + com.zaxxer.hikari + com.bencodez.simpleapi.hikari org.mozilla.javascript @@ -131,6 +134,33 @@ + + org.apache.maven.plugins + maven-surefire-plugin + 3.5.4 + + + default-test + + + **/PackagedArtifactTest.java + + + + + packaged-artifact-test + package + test + + **/PackagedArtifactTest.java + ${project.build.directory}/packaged-artifact-reports + + ${project.build.directory}/${project.name}.jar + + + + + @@ -209,7 +239,30 @@ com.bencodez simpleapi 1.0.2-SNAPSHOT + thin compile + + + org.bouncycastle + bcpkix-jdk18on + + + org.bouncycastle + bcprov-jdk18on + + + org.bouncycastle + bcutil-jdk18on + + + org.eclipse.paho + org.eclipse.paho.client.mqttv3 + + + redis.clients + jedis + + com.github.LoneDev6 @@ -240,6 +293,12 @@ rhino 1.9.1 + + com.google.code.gson + gson + 2.14.0 + provided + org.slf4j slf4j-simple @@ -513,4 +572,4 @@ - \ No newline at end of file + diff --git a/AdvancedCore/src/test/java/com/bencodez/advancedcore/tests/packaging/PackagedArtifactTest.java b/AdvancedCore/src/test/java/com/bencodez/advancedcore/tests/packaging/PackagedArtifactTest.java new file mode 100644 index 0000000000..ed1098e109 --- /dev/null +++ b/AdvancedCore/src/test/java/com/bencodez/advancedcore/tests/packaging/PackagedArtifactTest.java @@ -0,0 +1,48 @@ +package com.bencodez.advancedcore.tests.packaging; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.jar.JarFile; + +import org.junit.jupiter.api.Test; + +/** Verifies the actual minimized artifact rather than Maven's test classpath. */ +public class PackagedArtifactTest { + + @Test + void keepsRequiredRelocatedLibrariesWithoutOptionalTransports() throws Exception { + Path artifactPath = packagedJar(); + try (JarFile artifact = new JarFile(artifactPath.toFile())) { + assertNotNull(artifact.getEntry("com/bencodez/advancedcore/AdvancedCorePlugin.class")); + assertNotNull(artifact.getEntry("com/bencodez/simpleapi/scheduler/BukkitScheduler.class")); + assertNotNull(artifact.getEntry("com/bencodez/simpleapi/folialib/FoliaLib.class")); + assertNotNull(artifact.getEntry("com/bencodez/simpleapi/hikari/HikariDataSource.class")); + assertNotNull(artifact.getEntry("com/bencodez/advancedcore/rhino/Context.class")); + + assertNull(artifact.getEntry("com/tcoded/folialib/FoliaLib.class")); + assertNull(artifact.getEntry("com/zaxxer/hikari/HikariDataSource.class")); + assertNull(artifact.getEntry("org/mozilla/javascript/Context.class")); + assertFalse(artifact.stream().anyMatch(entry -> entry.getName().startsWith("org/bouncycastle/"))); + assertFalse(artifact.stream().anyMatch(entry -> entry.getName() + .startsWith("com/bencodez/simpleapi/servercomm/http/"))); + assertFalse(artifact.stream().anyMatch(entry -> entry.getName().startsWith("redis/clients/"))); + assertFalse(artifact.stream().anyMatch(entry -> entry.getName().startsWith("org/eclipse/paho/"))); + assertFalse(artifact.stream().anyMatch(entry -> entry.getName().startsWith("META-INF/versions/25/"))); + } + System.out.printf("AdvancedCore packaged artifact: %,d bytes; optional HTTP/Redis/MQTT payload absent%n", + Files.size(artifactPath)); + } + + private static Path packagedJar() { + String configured = System.getProperty("advancedcore.packagedJar"); + assertNotNull(configured, "Run this test through the Maven package lifecycle"); + Path artifact = Path.of(configured).toAbsolutePath().normalize(); + assertTrue(Files.isRegularFile(artifact), "Missing packaged artifact: " + artifact); + return artifact; + } +} diff --git a/docs/jar-packaging.md b/docs/jar-packaging.md new file mode 100644 index 0000000000..0057fdad9a --- /dev/null +++ b/docs/jar-packaging.md @@ -0,0 +1,20 @@ +# JAR packaging contract + +AdvancedCore consumes SimpleAPI's `thin` classifier so Maven Shade sees the +project classes and each dependency exactly once. The normal SimpleAPI artifact +remains a self-contained compatibility artifact for other consumers. + +AdvancedCore does not use SimpleAPI's HTTP, Redis, or MQTT implementations. +Its SimpleAPI dependency therefore excludes Bouncy Castle, Jedis, and Paho. +Hikari, FoliaLib, Configurate, and UniDialog remain available because the +AdvancedCore API and implementation use them. Hikari and FoliaLib retain their +existing `com.bencodez.simpleapi.*` relocated package names. + +Gson is declared as `provided`: AdvancedCore compiles against API signatures +that contain Gson types, while the supported server/proxy platforms supply it. +Rhino remains bundled and relocated for the JavaScript feature. + +The package phase runs `PackagedArtifactTest` after shading. It verifies the +actual minimized JAR contains required relocated classes and no HTTP crypto, +Redis, MQTT, or Java 25 Bouncy Castle payload. Deployment profiles use the same +Shade configuration; only publication/final-name behavior differs.