gnodet opened a new pull request, #13542: URL: https://github.com/apache/maven/pull/13542
## Why Plugins and extensions that need to inspect the build invocation context (goals, user properties, offline mode, concurrency, etc.) currently have to reach into the v3 `MavenExecutionRequest` API. There is no v4 API equivalent for this information. This is part of the broader v3→v4 API migration effort (#13460). ## What Introduces `BuildEnvironment` as a v4 API type on `Session`: - **`BuildEnvironment`** interface in `maven-api-core` — immutable snapshot of the invocation context - **`Session.buildEnvironment()`** — lazy-initialized accessor - **`DefaultBuildEnvironment`** record in `maven-core` — implementation with a `from(MavenSession)` factory ### What is captured | Field | Source | |---|---| | `goals()` | Requested goals/phases | | `userProperties()` | `-Dkey=value` (sensitive values redacted) | | `systemInfo()` | Curated OS/JVM/Maven properties for reproducibility | | `localRepository()` | Local repo path | | `activeProfiles()` | Explicitly activated profiles (`-P`) | | `selectedProjects()` | `-pl` selections | | `resumeFrom()` | `-rf` selector | | `reactorFailureBehavior()` | `-ff` / `-fae` / `-fn` | | `offline()`, `updateSnapshots()`, `batchMode()` | CLI flags | | `threads()` | `-T` concurrency | Sensitive user property keys (containing `password`, `secret`, `token`, etc.) are automatically redacted to `***`. ## How - `Session.buildEnvironment()` is added to the v4 API interface - `DefaultSession` lazily constructs a `DefaultBuildEnvironment` from the `MavenSession` on first access (double-checked locking) - `ApiRunner.DefaultSession` (standalone/test mode) throws `UnsupportedOperationException` - The factory method (`DefaultBuildEnvironment.from()`) is self-contained — downstream PRs (e.g. build report #12695) can consume it without changes ## Related - #13460 — v3→v4 API migration tracking issue - #12695 — build report (will use `BuildEnvironment` in the report JSON) ## Test plan - [x] `mvn compile` — all modules compile - [x] `mvn test -pl impl/maven-core,impl/maven-impl` — 743 tests pass - [ ] Full CI validation 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
