You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This also upgrades the Shadow Gradle plugin from 9.3.2 to 9.4.2 so the backport can retain the original artifact lifecycle configuration.
Summary
define an explicit list of unbundled CLASS-retention annotations to remove from shaded class files
add an ASM-powered cleanup stage after shadowing and before final JAR assembly
preserve invisible annotations whose annotation classes are bundled, including GraphQL Java and relocated dependency annotations
reject new RuntimeInvisibleAnnotations and RuntimeInvisibleParameterAnnotations whose annotation classes are not bundled and are not in the removal list
share the class-file rewrite machinery with the existing JaCoCo annotation task
compile a Java 11 consumer with class-file warnings treated as errors
make the annotation-cleaned JAR the sole unclassified binary artifact and the sole main artifact used by consumers, signing, and publication
Artifact pipeline
The regular jar and shadowJar outputs are internal inputs to the cleanup pipeline. They now have explicit plain and shadow classifiers and live under build/intermediates, outside build/libs.
buildFinalJar is the only task that writes the unclassified binary JAR to build/libs. It consumes the annotation-cleaned class tree directly, so Gradle tracks the actual final archive instead of a temporary archive that is renamed in doLast.
The Java API and runtime variants both expose buildFinalJar. The Shadow Java variant and assemble hook are disabled, and shadowRuntimeElements is non-consumable, so dependency resolution cannot select the uncleaned intermediate. Direct signing, Maven Local publication, and remote publication all depend on verification of the final JAR.
This separation matters because multiple tasks previously owned the same output path. A direct shadowJar invocation could overwrite the cleaned JAR while Gradle still considered the cleanup/reassembly tasks up to date. Unique intermediate paths plus a single final producer remove that failure mode.
Verification
./gradlew outgoingVariants: API and runtime variants expose only buildFinalJar; no consumable Shadow variant remains
./gradlew clean test assemble verifyShadedClassAnnotations compileShadedJarConsumer: passed, including 5,737 tests
./gradlew check -x test -x testng: passed
isolated publishGraphqlJavaPublicationToMavenLocal: published only the main, sources, Javadoc, and POM artifacts
the isolated Maven-local main JAR had the same SHA-256 as the buildFinalJar output
direct ./gradlew jar shadowJar invocation left the final JAR SHA-256 unchanged
The cleanup currently removes 1,345 annotations from 330 shaded class files.
Artifact size
Both artifacts were built through their complete publication pipelines with the same fixed 999.0.0-size-test release version.
Artifact
Size
origin/master before removal
3,878,053 bytes
This PR after removal
3,873,126 bytes
Reduction
4,927 bytes (0.127%)
The uncompressed JAR contents decrease by 16,152 bytes. Both archives contain 2,394 entries, and their manifests are identical.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #4445 to the
26.xmaintenance branch.This also upgrades the Shadow Gradle plugin from 9.3.2 to 9.4.2 so the backport can retain the original artifact lifecycle configuration.
Summary
Artifact pipeline
The regular
jarandshadowJaroutputs are internal inputs to the cleanup pipeline. They now have explicitplainandshadowclassifiers and live underbuild/intermediates, outsidebuild/libs.buildFinalJaris the only task that writes the unclassified binary JAR tobuild/libs. It consumes the annotation-cleaned class tree directly, so Gradle tracks the actual final archive instead of a temporary archive that is renamed indoLast.The Java API and runtime variants both expose
buildFinalJar. The Shadow Java variant and assemble hook are disabled, andshadowRuntimeElementsis non-consumable, so dependency resolution cannot select the uncleaned intermediate. Direct signing, Maven Local publication, and remote publication all depend on verification of the final JAR.This separation matters because multiple tasks previously owned the same output path. A direct
shadowJarinvocation could overwrite the cleaned JAR while Gradle still considered the cleanup/reassembly tasks up to date. Unique intermediate paths plus a single final producer remove that failure mode.Verification
./gradlew outgoingVariants: API and runtime variants expose onlybuildFinalJar; no consumable Shadow variant remains./gradlew clean test assemble verifyShadedClassAnnotations compileShadedJarConsumer: passed, including 5,737 tests./gradlew check -x test -x testng: passedpublishGraphqlJavaPublicationToMavenLocal: published only the main, sources, Javadoc, and POM artifactsbuildFinalJaroutput./gradlew jar shadowJarinvocation left the final JAR SHA-256 unchangedThe cleanup currently removes 1,345 annotations from 330 shaded class files.
Artifact size
Both artifacts were built through their complete publication pipelines with the same fixed
999.0.0-size-testrelease version.origin/masterbefore removalThe uncompressed JAR contents decrease by 16,152 bytes. Both archives contain 2,394 entries, and their manifests are identical.