apache / apache/maven-surefire
Support multiple Java modules per POM with Maven 4 Module Source Hierarchy
- Dominant language
- Java
- Stars
- 461
- Forks
- 588
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 19
Description
Follow-up to #3345 / #3392, which add support for the Maven 4 Module Source Hierarchy with ONE Java module per POM.
Maven 4 allows declaring several modules in one POM (`` with multiple `` entries, POM model 4.1.0). maven-compiler-plugin 4.x compiles them to `target/classes//`, `target/classes//`, … and test classes to `target/test-classes//`.
With the single-module support from #3392, surefire on such a project:
1. detects only the FIRST nested module descriptor,
2. scans only that module's nested test directory,
3. decides classpath-vs-module-path placement of dependencies with that single module descriptor via `LocationManager.resolvePaths(...)` — dependencies that only sibling modules `require` stay on the classpath, and the forked JVM fails at boot:
`java.lang.module.FindException: Module not found, required by `
(all nested modules resolve into the boot layer because `target/classes` is on the module path as a directory of modules, together with `--add-modules ALL-MODULE-PATH`),
4. patches and opens only the first module.
Reproduced with a real-world 3-module component (jakarta.json/jsonb implementation, 602 tests): zero-config surefire fails with the `FindException` above; the only working setup is one surefire execution per module with explicit `classesDirectory`/`testClassesDirectory`/`additionalClasspathElements`.
Expected: one `mvn test` execution runs the tests of ALL modules — each module patched with its own `target/test-classes//`, each opened for reflection, and the dependency split computed as the union over all module descriptors.
A PR implementing this (stacked on #3392) follows immediately.
cc @desruisseaux — this is the multi-module follow-up announced in #3345.
Contributor guide
Research direction
Start with the single-module Maven 4 support from #3392 and inspect LocationManager.resolvePaths(...), then reproduce the reported three-module Maven 4 project. Track module-specific classes and test directories, dependency resolution, and patching or opening for each descriptor. Done means one mvn test execution runs all modules without the reported FindException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system, testing-qa
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100