You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "efegokdemir (via GitHub)" <gi...@apache.org> on 2026/09/25 06:51:41 UTC

[PR] Run annotation processors when sources are unchanged [maven-compiler-plugin]

efegokdemir opened a new pull request, #1136:
URL: https://github.com/apache/maven-compiler-plugin/pull/1136

   ## Summary
   
   Fixes #1006.
   
   When `<proc>only</proc>` is configured, the compiler execution is dedicated to annotation processing. Incremental source-change detection must not skip that execution merely because the Java sources are unchanged.
   
   The fix makes `proc=only` use the existing `NONE` incremental mode, so all sources remain available to javac and the processor runs on every execution. A unit regression test covers two executions with unchanged sources.
   
   ## Testing
   
   - `mvn test` — passed (17 tests)
   - `mvn -Dtest=CompilerMojoTestCase#testCompilerProcOnlyRunsWhenSourcesAreUnchanged test` — passed
   - `mvn spotless:check` — passed
   - `git diff --check` — passed
   - `mvn verify` — attempted; the repository's dependency analysis failed while parsing the intentionally minimal `compiled.class` emitted by the existing test compiler stub (`Index 6 out of bounds for length 0`). The test suite itself passed before that lifecycle step.
   
   ## Contribution checklist
   
   - [x] This pull request addresses one issue.
   - [x] A regression test fails on the unchanged implementation and passes with this change.
   - [x] The commit includes a DCO sign-off and a verified SSH signature.
   - [x] The contribution is licensed under the Apache License 2.0.
   
   ## AI assistance
   
   Codex assisted with repository analysis, implementation, test authoring, and validation under human supervision. The submitted change and test results have been reviewed for correctness by the human contributor.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run annotation processors when sources are unchanged [maven-compiler-plugin]

Posted by "desruisseaux (via GitHub)" <gi...@apache.org>.
desruisseaux commented on PR #1136:
URL: https://github.com/apache/maven-compiler-plugin/pull/1136#issuecomment-5983513377

   Thanks, it looks fine to me. I would just like two comments to be added for helping the reader to understand why the amend method is doing a special case with `isAbsent(proc) && !isVersionEqualOrNewer(RELEASE_23)`, then I think we can merge.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run annotation processors when sources are unchanged [maven-compiler-plugin]

Posted by "desruisseaux (via GitHub)" <gi...@apache.org>.
desruisseaux commented on code in PR #1136:
URL: https://github.com/apache/maven-compiler-plugin/pull/1136#discussion_r4174569259


