ascheman opened a new pull request, #3394:
URL: https://github.com/apache/maven-surefire/pull/3394
Fixes #3393. **Stacked on #3392** (single-module Module Source Hierarchy
support) — draft until #3392 is merged; only the last commit is specific to
this PR.
### Changes
* `ResolvePathResultWrapper` additionally carries the descriptors of sibling
modules found under `target/classes/<module>/`.
* `AbstractSurefireMojo.findModuleDescriptor(...)` resolves ALL nested
module descriptors; the primary module (driving scanning and `--patch-module`)
is the first one that has a nested test output directory.
* `scanDirectories()` unions the test-class scan over every nested
`target/test-classes/<module>/` directory.
* `newStartupConfigWithModularPath(...)`:
* dependency split (classpath vs. module path) is computed per module
descriptor and unioned — an element required on the module path by ANY module
ends up there, since the fork has a single boot layer;
* the primary module's `--add-opens` list is restricted to its own test
packages;
* each sibling module with tests gets `--patch-module <m>=<its test dir>`,
`--add-reads <m>=ALL-UNNAMED` and `--add-opens <m>/<pkg>=ALL-UNNAMED`, passed
to the fork through the existing `StartupConfiguration#getJpmsArguments()`
channel (no change to the surefire-booter API or its serialization).
### Tests
* Unit: `shouldFindAllNestedModuleDescriptors` (all nested modules,
deterministic order).
* IT: `Surefire3393MultiModuleSourceHierarchyIT` — two modules in one POM
(`com.example.extra` requires `com.example.core`, core `requires transitive
jakarta.json` to cover the external-modular-dependency boot failure), whitebox
tests in both modules, 5 tests in ONE execution; skips itself under Maven 3.
### Verification (local, JDK 17 for surefire build/ITs, macOS)
* `maven-surefire-common` unit suite: 849 tests, 0 failures.
* IT matrix:
| Maven | classic IT | single-module MSH IT | multi-module MSH IT |
|---|---|---|---|
| 3.10.0-rc-1 | pass | skip | skip |
| 4.0.0-rc-5 | pass | pass | pass (5 tests, one execution) |
| 4.0.x-SNAPSHOT (rc-6 candidate) | pass | pass | pass |
* Real-world acceptance: 3-module jakarta.json/jsonb component (JDK 25,
Maven 4.0.x-SNAPSHOT): zero-config `mvn test` runs **602 tests, 0 failures in
ONE surefire execution**. With the single-module state (#3392) the same run
fails at the JPMS boot layer (`FindException: Module jakarta.json.bind not
found`); before #3345 it silently ran 0 tests. Fork argsfile verified: two
`--patch-module` entries, per-module `--add-reads`/`--add-opens`,
`--add-exports` from `module-info-patch.args`, and the union dependency split
placing `jakarta.json` on the module path.
---
Following this checklist to help us incorporate your contribution quickly
and easily:
- [x] Each commit in the pull request should have a meaningful subject line
and body.
- [x] Write a pull request description that is detailed enough to
understand what the pull request does, how, and why.
- [x] Run `mvn clean install` to make sure basic checks pass. A more
thorough check will be performed on your pull request automatically.
- [x] You have run the integration tests successfully (the new ITs plus the
matrix above; the full suite runs in CI).
- [x] I hereby declare this contribution to be licenced under the [Apache
License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
--
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]