gnodet commented on code in PR #1165:
URL: 
https://github.com/apache/maven-compiler-plugin/pull/1165#discussion_r4792578574


##########
src/main/java/org/apache/maven/plugin/compiler/incremental/ProcessorClassification.java:
##########
@@ -0,0 +1,169 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin.compiler.incremental;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * Discovers annotation processor classifications from the processor classpath.
+ *
+ * <p>Reads classification files from two locations in each classpath entry
+ * (directory or JAR), checked in order:
+ * <ol>
+ *   <li>{@code META-INF/maven/compiler/incremental.annotation.processors}</li>
+ *   <li>{@code META-INF/gradle/incremental.annotation.processors}
+ *       (Gradle-compatible, for ecosystem reuse)</li>
+ * </ol>
+ *
+ * <p>File format: one processor per line, {@code fully.qualified.Name,TYPE}
+ * where TYPE is {@code ISOLATING} or {@code AGGREGATING}. Empty lines and
+ * lines starting with {@code #} are ignored.
+ *
+ * <p>Processors not found in any classification file are classified as
+ * {@link ProcessorType#UNKNOWN}.
+ *
+ * @see ProcessorType
+ */
+public class ProcessorClassification {
+
+    private static final String MAVEN_COMPILER_RESOURCE = 
"META-INF/maven/compiler/incremental.annotation.processors";
+    private static final String GRADLE_RESOURCE = 
"META-INF/gradle/incremental.annotation.processors";
+
+    private final Map<String, ProcessorType> classifications = new HashMap<>();
+
+    /**
+     * Creates a classification by scanning the given classpath entries for
+     * processor classification files.
+     *
+     * @param processorPath classpath entries (directories or JARs) to scan
+     */
+    public ProcessorClassification(List<Path> processorPath) {
+        if (processorPath != null) {
+            for (Path entry : processorPath) {
+                loadFromEntry(entry);
+            }
+        }
+    }
+
+    /**
+     * Returns the classification for the given processor class name.
+     *
+     * @param processorClassName fully qualified processor class name
+     * @return the declared type, or {@link ProcessorType#UNKNOWN} if not 
declared
+     */
+    public ProcessorType classify(String processorClassName) {
+        return classifications.getOrDefault(processorClassName, 
ProcessorType.UNKNOWN);
+    }
+
+    /**
+     * Returns the worst (most conservative) classification across all given 
processors.
+     * UNKNOWN &gt; AGGREGATING &gt; ISOLATING.
+     */
+    public ProcessorType worstCase(List<String> processorClassNames) {

Review Comment:
   **Missing documentation**: The `worstCase()` method returns `ISOLATING` for 
an empty processor list, which is counter-intuitive but correct (no processors 
means no processor dependencies, so least conservative behavior is safe).
   
   This should be documented in the method's javadoc to clarify the rationale:
   
   ```java
   /**
    * Returns the worst (most conservative) classification across all given 
processors.
    * UNKNOWN > AGGREGATING > ISOLATING.
    * 
    * @param processorClassNames list of processor class names
    * @return ISOLATING if the list is empty (no processors = no processor 
dependencies),
    *         UNKNOWN if any processor is unclassified,
    *         AGGREGATING if all are classified and at least one is AGGREGATING,
    *         ISOLATING if all are classified as ISOLATING
    */
   ```
   
   _Claude Code on behalf of Guillaume Nodet_



##########
src/main/java/org/apache/maven/plugin/compiler/incremental/ProcessorClassification.java:
##########
@@ -0,0 +1,169 @@
+/*
+ * 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.
+ */
+package org.apache.maven.plugin.compiler.incremental;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * Discovers annotation processor classifications from the processor classpath.
+ *
+ * <p>Reads classification files from two locations in each classpath entry
+ * (directory or JAR), checked in order:
+ * <ol>
+ *   <li>{@code META-INF/maven/compiler/incremental.annotation.processors}</li>
+ *   <li>{@code META-INF/gradle/incremental.annotation.processors}
+ *       (Gradle-compatible, for ecosystem reuse)</li>
+ * </ol>
+ *
+ * <p>File format: one processor per line, {@code fully.qualified.Name,TYPE}
+ * where TYPE is {@code ISOLATING} or {@code AGGREGATING}. Empty lines and
+ * lines starting with {@code #} are ignored.
+ *
+ * <p>Processors not found in any classification file are classified as
+ * {@link ProcessorType#UNKNOWN}.
+ *
+ * @see ProcessorType
+ */
+public class ProcessorClassification {

Review Comment:
   **Missing documentation**: Should document that for optimal incremental 
compilation behavior, **ALL** annotation processors on the processor path 
should be classified.
   
   Mixed scenarios (some JARs with classification files, some without) may 
exhibit conservative fallback behavior. Consider adding this to the class-level 
javadoc:
   
   ```java
    * <p><strong>Important</strong>: For optimal incremental compilation, all 
annotation
    * processors on the processor path should provide classification metadata. 
If only some
    * processors are classified, the incremental build may fall back to 
conservative behavior
    * (UNKNOWN) for safety.
   ```
   
   _Claude Code on behalf of Guillaume Nodet_



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to