Repository navigation
SONARJAVA-7320 Cache safe Maven module results in PR checks - #6500
romainbrenguier wants to merge 7 commits into
Conversation
| <maven.build.cache.input.1>../java-checks-test-sources/aws/src</maven.build.cache.input.1> | ||
| <maven.build.cache.input.2>../java-checks-test-sources/default/src</maven.build.cache.input.2> | ||
| <maven.build.cache.input.3>../java-checks-test-sources/java-17/src</maven.build.cache.input.3> | ||
| <maven.build.cache.input.4>../java-checks-test-sources/spring-3.2/src</maven.build.cache.input.4> | ||
| <maven.build.cache.input.5>../java-checks-test-sources/spring-web-4.0/src</maven.build.cache.input.5> | ||
| <maven.build.cache.input.6>../java-checks-test-sources/quarkus-arc-3.15/src</maven.build.cache.input.6> |
There was a problem hiding this comment.
⚠️ Bug: Test-source POM/classpath changes don't invalidate consumer module caches
The frontend, checks, AWS checks, and testkit modules add only ../java-checks-test-sources/*/src as extra cache inputs. Their tests also read outputs built from the test-source POMs. DependencyVersionInferenceTest loads ../java-checks-test-sources/default/target/test-classpath.txt and spring-3.2/target/test-classpath.txt, and JParserTestUtils resolves semantics from each test project's target/test-classpath.txt. Those files come from maven-dependency-plugin:build-classpath in java-checks-test-sources/pom.xml, driven by each sub-POM's dependencies. None of these modules has a Maven dependency on the test-source modules, so a change to a sub-POM (for example a Renovate bump of a Spring/AWS version in java-checks-test-sources/default/pom.xml) leaves their fingerprints unchanged.
The CI restore falls back to the config_prefix key, so an older archive can still be restored after the POM hash changes. The extension then reports hits for java-frontend/java-checks and restores old Surefire reports without running the tests that depend on the new classpath. That breaks the PR's claim that an outdated entry can never stand in for tests that must run.
Fix: add the test-source POMs (or the generated test-classpath.txt files) as extra inputs for each consumer module. Alternatively, declare the test-source modules as test-scoped reactor dependencies so their fingerprints propagate.
Also fingerprint the test-source POMs that determine test-classpath.txt (repeat for java-checks, java-checks-aws, and java-checks-testkit with the matching sub-modules):
<maven.build.cache.input.7>../java-checks-test-sources/pom.xml</maven.build.cache.input.7>
<maven.build.cache.input.8>../java-checks-test-sources/default/pom.xml</maven.build.cache.input.8>
<maven.build.cache.input.9>../java-checks-test-sources/aws/pom.xml</maven.build.cache.input.9>
<maven.build.cache.input.10>../java-checks-test-sources/java-17/pom.xml</maven.build.cache.input.10>
<maven.build.cache.input.11>../java-checks-test-sources/spring-3.2/pom.xml</maven.build.cache.input.11>
<maven.build.cache.input.12>../java-checks-test-sources/spring-web-4.0/pom.xml</maven.build.cache.input.12>
<maven.build.cache.input.13>../java-checks-test-sources/quarkus-arc-3.15/pom.xml</maven.build.cache.input.13>
- Apply fix
Check the box to apply the fix or reply for a change | Was this helpful? React with 👍 / 👎
Code Review
|
| Auto-apply | Compact | Unblock |
|
|
|
Was this helpful? React with 👍 / 👎 | Gitar
|





Part of AP-1237
Summary
clean verify, sanity test-sourceclean compile, and custom-rules exampleclean package.masterpushes or same-repository PR jobs; fork PRs have no save step.Validation
clean compileran 62 goals; clean warm run restored eight modules and ran eight goals. Source invalidation and a second clean checkout with copied cache passed.clean packageran 11 goals; clean warm run restored the module and 13 Surefire reports, running one goal. Source, failing test, fixture, compiler-setting, partial-test, and rollback checks passed. Each skipped-test and ignored-failure poisoning pair exited 0 then 1 after the POM fix. A second clean checkout with copied cache passed.clean verify. Sanity restored all eight compile modules, then ran both live tests successfully. Custom rules restored its module while license aggregation still ran.versions:setcommand succeeded in a disposable checkout and updated the root, sanity-source, and plugin POMs. Workflow YAML and diff checks passed; deep Vortex analysis found no issues in the latest changed files.Remaining limits
Native remote transport is unconfigured. GitHub Actions archive reuse is verified for trusted PR updates; fork PRs cannot write shared archives. Service-backed and publication jobs remain uncached. Cache hits restore configured outputs, not the entire
targetdirectory.Summary by Gitar
maven-build-cache-extension1.3.0 with.mvn/maven-build-cache-config.xmlfingerprinting sources and POMsskip,skipTests, andtestFailureIgnoreproperties fingerprint test settings in root and custom-rules POMsapache-build-cacheprofile pinsImplementation-BuildandBuild-Timemanifest entriesAGENTS.mdandREADME.md, linking todocs/maven-build-cache.mdThis will update automatically on new commits.