Fix coverage-modified classes being included in published artifacts#4341
Closed
Fix coverage-modified classes being included in published artifacts#4341
Conversation
The markGeneratedEqualsHashCode task was modifying .class files in-place in build/classes/java/main and the jar task depended on it, causing bytecode with injected @generated annotations to end up in the published JAR. Fix by copying classes to a separate build/classes-jacoco directory for modification, and only wiring jacocoTestReport (not jar) to depend on the task. https://claude.ai/code/session_01XDZqTUKLBoSJpGPGx9Amxg
Contributor
Test ReportTest Results
Code Coverage (Java 25)
Changed Class Coverage (59 classes)
FieldComplexityEnvironment — method details
QueryVisitorFieldEnvironmentImpl — method details
QueryVisitorFragmentDefinitionEnvironmentImpl — method details
QueryVisitorFragmentSpreadEnvironmentImpl — method details
QueryVisitorInlineFragmentEnvironmentImpl — method details
ImmutableMapWithNullValues — method details
DataFetcherResult — method details
ExecutionId — method details
MergedField — method details
MergedField.MultiMergedField — method details
NonNullableFieldWasNullError — method details
ResultPath — method details
GraphQLContext — method details
IncrementalPayload — method details
IgnoredChar — method details
SourceLocation — method details
ExecutableNormalizedOperationToAstCompiler.ExecutionFragmentDetails — method details
NormalizedInputValue — method details
DefaultEdge — method details
InvalidCursorException — method details
EditOperation — method details
FieldCoordinates — method details
GraphQLNonNull — method details
GraphqlTypeComparatorEnvironment — method details
BaseError — method details
TypeInfo — method details
PropertyFetchingImpl.CacheKey — method details
SerializationError — method details
TypeMismatchError — method details
UnresolvedTypeError — method details
Breadcrumb — method details
NodeLocation — method details
OperationValidator.FieldAndType — method details
|
jacocoTestReport was only including execution data from the JUnit `test` task. The `testng` task also produces a JaCoCo .exec file but it was never merged into the report, causing code exercised only by TestNG tests to show zero coverage. Add `testng` to dependsOn and set executionData to include all .exec files from the jacoco output directory. https://claude.ai/code/session_01XDZqTUKLBoSJpGPGx9Amxg
The markGeneratedEqualsHashCode task copied class files and then modified them with ASM to add @generated annotations on equals/hashCode methods. This changed the bytecode CRC64 checksums, so JaCoCo could not correlate its execution data (recorded against the original classes) with the modified copies. Result: 61 classes with equals/hashCode showed ZERO coverage across all metrics — not just on equals/hashCode, but on every line, branch, and method in the class. Fix by pointing classDirectories back at the original classes/java/main directory and removing the markGeneratedEqualsHashCode task entirely. The small trade-off is that equals/hashCode methods now appear in coverage metrics, but all 61 affected classes regain their full coverage. https://claude.ai/code/session_01XDZqTUKLBoSJpGPGx9Amxg
Member
Author
|
I have to look more closely at this - so far only a quick Claude attempt |
Member
Author
|
Fixed by #4343 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The markGeneratedEqualsHashCode task was modifying .class files in-place
in build/classes/java/main and the jar task depended on it, causing
bytecode with injected @generated annotations to end up in the published
JAR. Fix by copying classes to a separate build/classes-jacoco directory
for modification, and only wiring jacocoTestReport (not jar) to depend
on the task.
https://claude.ai/code/session_01XDZqTUKLBoSJpGPGx9Amxg