I think that's what I implemented with https://github.com/apache/maven-compiler-plugin/pull/1165 and the 4 stacked PRs. It's waiting for a review...
Le dim. 15 nov. 2026 à 20:46, Sergey Chernov <[email protected]> a écrit : > > Hey, Charan. > > This feature is potentially interesting though it has few caveats. > One of the questions that I have: where do you plan to store the ABI models > for modules and for the libraries? > E.g. Gradle stores this in its ~/.gradle/caches/X/transforms (if I'm not > mistaken). > But regarding Maven it can be target directories for module, ~/.m2 or > projectRoot/.mvn/target (since Maven 4). Should it be a new attached > artifacts of the build? > > Indeed such enhancement may be too ambitious (while potentially realistic). > What I did in the past was somehow similar, but related to > surefire/failsafe plugins caching (as in our case it takes approx ~95% of > all build time to run tests, while things like compilation are relatively > fast). > Instead of forking the plugin (or submitting the change directly to it), I > made an extension that creates proxying wrapper to the real > standard-implemented surefire Mojo delegates. And this wrapper first checks > the existing cache entries (in my case these are stored in ~/.m2/test-cache) > and takes cached artifacts (usually TEST-*.xml reports, but not only), > otherwise executes the tests (delegates to default Mojos) and in case of > success caches them (either locally or remotely). This can be a good start > for your early prototyping, and such project can live separately even if > eventually the enhancement is not merged to the main branch of > maven-compiler-plugin. I mean the logic of either delegating or skipping > the default impl. > My project is https://github.com/seregamorph/maven-surefire-cached which > may be a reference as it gives some clarity on the approach. Conceptually > it's quite different to how the Apache Maven Build Cache Extension is > implemented. > > > On Sun, Nov 15, 2026 at 7:40 PM CHARAN GOWDA M D <[email protected]> > wrote: > > > Hi everyone, > > > > I'm Charan, a Computer Science Engineering student and a contributor to > > Apache Maven. Some of my contributions include: > > > > - > > > > https://github.com/apache/maven/pull/13941 > > - > > > > https://github.com/apache/maven/pull/13722 > > > > I'm considering applying for GSoC 2027 with Apache Maven. Before preparing > > a full proposal, I'd like to share an idea I've been exploring and get > > feedback from the community. > > > > *Proposal: Introduce class-level dependency tracking and ABI-aware > > invalidation for incremental compilation in maven-compiler-plugin.* > > > > *Problem* > > > > The Maven Compiler Plugin already supports incremental compilation through > > different strategies. However, its current approach primarily determines > > which source files need compilation based on file changes, timestamps, > > compiler options, and dependency changes. > > > > For example, when a source file is modified, Maven's default incremental > > compilation strategy can trigger recompilation of the entire module. > > Alternatively, compiling only the modified source files does not > > necessarily recompile other classes that depend on the changed class, which > > can lead to compilation errors or inconsistent outputs. > > > > This creates an opportunity to explore a more dependency-aware approach to > > incremental Java compilation, particularly for large projects containing > > many source files. > > > > *Proposed idea* > > > > Investigate and prototype class-level dependency tracking in > > maven-compiler-plugin. > > > > The proposed mechanism would maintain a dependency graph between compiled > > classes and use it to determine which classes are affected when a source > > file changes. > > > > Ideally, the implementation would also distinguish between API/ABI changes > > and implementation-only changes. > > > > For example: > > > > User.java > > | > > +---- UserService.java > > | | > > | +---- UserController.java > > | > > +---- UserRepository.java > > > > PaymentService.java > > > > Consider two scenarios: > > > > 1. > > > > *Implementation-only change:* If only the body of a private method in > > User.java changes without affecting its externally observable ABI, > > dependent classes may not need recompilation. > > 2. > > > > *API/ABI change:* If a public method signature or another relevant > > compile-time contract changes, the affected dependent classes should be > > identified and recompiled. > > > > The intention is to minimize unnecessary compilation while preserving the > > correctness and consistency of build outputs. > > > > *Prior art and existing work* > > > > I've started looking into the following: > > > > - > > > > *Maven Compiler Plugin:* Its existing incremental compilation > > strategies, particularly the incrementalCompilation configuration > > introduced in the 4.x line. I want to understand how the existing > > classes, > > sources, and rebuild strategies can be extended or improved without > > duplicating existing functionality. > > - > > > > *Maven Build Cache Extension:* It already provides input fingerprinting, > > build caching, and restoration of previously generated outputs. I would > > like to understand how class-level dependency analysis could complement > > its > > existing caching mechanism. > > - > > > > *Gradle incremental Java compilation:* Gradle provides class-level > > dependency analysis and ABI-based compile avoidance. Its approach is an > > interesting reference for investigating how similar capabilities could > > fit > > into Maven's compiler plugin architecture. > > - > > > > *GNU Make:* Its prerequisite-based dependency model initially inspired > > this exploration. However, Java compilation introduces additional > > complexity, particularly around type dependencies, compiler analysis, > > and > > generated sources. > > > > *Open design questions* > > > > There are several areas where I would appreciate guidance: > > > > 1. > > > > *Dependency analysis:* What would be the most reliable approach to > > constructing a class-level dependency graph? Should this be based on > > bytecode analysis, compiler APIs, or another mechanism? > > 2. > > > > *ABI detection:* How should the implementation identify changes that > > affect a class's compile-time contract versus changes limited to its > > implementation? > > 3. > > > > *Correctness and edge cases:* How should cases involving inlined > > constants, annotation processors, generated sources, inheritance, and > > deleted classes be handled? > > 4. > > > > *Build cache integration:* How should the dependency information be > > persisted and integrated with the existing Build Cache Extension without > > introducing inconsistent build results? > > 5. > > > > *Compatibility:* How can this functionality be introduced without > > breaking existing compiler plugin configurations or changing the > > behaviour > > of existing incremental compilation strategies? > > > > *Rough implementation plan (12 weeks)* > > > > 1. > > > > *Research and design:* Study the existing incremental compilation > > implementation, reproduce relevant scenarios, investigate Gradle's > > approach, and prepare a design document. > > 2. > > > > *Dependency analysis prototype:* Develop a mechanism to collect and > > persist class-level dependency information, initially focusing on > > straightforward Java dependency relationships. > > 3. > > > > *Change detection and invalidation:* Identify affected classes after > > source changes and investigate ABI-aware invalidation. Use conservative > > full recompilation whenever correctness cannot be established. > > 4. > > > > *Testing and evaluation:* Add unit and integration tests covering > > dependency changes, API modifications, implementation-only changes, > > deleted > > classes, and relevant edge cases. > > 5. > > > > *Performance evaluation and documentation:* Compare compilation > > behaviour against the existing strategies using representative projects > > and > > document the implementation, limitations, and performance results. > > > > The scope would be refined based on the existing implementation and > > community feedback. > > > > *I'd appreciate feedback on the following:* > > > > 1. > > > > Is this a meaningful and feasible direction for a 12-week GSoC project, > > or is the proposed scope too ambitious? > > 2. > > > > Does similar functionality already exist in the Maven Compiler Plugin's > > development branch, Maven 4, or any ongoing discussions or JIRA issues? > > 3. > > > > Would maven-compiler-plugin be the appropriate place for this > > implementation, or would parts of the functionality be better suited to > > another Maven component? > > 4. > > > > Would any Apache Maven committer or experienced contributor be > > interested in discussing and potentially mentoring this idea for GSoC > > 2027? > > 5. > > > > Are there specific classes, existing implementations, or design > > discussions in the codebase that I should investigate before taking this > > further? > > > > I understand that this is an early-stage idea and that some aspects may > > overlap with existing work. I'm open to refining the scope or exploring a > > different approach based on the community's feedback. > > > > As I've already started contributing to Maven, I'd like to use this > > opportunity to work on a more substantial improvement and develop a deeper > > understanding of its compiler and build execution architecture. > > > > I'd appreciate any feedback, suggestions, or pointers to relevant > > discussions. > > > > Thank you for your time. > > > > Best regards, > > > > Charan Gowda M D > > GitHub: https://github.com/charangowdamd-cmd > > -- ------------------------ Guillaume Nodet --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
