Supplement processor-module-path with module-path dependencies#1042
Supplement processor-module-path with module-path dependencies#1042mariuszs wants to merge 1 commit intoapache:masterfrom
Conversation
3ff2838 to
bb5a9ab
Compare
When a dependency appears both on --module-path (as a direct project dependency with type modular-jar) and as a transitive dependency of a modular-processor, Maven's dependency resolver places it only on --module-path. However, javac resolves the processor module layer independently, causing a FindException when the processor module cannot find its required dependency. This fix copies module-path entries to processor-module-path when processor modules are present, ensuring javac can resolve all dependencies needed by modular annotation processors. Note: this applies only to modular paths. For classpath-based processors, javac uses a single class loader that can see both the classpath and the processor path, so no supplementing is needed. Closes apache#1039
bb5a9ab to
f8a6fd1
Compare
|
I think that the analysis is correct and this pull request seems to address the issue, but as a workaround. Ideally, it seems to me that the issue should be addressed in Maven core or in Maven resolver. It would allow to add only the dependencies that were really requested, instead of adding all dependencies that could potentially have been requested. I was hopping that apache/maven#11380 would help, but maybe it is only a first step. If I'm guessing correctly (I have not yet verified with a step-by-step debugging), the above-cited PR 11380 fixes the type of transitive dependencies when the type is only |
Summary
Fixes #1039 —
FindExceptionwhen amodular-processordependency transitively requires a module that is also a direct project dependency (declared asmodular-jar).Root cause: Maven's conflict resolution places a dependency on only one path type. When
avaje-injectis declared asmodular-jar(→--module-path) and is also a transitive dependency ofavaje-inject-generator(modular-processor→--processor-module-path), it ends up only on--module-path. Sincejavacresolves the processor module layer independently, it throwsFindException: Module not found.Fix: After dependency resolution, copy
--module-pathentries to--processor-module-pathwhen processor modules are present. This is safe because the processor module layer is isolated — additional modules don't cause conflicts.Changes
ToolExecutor.java: AddedsupplementProcessorModulePath()method (~15 lines)modular-processor-shared-dep/that reproduces the exact scenarioTest plan
modular-processor-shared-depfails without fix (FindException), passes with fix