Skip to content

Recompile when dependencies change - #1102

Open
wilx wants to merge 1 commit into
apache:maven-compiler-plugin-3.xfrom
wilx:issue-1087-dependency-state
Open

Recompile when dependencies change#1102
wilx wants to merge 1 commit into
apache:maven-compiler-plugin-3.xfrom
wilx:issue-1087-dependency-state

Conversation

@wilx

@wilx wilx commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • persist the ordered class path and module path in the plugin-local dependencies.lst state file
  • collect persisted metadata and the current-build timestamp fallback in one cached scan per normalized dependency path, removing the previous duplicate traversal
  • record regular dependency files as size and modification time, and exploded dependency directories as a stable metadata fingerprint
  • trigger the existing changed dependency rebuild reason when dependencies are added, removed, reordered, relocated, or replaced at the same path
  • add unit coverage for the consolidated detector and integration coverage for dependency removal and same-path SNAPSHOT replacement

Why

The 3.x incremental check only considered dependency timestamps relative to the current Maven session. It could therefore miss a dependency removed between invocations or a JAR replaced at the same path before the next invocation, leaving stale application bytecode.

The persisted comparison and the existing session-relative fallback are now consolidated. A missing baseline still detects dependencies rebuilt during the current Maven invocation, while unchanged builds no longer walk exploded dependencies once for persisted state and again for the timestamp fallback.

Validation

  • JAVA_HOME=/opt/jdks/latest-8 /opt/maven/latest/bin/mvn clean verify — 36 tests passed
  • JAVA_HOME=/opt/jdks/latest-21 /opt/maven/latest/bin/mvn clean verify — 36 tests passed
  • focused MCOMPILER-349, MCOMPILER-474, dependency-removal, and same-path-replacement integration tests passed
  • JAVA_HOME=/opt/jdks/latest-21 /opt/maven/latest/bin/mvn -Prun-its clean verify — 78 builds passed, 5 environment-specific skips

Fixes #1087


Following this checklist to help us incorporate your
contribution quickly and easily:

  • An issue is filed for this change: No recompilation if the dependencies have changed #1087. This pull request addresses only that issue.
  • Each commit in the pull request has a meaningful subject line and body.
  • The pull request title describes the issue. The template's [MCOMPILER-XXX] convention is not applicable because this is tracked as GitHub issue No recompilation if the dependencies have changed #1087.
  • The pull request description explains what the pull request does, how, and why.
  • Ran mvn clean verify.
  • Ran the integration tests successfully with mvn -Prun-its clean verify.

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

@wilx
wilx marked this pull request as ready for review July 31, 2026 21:48
@wilx
wilx marked this pull request as draft July 31, 2026 22:19
@wilx
wilx force-pushed the issue-1087-dependency-state branch from 3d01630 to 665f6cf Compare July 31, 2026 22:42
@wilx
wilx marked this pull request as ready for review July 31, 2026 22:43
Persist ordered classpath and module-path dependency state between plugin invocations. Compare file metadata and stable directory fingerprints while preserving current-build timestamp detection in the same scan, so removed, reordered, relocated, and same-path replaced dependencies trigger recompilation without duplicate directory traversal.

Fixes apache#1087
@wilx
wilx force-pushed the issue-1087-dependency-state branch from 665f6cf to 096cfb4 Compare July 31, 2026 23:25
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.

1 participant