##########
src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTestCase.java:
##########
@@ -247,15 +250,9 @@ public void testCompilerProcFullRunsWhenSourcesAreUnchanged(
     @Basedir("${basedir}/target/test-classes/unit/compiler-proc-only-explicit-incremental-test")
     public void testCompilerProcOnlyRespectsExplicitIncrementalCompilation(
             @InjectMojo(goal = "compile", pom = "plugin-config.xml") CompilerMojo compileMojo) {
-        Log log = mock(Log.class);
-        compileMojo.logger = log;
-        compileMojo.execute();
-
-        clearInvocations(log);
-        compileMojo.execute();
-
-        verify(log, never()).info("Nothing to compile - all classes are up to date.");
-        assertCompilerStubOutputFileExists(compileMojo);

Review Comment:
   This change removes a lot of value to this test. The whole `test-classes/unit/compiler-proc-only-explicit-incremental-test` directory become ignored. What was non-deterministic in the previous version? If nevertheless we keep this change, then we should at least remove what is no longer necessary.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run annotation processors when sources are unchanged [maven-compiler-plugin]

Posted by "desruisseaux (via GitHub)" <gi...@apache.org>.
desruisseaux merged PR #1136:
URL: https://github.com/apache/maven-compiler-plugin/pull/1136


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run annotation processors when sources are unchanged [maven-compiler-plugin]

Posted by "efegokdemir (via GitHub)" <gi...@apache.org>.
efegokdemir commented on code in PR #1136:
URL: https://github.com/apache/maven-compiler-plugin/pull/1136#discussion_r4178995126


##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########


Review Comment:
   Added the requested note in ea009b6. The Javadoc now states that uncertain detection (including pre-Java-23 defaults) conservatively returns true.



##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########
@@ -708,15 +708,24 @@ final EnumSet<IncrementalBuild.Aspect> incrementalCompilationConfiguration() {
     }
 
     /**
-     * Amends the configuration of incremental compilation for the presence of annotation processors.
+     * Amends the default configuration of incremental compilation for annotation processing.
+     * When processing is explicitly requested, incremental compilation is disabled so that processors always run.
+     * On Java versions before 23, an absent {@code proc} value only implies the compiler's default processing mode;
+     * it does not prove that a processor is present, so the traditional rebuild-on-add/change behavior is retained.
+     * This method does not amend an explicitly configured {@link #incrementalCompilation} value.
      *
      * @param aspects the configuration to amend if an annotation processor is found
      * @param dependencyTypes the type of dependencies, for checking if any of them is a processor path
      */
     final void amendincrementalCompilation(EnumSet<IncrementalBuild.Aspect> aspects, Set<PathType> dependencyTypes) {
         if (isAbsent(incrementalCompilation) && hasAnnotationProcessor(dependencyTypes)) {
-            aspects.add(IncrementalBuild.Aspect.REBUILD_ON_ADD);
-            aspects.add(IncrementalBuild.Aspect.REBUILD_ON_CHANGE);
+            if (isAbsent(proc) && !isVersionEqualOrNewer(RELEASE_23)) {
+                aspects.add(IncrementalBuild.Aspect.REBUILD_ON_ADD);

Review Comment:
   Added the requested explanation in ea009b6 above the intermediate pre-Java-23 strategy; no runtime behavior changed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run annotation processors when sources are unchanged [maven-compiler-plugin]

Posted by "gnodet-bot (via GitHub)" <gi...@apache.org>.
gnodet-bot commented on code in PR #1136:
URL: https://github.com/apache/maven-compiler-plugin/pull/1136#discussion_r4101990995


##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########
@@ -714,6 +714,11 @@ final EnumSet<IncrementalBuild.Aspect> incrementalCompilationConfiguration() {
      * @param dependencyTypes the type of dependencies, for checking if any of them is a processor path
      */
     final void amendincrementalCompilation(EnumSet<IncrementalBuild.Aspect> aspects, Set<PathType> dependencyTypes) {

Review Comment:
   💡 **Nit (Javadoc):** The method's Javadoc describes amending incremental compilation for annotation processors, but the new `proc=only` guard is a different concern — it disables incremental compilation entirely. Consider updating the Javadoc to mention this:
   
   ```suggestion
        * Amends the configuration of incremental compilation. If annotation processing only is requested
        * ({@code proc=only}), incremental compilation is disabled so that processors always run.
        * Otherwise, if an annotation processor is present, the incremental configuration is amended
        * to also rebuild on source additions and changes.
   ```



##########
src/test/resources/unit/compiler-proc-only-test/plugin-config.xml:
##########
@@ -0,0 +1,38 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<project>
+  <build>
+    <directory>${project.basedir}/target</directory>
+    <outputDirectory>${project.basedir}/target/classes</outputDirectory>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <compileSourceRoots>
+            <compileSourceRoot>${project.basedir}/src/main/java</compileSourceRoot>
+          </compileSourceRoots>
+          <compilerId>maven-compiler-stub</compilerId>
+          <incrementalCompilation>classes</incrementalCompilation>
+          <proc>only</proc>

Review Comment:
   💡 **Suggestion:** The fixture hardcodes `<incrementalCompilation>classes</incrementalCompilation>`, but the most common user scenario is with `incrementalCompilation` unset (the default). The fix works for both paths — `proc=only` fires before the `isAbsent(incrementalCompilation)` check — but it would be slightly more convincing to also test the default case (or test this one without the explicit `incrementalCompilation` line, since the default path is what issue #1006 describes).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run annotation processors when sources are unchanged [maven-compiler-plugin]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #1136:
URL: https://github.com/apache/maven-compiler-plugin/pull/1136#issuecomment-5984191110

   @desruisseaux Please assign appropriate label to PR according to the type of change.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run annotation processors when sources are unchanged [maven-compiler-plugin]

Posted by "desruisseaux (via GitHub)" <gi...@apache.org>.
desruisseaux commented on PR #1136:
URL: https://github.com/apache/maven-compiler-plugin/pull/1136#issuecomment-5837025638

   The rational for disabling incremental compilation when there is a `-proc only` option is also true for the case of a `-proc full` option: the latter could be for both collecting information on all classes *and* recompiling a few classes. Doing something different in the two cases is an heuristic rules with no guarantees to be true.
   
   Another inconsistency is that the current implementation modifies the configuration only when user did *not* specified explicitly an `incrementalCompilation` value (user configuration has precedence), while this pull request unconditionally discards user configuration in the `-proc only` case.
   
   I propose to revert the changes in the `amendincrementalCompilation` method. Instead, keep the currently existing `if` statement with a different body: delete the two `aspects.add` calls and put the `aspects.clear()` and the new `aspects.add(IncrementalBuild.Aspect.NONE)` instead.
   
   As an optimization, if the project is modular and there is no include/exclude filters, the option should be `MODULES` instead of `NONE`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run annotation processors when sources are unchanged [maven-compiler-plugin]

Posted by "efegokdemir (via GitHub)" <gi...@apache.org>.
efegokdemir commented on code in PR #1136:
URL: https://github.com/apache/maven-compiler-plugin/pull/1136#discussion_r4106719917


##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########
@@ -708,12 +708,20 @@ final EnumSet<IncrementalBuild.Aspect> incrementalCompilationConfiguration() {
     }
 
     /**
-     * Amends the configuration of incremental compilation for the presence of annotation processors.
+     * Amends the configuration of incremental compilation. If annotation processing only is requested
+     * ({@code proc=only}), incremental compilation is disabled so that processors always run.
+     * Otherwise, if an annotation processor is present, the incremental configuration is amended
+     * to also rebuild on source additions and changes.
      *
      * @param aspects the configuration to amend if an annotation processor is found
      * @param dependencyTypes the type of dependencies, for checking if any of them is a processor path
      */
     final void amendincrementalCompilation(EnumSet<IncrementalBuild.Aspect> aspects, Set<PathType> dependencyTypes) {
+        if ("only".equalsIgnoreCase(proc)) {
+            aspects.clear();
+            aspects.add(IncrementalBuild.Aspect.NONE);
+            return;

Review Comment:
   Applied the requested control-flow formatting in commit 010495c. The scoped Spotless check for AbstractCompilerMojo.java and git diff --check pass. The repository-level Maven test invocation remains blocked locally by the available Maven/JDK toolchain (Maven 3.9.16 is below the project’s Maven 4.0.0-rc-7 requirement, and JDK 27 triggers the existing palantir-java-format javac incompatibility); CI will provide the canonical build validation.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run annotation processors when sources are unchanged [maven-compiler-plugin]

Posted by "efegokdemir (via GitHub)" <gi...@apache.org>.
efegokdemir commented on code in PR #1136:
URL: https://github.com/apache/maven-compiler-plugin/pull/1136#discussion_r4174944794


##########
src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTestCase.java:
##########
@@ -247,15 +250,9 @@ public void testCompilerProcFullRunsWhenSourcesAreUnchanged(
     @Basedir("${basedir}/target/test-classes/unit/compiler-proc-only-explicit-incremental-test")
     public void testCompilerProcOnlyRespectsExplicitIncrementalCompilation(
             @InjectMojo(goal = "compile", pom = "plugin-config.xml") CompilerMojo compileMojo) {
-        Log log = mock(Log.class);
-        compileMojo.logger = log;
-        compileMojo.execute();
-
-        clearInvocations(log);
-        compileMojo.execute();
-
-        verify(log, never()).info("Nothing to compile - all classes are up to date.");
-        assertCompilerStubOutputFileExists(compileMojo);

Review Comment:
   The earlier end-to-end assertion ran the mojo twice with `incrementalCompilation=classes`. The second run’s expected log depended on the class-output state left by the first run (including the stub compiler output cleanup), so it did not isolate whether `amendincrementalCompilation()` preserved the explicit setting. I replaced it with a direct assertion that explicitly sets `incrementalCompilation` to `classes`, supplies `PROCESSOR_CLASSES`, and verifies the aspect set remains unchanged. I also removed the now-unused fixture files as requested. Validation on the current branch: `mvn -Denforcer.skip=true -Dspotless.check.skip=true -Dspotless.apply.skip=true -Dspotless.skip=true -Dcheckstyle.skip=true -DskipITs -Dtest=CompilerMojoTestCase test` passed (18 tests). The pushed commit is `cc9c788`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run annotation processors when sources are unchanged [maven-compiler-plugin]

Posted by "desruisseaux (via GitHub)" <gi...@apache.org>.
desruisseaux commented on code in PR #1136:
URL: https://github.com/apache/maven-compiler-plugin/pull/1136#discussion_r4105615318


##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########
@@ -708,12 +708,20 @@ final EnumSet<IncrementalBuild.Aspect> incrementalCompilationConfiguration() {
     }
 
     /**
-     * Amends the configuration of incremental compilation for the presence of annotation processors.
+     * Amends the configuration of incremental compilation. If annotation processing only is requested
+     * ({@code proc=only}), incremental compilation is disabled so that processors always run.
+     * Otherwise, if an annotation processor is present, the incremental configuration is amended
+     * to also rebuild on source additions and changes.
      *
      * @param aspects the configuration to amend if an annotation processor is found
      * @param dependencyTypes the type of dependencies, for checking if any of them is a processor path
      */
     final void amendincrementalCompilation(EnumSet<IncrementalBuild.Aspect> aspects, Set<PathType> dependencyTypes) {
+        if ("only".equalsIgnoreCase(proc)) {
+            aspects.clear();
+            aspects.add(IncrementalBuild.Aspect.NONE);
+            return;

Review Comment:
   Formatting: replace `return;} if` by `} else if`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run annotation processors when sources are unchanged [maven-compiler-plugin]

Posted by "desruisseaux (via GitHub)" <gi...@apache.org>.
desruisseaux commented on code in PR #1136:
URL: https://github.com/apache/maven-compiler-plugin/pull/1136#discussion_r4178924370


##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########


Review Comment:
   Could you add the following comment just below the `{@return ...}` please? This is for helping to understand the change in the `amendincrementalCompilation` method:
   
   > In case of doubt (for example, with Java versions older than 23), conservatively returns {@code true}.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run annotation processors when sources are unchanged [maven-compiler-plugin]

Posted by "desruisseaux (via GitHub)" <gi...@apache.org>.
desruisseaux commented on PR #1136:
URL: https://github.com/apache/maven-compiler-plugin/pull/1136#issuecomment-5967098349

   Some integration tests are failing ([logs there](https://github.com/apache/maven-compiler-plugin/actions/runs/36766039529/job/111156119224?pr=1136#step:8:15210)):
   
   * `default-incremental-disable/pom.xml`
   * `mcompiler-182/pom.xml` — Case sensitivity changes in class names not detected by compiler
   * `MCOMPILER-192/pom.xml` — No error reporting with forked compiler when Compiler includes non java files
   * `MCOMPILER-500-package-info-incr/pom.xml` — add a parameter to exclude some pattern from incr stale source file calculation
   
   Two of them seem related to incremental builds and may need adjustment for the new behaviour. The two others seem unrelated (judging by their title only) and would need some investigation.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run annotation processors when sources are unchanged [maven-compiler-plugin]

Posted by "desruisseaux (via GitHub)" <gi...@apache.org>.
desruisseaux commented on PR #1136:
URL: https://github.com/apache/maven-compiler-plugin/pull/1136#issuecomment-5873335024

   @gnodet-bot : no, at least the consistency point of [above discussion](https://github.com/apache/maven-compiler-plugin/pull/1136#issuecomment-5837025638) is blocking. Doing that later would be a behavioural change for users and likely to cause "regression" bug reports. The comment was saying exactly what to do, please apply.
   
   The `MODULES` point should at least be considered, again for avoiding the risk of regression in the future.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run annotation processors when sources are unchanged [maven-compiler-plugin]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on PR #1136:
URL: https://github.com/apache/maven-compiler-plugin/pull/1136#issuecomment-5871046496

   Fixed CI failure: added `assertCompilerStubOutputFileExists(compileMojo)` at the end of the new test.
   
   The `CompilerStub` creates an empty (0-byte) `compiled.class` file in the output directory during the test. The `dependency:analyze` phase then scans `target/test-classes` recursively and trips on that file with an `ArrayIndexOutOfBoundsException` in ASM (which cannot read an empty class file). All other tests using the stub already call `assertCompilerStubOutputFileExists()`, which both asserts the file exists and deletes it — the Javadoc even mentions this exact issue. The new test was the only one missing that cleanup call.
   
   Fixed in 667a164.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run annotation processors when sources are unchanged [maven-compiler-plugin]

Posted by "efegokdemir (via GitHub)" <gi...@apache.org>.
efegokdemir commented on PR #1136:
URL: https://github.com/apache/maven-compiler-plugin/pull/1136#issuecomment-5918207879

   Adjusted the explicit `incrementalCompilation=classes` regression assertion in 218661a. The second `proc=only` execution performs the expected incremental compile, so it must not emit “Nothing to compile - all classes are up to date.” This matches the neighboring processor-only regression conventions.
   
   Validation: `git diff --check` passed. The focused Maven test could not run locally because this environment has no Java runtime and the checkout has no Maven wrapper; CI is the executable validation for this commit.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run annotation processors when sources are unchanged [maven-compiler-plugin]

Posted by "efegokdemir (via GitHub)" <gi...@apache.org>.
efegokdemir commented on code in PR #1136:
URL: https://github.com/apache/maven-compiler-plugin/pull/1136#discussion_r4155650458


##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########
@@ -708,12 +708,20 @@ final EnumSet<IncrementalBuild.Aspect> incrementalCompilationConfiguration() {
     }
 
     /**
-     * Amends the configuration of incremental compilation for the presence of annotation processors.
+     * Amends the configuration of incremental compilation. If annotation processing only is requested
+     * ({@code proc=only}), incremental compilation is disabled so that processors always run.
+     * Otherwise, if an annotation processor is present, the incremental configuration is amended
+     * to also rebuild on source additions and changes.
      *
      * @param aspects the configuration to amend if an annotation processor is found
      * @param dependencyTypes the type of dependencies, for checking if any of them is a processor path
      */
     final void amendincrementalCompilation(EnumSet<IncrementalBuild.Aspect> aspects, Set<PathType> dependencyTypes) {
+        if ("only".equalsIgnoreCase(proc)) {
+            aspects.clear();
+            aspects.add(IncrementalBuild.Aspect.NONE);
+            return;

Review Comment:
   The current branch now derives the context dry-run flag centrally in AbstractUpgradeGoal.execute() from shouldSaveModifications(), so individual goals cannot omit the mapping. The remaining inference messages use the shared logChange helper and report “would be applied” during check.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run annotation processors when sources are unchanged [maven-compiler-plugin]

Posted by "efegokdemir (via GitHub)" <gi...@apache.org>.
efegokdemir commented on code in PR #1136:
URL: https://github.com/apache/maven-compiler-plugin/pull/1136#discussion_r4155653498


##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########
@@ -708,12 +708,20 @@ final EnumSet<IncrementalBuild.Aspect> incrementalCompilationConfiguration() {
     }
 
     /**
-     * Amends the configuration of incremental compilation for the presence of annotation processors.
+     * Amends the configuration of incremental compilation. If annotation processing only is requested
+     * ({@code proc=only}), incremental compilation is disabled so that processors always run.
+     * Otherwise, if an annotation processor is present, the incremental configuration is amended
+     * to also rebuild on source additions and changes.
      *
      * @param aspects the configuration to amend if an annotation processor is found
      * @param dependencyTypes the type of dependencies, for checking if any of them is a processor path
      */
     final void amendincrementalCompilation(EnumSet<IncrementalBuild.Aspect> aspects, Set<PathType> dependencyTypes) {
+        if ("only".equalsIgnoreCase(proc)) {
+            aspects.clear();
+            aspects.add(IncrementalBuild.Aspect.NONE);
+            return;

Review Comment:
   Correction: my previous reply was sent to this compiler-plugin thread by mistake. It does not concern the Maven upgrade PR; the requested formatting change remains addressed in commit 010495c.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run annotation processors when sources are unchanged [maven-compiler-plugin]

Posted by "efegokdemir (via GitHub)" <gi...@apache.org>.
efegokdemir commented on PR #1136:
URL: https://github.com/apache/maven-compiler-plugin/pull/1136#issuecomment-5889649957

   Applied the blocking consistency feedback in 05525cf. `amendincrementalCompilation` now keeps the existing `incrementalCompilation`-absent condition, clears the default aspects, and selects `NONE` for annotation processors, so `proc=only` and `proc=full` behave consistently without overriding explicit user configuration. I evaluated the `MODULES` optimization; this method does not have the modular-project context needed to select it without broadening the change.
   
   Added coverage for default `proc=full` and explicit `incrementalCompilation` with `proc=only`; the existing `proc=only` regression and CompilerStub cleanup remain intact. `mvn -Denforcer.skip=true -Dspotless.check.skip=true -Dspotless.apply.skip=true -Dspotless.skip=true -Dcheckstyle.skip=true -DskipITs -Dtest=CompilerMojoTestCase test` passed (18 tests), and `git diff --check` passed. The normal Spotless path remains incompatible with this local JDK due the existing palantir-java-format `JCTree$JCCompilationUnit.endPositions` error.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run annotation processors when sources are unchanged [maven-compiler-plugin]

Posted by "efegokdemir (via GitHub)" <gi...@apache.org>.
efegokdemir commented on PR #1136:
URL: https://github.com/apache/maven-compiler-plugin/pull/1136#issuecomment-5968883854

   Addressed the implicit pre-Java-23 `proc` regression in 55c4389. When `proc` is unset on Java <23, the compiler default only means processing is enabled; it does not establish that a processor is present. That path now retains the previous `REBUILD_ON_ADD` / `REBUILD_ON_CHANGE` behavior instead of clearing all aspects to `NONE`. Explicit `proc=only` and `proc=full` still use `NONE`, and the explicit `incrementalCompilation` guard remains unchanged.
   
   Validation: focused `proc=only` and `proc=full` unit tests passed (2/2) on local JDK 27; `git diff --check` passed. The full `CompilerMojoTestCase` run had 1 local JDK-27-only failure in the explicit-incremental expectation (17 passed); the remote JDK-17 CI run before this commit showed that test passing and failed in `MCOMPILER-500-package-info-incr`. I could not execute the reported JDK-17 integration cases locally. Spotless is blocked by the repository formatter’s `JCCompilationUnit.endPositions` incompatibility with JDK 27. No checks are reported for the new remote head yet.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Run annotation processors when sources are unchanged [maven-compiler-plugin]

Posted by "desruisseaux (via GitHub)" <gi...@apache.org>.
desruisseaux commented on code in PR #1136:
URL: https://github.com/apache/maven-compiler-plugin/pull/1136#discussion_r4178952373


##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########
@@ -708,15 +708,24 @@ final EnumSet<IncrementalBuild.Aspect> incrementalCompilationConfiguration() {
     }
 
     /**
-     * Amends the configuration of incremental compilation for the presence of annotation processors.
+     * Amends the default configuration of incremental compilation for annotation processing.
+     * When processing is explicitly requested, incremental compilation is disabled so that processors always run.
+     * On Java versions before 23, an absent {@code proc} value only implies the compiler's default processing mode;
+     * it does not prove that a processor is present, so the traditional rebuild-on-add/change behavior is retained.
+     * This method does not amend an explicitly configured {@link #incrementalCompilation} value.
      *
      * @param aspects the configuration to amend if an annotation processor is found
      * @param dependencyTypes the type of dependencies, for checking if any of them is a processor path
      */
     final void amendincrementalCompilation(EnumSet<IncrementalBuild.Aspect> aspects, Set<PathType> dependencyTypes) {
         if (isAbsent(incrementalCompilation) && hasAnnotationProcessor(dependencyTypes)) {
-            aspects.add(IncrementalBuild.Aspect.REBUILD_ON_ADD);
-            aspects.add(IncrementalBuild.Aspect.REBUILD_ON_CHANGE);
+            if (isAbsent(proc) && !isVersionEqualOrNewer(RELEASE_23)) {
+                aspects.add(IncrementalBuild.Aspect.REBUILD_ON_ADD);

Review Comment:
   Could you add the following comment (or something equivalent) just below the `if` statement? In complement to the comment added in the `hasAnnotationProcessor` method.
   
   ```java
   // Case when `hasAnnotationProcessor(…)` cannot decide for sure.
   // Apply an intermediate strategy between "no processor" and "processor for sure".
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org