gnodet-bot commented on code in PR #1144:
URL:
https://github.com/apache/maven-compiler-plugin/pull/1144#discussion_r4139090687
##########
src/main/java/org/apache/maven/plugin/compiler/ToolExecutor.java:
##########
@@ -915,6 +919,201 @@ private static boolean removeFirsts(Deque<Path> paths,
Integer count) {
}
}
+ /**
+ * Compiles using the ABI-fingerprint incremental strategy. This method
handles the full
+ * lifecycle: determining what to compile, running javac with the analysis
TaskListener,
+ * cascading on ABI changes, and persisting state.
+ *
+ * @param compiler the compiler
+ * @param configuration the options to give to the Java compiler
+ * @param mojo the MOJO for configuration access
+ * @throws IOException if an error occurred while reading or writing a file
+ * @throws MojoException if the compilation failed
+ */
+ void compileWithAbiIncremental(JavaCompiler compiler, final Options
configuration, final AbstractCompilerMojo mojo)
+ throws IOException {
+ if (compiler instanceof ForkedTool) {
+ logger.warn("ABI incremental strategy is not supported with forked
compilation."
+ + " Falling back to full compilation.");
+ }
+ var abiBuild = new AbiIncrementalBuild(outputDirectory);
Review Comment:
💡 **Suggestion (medium):** The warning says "Falling back to full
compilation" but this isn't accurate on incremental builds. When state exists
from a previous run, `initialize()` returns only changed files. Without
`attachTo()` (since the forked task doesn't implement `JavacTask`),
`processRound()` always returns `Set.of()` — so ABI cascade is silently
skipped. Then `finish()` saves state with source hashes but no ABI fingerprints
for newly compiled types.
On the next build, those files' hashes match so they're skipped, but ABI
data is incomplete — ABI-breaking changes in the forked-compiled files won't
cascade to consumers.
To truly fall back to full compilation, invalidate the state so
`initialize()` returns all files:
```suggestion
if (compiler instanceof ForkedTool) {
logger.warn("ABI incremental strategy is not supported with
forked compilation."
+ " Falling back to full compilation.");
}
var abiBuild = new AbiIncrementalBuild(outputDirectory);
if (compiler instanceof ForkedTool) {
abiBuild.invalidate();
}
```
Alternatively, the `instanceof ForkedTool` check could short-circuit to the
standard `compile()` method entirely, avoiding the ABI machinery altogether.
--
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]