Skip to content

[#1085] Document conservative incremental default on JDK < 23 - #1086

Merged
ascheman merged 3 commits into
apache:masterfrom
aschemaven:bugfix/1085-incremental-default-recompiles-all
Jul 21, 2026
Merged

ascheman merged 3 commits into
apache:masterfrom
aschemaven:bugfix/1085-incremental-default-recompiles-all

Conversation

@ascheman

Copy link
Copy Markdown
Contributor

Fixes #1085.

Per @desruisseaux's steer on the issue: the full rebuild on any change (when proc is unset on JDK < 23) is intentional. Before Java 23 javac defaults to -proc:full and discovers annotation processors on the compile classpath, and recompiling everything avoids losing processor-generated state (e.g. missed META-INF/services registrations). So this keeps the behaviour and documents it instead of changing it.

Changes

  • AbstractCompilerMojo: clarify the incrementalCompilation default-value javadoc — why, on JDK < 23 with proc unset, the plugin conservatively assumes a processor may be present, and that setting proc to none (or an explicit incrementalCompilation) restores per-file recompilation.
  • New IT incremental-proc-none-per-file: with proc=none, changing one of three independent classes recompiles only that file. This exercises the documented workaround and is green on all JDKs (verified on 21 and 25).

Doc + test only; no behavioural change.

ascheman added 2 commits July 20, 2026 18:42
When `proc` is unset, `javac` enables annotation processing by default before
Java 23 (`-proc:full`) and discovers processors on the compile classpath. The
plugin therefore conservatively assumes a processor may be present and applies
`rebuild-on-add,rebuild-on-change` by default, doing a full rebuild on any
change even when no processor is actually present.

This behaviour is intentional (a partial recompile can lose processor-generated
state); document it in the incrementalCompilation default-value javadoc, and
note that Java < 23 users with no annotation processor can restore per-file
recompilation by setting `proc` to `none` or an explicit `incrementalCompilation`.
…JDKs

`incremental-proc-none-per-file` compiles three independent classes with
`proc=none`, modifies one between two `compile` invocations, and asserts that
only the modified file is recompiled. This exercises the documented workaround
for Java < 23 and is green on all JDKs (verified on 21 and 25).
@ascheman ascheman added the bug Something isn't working label Jul 20, 2026
@ascheman
ascheman requested review from Copilot and desruisseaux July 20, 2026 16:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the plugin documentation to explicitly describe why incremental compilation defaults to a conservative full rebuild on JDK < 23 when proc is unset, and adds a new invoker integration test that validates the documented workaround (proc=none) produces per-file recompilation.

Changes:

  • Clarify AbstractCompilerMojo#incrementalCompilation “Default value” Javadoc to explain the JDK < 23 conservative behavior when proc is unset, and how to restore per-file recompilation.
  • Add a new invoker IT (incremental-proc-none-per-file) that disables annotation processing (proc=none), modifies one of three independent classes between two compile runs, and asserts only the modified file is recompiled.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java Documents the intentional conservative incremental default on JDK < 23 when proc is unset, and points to proc=none / explicit incremental config as the workaround.
src/it/incremental-proc-none-per-file/pom.xml Defines an invoker IT project with proc=none and a Groovy step to modify a source file between builds.
src/it/incremental-proc-none-per-file/invoker.properties Runs clean compile, modifies one source file, then runs compile again to exercise incremental recompilation.
src/it/incremental-proc-none-per-file/verify.groovy Asserts the incremental log indicates exactly one modified file is compiled and no “recompile all” fallback occurs.
src/it/incremental-proc-none-per-file/src/main/java/it/A.java Test input class A.
src/it/incremental-proc-none-per-file/src/main/java/it/B.java Test input class B.
src/it/incremental-proc-none-per-file/src/main/java/it/C.java Test input class C.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…spaces

Reflow the incrementalCompilation default-value paragraph so each line breaks
at a sentence or comma-delimited clause boundary (cleaner future diffs), and
replace the non-breaking spaces with regular spaces.
@ascheman
ascheman merged commit 814f75f into apache:master Jul 21, 2026
20 checks passed
@github-actions github-actions Bot added this to the 4.0.0-beta-5 milestone Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default incremental compilation recompiles the whole source set on any change (JDK < 23, no annotation processor)

3 participants