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
4 changes: 3 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 4 additions & 2 deletions docs/jar-packaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading