From e7c9c1fe242fc9d4162aceb9c5b45e018d12e578 Mon Sep 17 00:00:00 2001
From: BenCodez <17074231+BenCodez@users.noreply.github.com>
Date: Wed, 2 Dec 2026 22:14:53 +0000
Subject: [PATCH] Add opt-in main and NeoForge classified packaging
---
VotingPlugin/pom.xml | 109 ++++++++++++++++++
.../tests/packaging/PackagedArtifactTest.java | 52 +++++++++
docs/platform-packaging.md | 60 ++++++++++
3 files changed, 221 insertions(+)
create mode 100644 docs/platform-packaging.md
diff --git a/VotingPlugin/pom.xml b/VotingPlugin/pom.xml
index f6ead8e44..68c210d95 100644
--- a/VotingPlugin/pom.xml
+++ b/VotingPlugin/pom.xml
@@ -17,6 +17,10 @@
21
3.4.0
21.1.211
+
+ default
+ false
+ false
${packaged.jar.name}
@@ -273,6 +277,12 @@
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+ 3.2.0
+
org.apache.maven.plugins
maven-surefire-plugin
@@ -295,6 +305,10 @@
${project.build.directory}/packaged-artifact-reports
${project.build.directory}/${packaged.jar.name}.jar
+ ${project.build.directory}/${packaged.jar.name}-main.jar
+ ${project.build.directory}/${packaged.jar.name}-neoforge.jar
+ ${platform.main.enabled}
+ ${platform.neoforge.enabled}
@@ -581,6 +595,101 @@
+
+ platform-main
+
+ true
+
+ true
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.5.1
+
+
+ mojang
+
+
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+
+
+ attach-platform-main
+ package
+ run
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ platform-neoforge
+
+ true
+
+ true
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.5.1
+
+
+ mojang
+
+
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+
+
+ attach-platform-neoforge
+ package
+ run
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
default
diff --git a/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/packaging/PackagedArtifactTest.java b/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/packaging/PackagedArtifactTest.java
index 8194be830..9c78e90f9 100644
--- a/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/packaging/PackagedArtifactTest.java
+++ b/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/packaging/PackagedArtifactTest.java
@@ -271,6 +271,58 @@ void packagedJdkTlsIdentityWorksWithoutExternalCrypto(@TempDir Path directory) t
}
}
+ @Test
+ void mainProfilePreservesEveryUnrelatedEntry() throws Exception {
+ org.junit.jupiter.api.Assumptions.assumeTrue(
+ Boolean.getBoolean("votingplugin.testMainArtifact"), "Main profile is opt-in");
+ assertPlatformSubset("votingplugin.mainJar", name ->
+ name.startsWith("com/bencodez/votingplugin/neoforge/")
+ || name.equals("META-INF/neoforge.mods.toml"));
+ }
+
+ @Test
+ void neoForgeProfileOnlyChangesPlatformDiscovery() throws Exception {
+ org.junit.jupiter.api.Assumptions.assumeTrue(
+ Boolean.getBoolean("votingplugin.testNeoForgeArtifact"), "NeoForge profile is opt-in");
+ assertPlatformSubset("votingplugin.neoForgeJar", name ->
+ name.equals("plugin.yml") || name.equals("bungee.yml")
+ || name.equals("velocity-plugin.json"));
+ }
+
+ private static void assertPlatformSubset(String property,
+ java.util.function.Predicate excluded) throws Exception {
+ Path original = packagedJar();
+ Path selected = Path.of(System.getProperty(property));
+ assertTrue(Files.isRegularFile(selected), "Requested platform artifact must be produced");
+ try (JarFile before = new JarFile(original.toFile()); JarFile after = new JarFile(selected.toFile())) {
+ var expected = before.stream().filter(entry -> !excluded.test(entry.getName()))
+ .map(java.util.zip.ZipEntry::getName).collect(java.util.stream.Collectors.toSet());
+ var entries = after.stream().map(java.util.zip.ZipEntry::getName).toList();
+ assertEquals(entries.size(), new java.util.HashSet<>(entries).size());
+ assertEquals(expected, new java.util.HashSet<>(entries));
+ String version = new String(after.getInputStream(after.getEntry("votingpluginversion.yml"))
+ .readAllBytes(), StandardCharsets.UTF_8);
+ assertFalse(version.contains("${build.profile.id}"), "Profile metadata must be resolved");
+ for (String name : expected) {
+ try (var input = before.getInputStream(before.getEntry(name));
+ var output = after.getInputStream(after.getEntry(name))) {
+ byte[] retained = output.readAllBytes();
+ assertArrayEquals(input.readAllBytes(), retained, name);
+ if (property.equals("votingplugin.mainJar") && name.endsWith(".class")) {
+ assertFalse(new String(retained, StandardCharsets.ISO_8859_1)
+ .contains("com/bencodez/votingplugin/neoforge/"),
+ "Retained classes must not link to the removed adapter: " + name);
+ }
+ }
+ }
+ assertEquals(before.getComment(), after.getComment());
+ assertNotNull(after.getManifest());
+ }
+ try (var input = new java.util.jar.JarInputStream(Files.newInputStream(selected))) {
+ assertNotNull(input.getManifest(), "Streaming readers must see the original manifest");
+ }
+ }
+
private static Path packagedJar() {
String configured = System.getProperty("votingplugin.packagedJar");
assumeTrue(configured != null, "Packaged artifact is available only in the package lifecycle");
diff --git a/docs/platform-packaging.md b/docs/platform-packaging.md
new file mode 100644
index 000000000..376632f72
--- /dev/null
+++ b/docs/platform-packaging.md
@@ -0,0 +1,60 @@
+# Opt-in platform packaging
+
+The normal `mvn -B -f VotingPlugin/pom.xml clean package` contract is unchanged:
+`VotingPlugin/target/VotingPlugin.jar` remains the universal main artifact, with
+its existing coordinates and platform discovery metadata. No Jenkins, Nexus or
+other download consumer is switched by this change.
+
+Two optional profiles attach additional artifacts after shading:
+
+| Maven profile | Additional local file | Maven classifier | Discovery |
+| --- | --- | --- | --- |
+| `platform-main` | `VotingPlugin-main.jar` | `main` | Bukkit/Spigot/Paper/Folia, BungeeCord and Velocity |
+| `platform-neoforge` | `VotingPlugin-neoforge.jar` | `neoforge` | NeoForge only |
+
+Run either profile, or both together:
+
+```sh
+mvn -B -f VotingPlugin/pom.xml -Pplatform-main,platform-neoforge clean package
+```
+
+Files use `${packaged.jar.name}` when an existing build overrides that property.
+The unclassified artifact is still built and remains the source of both attached
+artifacts. Existing deploy profiles may be combined explicitly; no install or
+deploy is necessary to build the files. These profiles force fresh JAR creation
+to prevent reshading a previous shaded output. They preserve the mapping manifest
+entry even though selecting a profile disables Maven's active-by-default profile.
+Do not use the developer-specific `dev` profile in automation.
+
+The main classifier removes only the NeoForge adapter package and its discovery
+metadata. It preserves proxy/backend support, shared core, libraries, license
+notices, services, configuration defaults and every SQLite entry in its input.
+The NeoForge classifier removes only the three other platform discovery files;
+it deliberately retains implementation and dependency classes until a separate
+compatibility assessment proves a narrower closure safe. It is a separate
+installable file, not a claim of a lightweight neutral library or native runtime
+acceptance. No dependency minimization, new runtime download or engine substitution
+is used. ZIP64 remains automatic, the manifest is first, and retained entry bytes
+must match the universal artifact in package-phase checks.
+
+The current default branch's SQLite native policy is inherited, not broadened or
+narrowed here. It does not embed every supported native architecture. Restoring
+full supported offline/native behavior is a separate dependency acceptance gate;
+these profile checks must not be represented as Windows/native acceptance. The
+frozen dependency candidate is not modified. Once that work is integrated, every
+additional SQLite/native/resource entry automatically flows to both classifiers
+and is covered by the retained-byte comparison. Custom native override behavior
+is not changed by profile extraction.
+
+Fabric has an existing standalone Gradle/Loom bootstrap in a separate open change.
+It is not on this baseline and does not yet implement the full vote-processing
+feature set. This change does not duplicate it, rename its remapped output or
+present a Maven ZIP as a remapped Fabric mod. A Maven orchestration profile needs
+the actual module, wrapper/build-tool contract, mapping/remap output and owning
+maintainer agreement first. No Fabric artifact is advertised by these profiles.
+
+A future switch of the default download to the main classifier needs an explicit
+artifact/download migration decision and consumer validation. Changing default
+coordinates or replacing a universal artifact is outside this opt-in change.
+These classifiers alone do not promise a multi-megabyte reduction; measured
+savings must be reported for final files against a verified published release.