Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 62 additions & 3 deletions AdvancedCore/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,11 @@
<relocations>
<relocation>
<pattern>com.tcoded.folialib</pattern>
<shadedPattern>
${project.groupId}.advancedcore.folialib</shadedPattern>
<shadedPattern>com.bencodez.simpleapi.folialib</shadedPattern>
</relocation>
<relocation>
<pattern>com.zaxxer.hikari</pattern>
<shadedPattern>com.bencodez.simpleapi.hikari</shadedPattern>
</relocation>
<relocation>
<pattern>org.mozilla.javascript</pattern>
Expand All @@ -131,6 +134,33 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<executions>
<execution>
<id>default-test</id>
<configuration>
<excludes>
<exclude>**/PackagedArtifactTest.java</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>packaged-artifact-test</id>
<phase>package</phase>
<goals><goal>test</goal></goals>
<configuration>
<includes><include>**/PackagedArtifactTest.java</include></includes>
<reportsDirectory>${project.build.directory}/packaged-artifact-reports</reportsDirectory>
<systemPropertyVariables>
<advancedcore.packagedJar>${project.build.directory}/${project.name}.jar</advancedcore.packagedJar>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
Expand Down Expand Up @@ -209,7 +239,30 @@
<groupId>com.bencodez</groupId>
<artifactId>simpleapi</artifactId>
<version>1.0.2-SNAPSHOT</version>
<classifier>thin</classifier>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk18on</artifactId>
</exclusion>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
</exclusion>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcutil-jdk18on</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
</exclusion>
<exclusion>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.LoneDev6</groupId>
Expand Down Expand Up @@ -240,6 +293,12 @@
<artifactId>rhino</artifactId>
<version>1.9.1</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.14.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
Expand Down Expand Up @@ -513,4 +572,4 @@
</build>
</profile>
</profiles>
</project>
</project>
Original file line number Diff line number Diff line change
@@ -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;
}
}
20 changes: 20 additions & 0 deletions docs/jar-packaging.md
Original file line number Diff line number Diff line change
@@ -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.
Loading