Never package bytecode-modified class files in published JARs by andimarek · Pull Request #4343 · graphql-java/graphql-java · GitHub
Skip to content

Never package bytecode-modified class files in published JARs#4343

Merged
andimarek merged 1 commit intomasterfrom
fix/exclude-modified-classes-from-jar
Mar 18, 2026
Merged

Never package bytecode-modified class files in published JARs#4343
andimarek merged 1 commit intomasterfrom
fix/exclude-modified-classes-from-jar

Conversation

@andimarek
Copy link
Copy Markdown
Member

Summary

  • The markGeneratedEqualsHashCode task was modifying .class files in-place in build/classes/java/main and the jar task depended on it, causing every published class with equals/hashCode to contain a spurious @Generated (Lgraphql/coverage/Generated;) annotation in the bytecode
  • Fix: copy classes to a separate build/classes-jacoco/ directory before injecting annotations, prepend that directory to the test classpath (so Jacoco CRC64 checksums match the execution data), and point jacocoTestReport at the modified copy
  • The jar/shadowJar/publish tasks now only see pristine compiler output — no bytecode modifications leak into artifacts

Test plan

  • Verified original classes in build/classes/java/main remain unmodified after running markGeneratedEqualsHashCode
  • Verified classes in build/classes-jacoco/java/main contain the @Generated annotation
  • Verified the built JAR does not contain graphql.coverage.Generated annotations
  • Verified the shadow JAR does not contain graphql.coverage.Generated annotations
  • All tests pass (./gradlew test)
  • Jacoco report generates successfully with real coverage data (non-zero counters)
  • equals/hashCode methods are properly excluded from the Jacoco coverage report

🤖 Generated with Claude Code

The markGeneratedEqualsHashCode task was modifying class files in-place
in build/classes/java/main, and the jar task depended on it, causing
the @Generated-annotated bytecode to flow into published artifacts.

Fix: copy classes to a separate build/classes-jacoco/ directory before
modifying them, prepend that directory to the test classpath (so Jacoco
CRC64 checksums match), and point jacocoTestReport at the modified copy.
The jar/shadowJar tasks now only see the pristine compiler output.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@andimarek andimarek enabled auto-merge (rebase) March 18, 2026 00:34
@andimarek andimarek merged commit e53ab1a into master Mar 18, 2026
11 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

@dondonz
Copy link
Copy Markdown
Member

dondonz commented Mar 18, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants