desruisseaux commented on code in PR #1144: URL: https://github.com/apache/maven-compiler-plugin/pull/1144#discussion_r4179210293
########## src/main/java/org/apache/maven/plugin/compiler/incremental/AbiIncrementalBuild.java: ########## @@ -0,0 +1,893 @@ +/* + * 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.io.UncheckedIOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; +import java.util.stream.Collectors; + +/** + * ABI-fingerprint-driven incremental build engine, designed for embedding + * in maven-compiler-plugin alongside the existing timestamp-based + * {@code IncrementalBuild}. + * + * <p>The plugin drives compilation; this class determines <em>what</em> to + * compile and performs post-compilation bytecode analysis to build the + * dependency graph and ABI fingerprints. Typical usage: + * + * <pre>{@code + * var abi = new AbiIncrementalBuild(outputDir); + * abi.setClasspathEntries(classpath); + * abi.setReactorModulePaths(reactorModules); + * abi.setProcessorPath(processorPath); + * abi.setConfigHash(configHash); + * + * Set<Path> toCompile = abi.initialize(allSourceFiles); + * + * while (!toCompile.isEmpty()) { + * compiler.compile(toCompile); // any compiler, any mode + * toCompile = abi.processCompiledClasses(toCompile); + * } + * + * abi.finish(); + * }</pre> + * + * <p>After each compilation pass, {@link #processCompiledClasses(Set)} scans + * the freshly produced {@code .class} files, updates the dependency graph and + * ABI fingerprints, and returns any additional files that must be compiled in + * the next pass (cascade due to ABI changes, or newly discovered dependencies). + * The loop converges in at most 2–3 passes in practice. + * + * <p>The engine persists its state as {@code .abi-incremental-state} in the Review Comment: Why a hidden file? (the `.` prefix). -- 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]
