diff --git a/AGENTS.md b/AGENTS.md index 00f50ff4d1..79ff954b0b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -28,7 +28,9 @@ automation because it copies a JAR into a developer-specific server directory. Assign one owner to Maven validation in each worktree. Never run concurrent Maven commands in the same worktree, including focused tests alongside a clean/package build: compilation and cleanup share `target/` and can invalidate each other. Reviewers must inspect source only while that owner builds, or run validation in a separate worktree. -Keep the downloadable VotingPlugin JAR as small as practical. Inspect the shaded +Keep the downloadable VotingPlugin JAR as small as practical. The 10 MiB size target is advisory: +report a prominent package/build warning when exceeded, never fail a build solely for artifact size. +Keep required-resource, linkage, and packaging-safety checks enforced. Inspect the shaded artifact when dependencies change, avoid duplicate embedded packages, and update the package-phase size and runtime checks when a necessary dependency increases the artifact budget. diff --git a/VotingPlugin/src/test/java/com/bencodez/votingplugin/packaging/PackagedArtifactTest.java b/VotingPlugin/src/test/java/com/bencodez/votingplugin/packaging/PackagedArtifactTest.java index d317fa1066..c7f510a8fc 100644 --- a/VotingPlugin/src/test/java/com/bencodez/votingplugin/packaging/PackagedArtifactTest.java +++ b/VotingPlugin/src/test/java/com/bencodez/votingplugin/packaging/PackagedArtifactTest.java @@ -6,6 +6,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assumptions.assumeTrue; +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; import java.net.URL; import java.net.URLClassLoader; import java.nio.charset.StandardCharsets; @@ -18,7 +20,7 @@ /** Package-phase checks for the actual downloadable plugin artifact. */ public class PackagedArtifactTest { - private static final long MAX_DOWNLOAD_BYTES = 10L * 1024L * 1024L; + private static final long ARTIFACT_SIZE_TARGET_BYTES = 10L * 1024L * 1024L; @Test void containsOneRelocatedRuntimeWithoutUnusedHttpCrypto() throws Exception { @@ -65,13 +67,32 @@ void containsOneRelocatedRuntimeWithoutUnusedHttpCrypto() throws Exception { "Only the common offline SQLite native may be embedded"); } long artifactBytes = Files.size(artifactPath); - assertTrue(artifactBytes <= MAX_DOWNLOAD_BYTES, - () -> "VotingPlugin downloadable artifact exceeded " - + (MAX_DOWNLOAD_BYTES / (1024L * 1024L)) + " MiB: " + artifactBytes); + warnIfArtifactExceedsSizeTarget(artifactBytes, System.out); System.out.printf("VotingPlugin downloadable artifact: %,d bytes; duplicate Rhino, external crypto and uncommon SQLite natives absent%n", Files.size(artifactPath)); } + @Test + void artifactSizeTargetWarnsWithoutRejectingOversizedArtifacts() { + ByteArrayOutputStream output = new ByteArrayOutputStream(); + try (PrintStream report = new PrintStream(output, true, StandardCharsets.UTF_8)) { + warnIfArtifactExceedsSizeTarget(ARTIFACT_SIZE_TARGET_BYTES, report); + assertTrue(output.toString(StandardCharsets.UTF_8).isEmpty()); + warnIfArtifactExceedsSizeTarget(ARTIFACT_SIZE_TARGET_BYTES + 1, report); + String warning = output.toString(StandardCharsets.UTF_8); + assertTrue(warning.contains("[WARNING]")); + assertTrue(warning.contains("10 MiB size target")); + assertTrue(warning.contains("does not fail the build")); + } + } + + private static void warnIfArtifactExceedsSizeTarget(long artifactBytes, PrintStream output) { + if (artifactBytes > ARTIFACT_SIZE_TARGET_BYTES) { + output.printf("[WARNING] VotingPlugin downloadable artifact exceeds the 10 MiB size target: %,d bytes. " + + "Review dependency growth; this warning does not fail the build.%n", artifactBytes); + } + } + @Test void packagedNeoForgeRuntimeStartsAndClosesWithoutTestDependencies(@TempDir Path directory) throws Exception { URL jar = packagedJar().toUri().toURL(); diff --git a/docs/jar-packaging.md b/docs/jar-packaging.md index 3a9536b9f6..0dbc4cacb2 100644 --- a/docs/jar-packaging.md +++ b/docs/jar-packaging.md @@ -35,8 +35,10 @@ JVM properties. Extracted natives use a unique load directory so a replacement plugin classloader never reuses the prior classloader's JNI path; stale copies are removed on a best-effort basis. -The test caps the downloadable artifact at 10 MiB so dependency growth must be -reviewed explicitly. Release/deployment profiles +The package-phase test reports a prominent warning when the downloadable artifact +exceeds the 10 MiB size target. Size alone does not fail the build; dependency +growth should still be reviewed. Required runtime resources, duplicate libraries, +linkage, and other packaging-safety checks remain build failures. Release/deployment profiles reuse this Shade setup; the artifact check follows their configured JAR name. Keep the downloadable VotingPlugin JAR as small as practical. Before adding a