gnodet opened a new issue, #13472:
URL: https://github.com/apache/maven/issues/13472
Part of #13460 — Migrate Maven internals from v3 to v4 API
## Context
Today, embedding Maven programmatically requires using the v3 entry point:
```
Maven.execute(MavenExecutionRequest) → MavenExecutionResult
```
`MavenExecutionRequest` is a massive mutable bean (~80 getters/setters)
mixing CLI concerns, session config, and execution parameters. The v4 API needs
a clean equivalent so Maven can be used embedded without going through the CLI
layer (`InvokerRequest` / `Parser`).
The v4 API already has building blocks:
- `BuildReport`, `BuildEnvironment` (PR #12695) — structured execution
output and invocation context
- `InvokerRequest` / `Parser` / `Options` (`api/maven-api-cli`) —
CLI-specific parsing
- `Session` — holds configuration, projects, settings, repositories
What's missing is a **service + request/result** for programmatic execution.
## Proposed Design
Follow the established v4 pattern (`Service.method(Request) → Result`):
```java
// api/maven-api-services
@Experimental
interface Maven {
MavenExecutionResult execute(MavenExecutionRequest request);
}
@Immutable
interface MavenExecutionRequest {
Session session();
List<String> goals();
List<String> selectedProjects(); // -pl equivalent
String resumeFrom(); // -rf equivalent
List<String> activeProfileIds();
// ... clean, focused set of execution parameters
static Builder builder() { ... }
}
@Immutable
interface MavenExecutionResult {
BuildReport report();
boolean isSuccessful();
List<FailureReport> failures();
}
```
### Two entry points, same service
```
CLI: InvokerRequest → Parser → builds MavenExecutionRequest →
Maven.execute()
Embedder: builds MavenExecutionRequest directly →
Maven.execute()
```
### Key differences from v3 `MavenExecutionRequest`
- **Immutable with a builder** — same pattern as `ModelBuilderRequest`,
`ProjectBuilderRequest`, etc.
- **No mixed concerns** — CLI parsing stays in `InvokerRequest`/`Parser`,
session config stays in `Session`, execution request is just "what to build and
how"
- **Result wraps `BuildReport`** — leveraging the structured report from
#12695 instead of a loose bag of exceptions
## Compatibility
The v3 `Maven.execute(MavenExecutionRequest)` stays for embedders that
depend on it. Its implementation delegates to the v4 service internally,
adapting request/result types.
## Dependencies
- Benefits from #12695 (BuildReport / BuildEnvironment) for the result type
- Should be designed alongside Session inversion (#13462)
- Will be consumed by #13466 (orchestrator/CLI migration)
## Complexity
Medium. This is primarily API design + a thin implementation layer. The hard
part is deciding what belongs on the execution request vs on the session.
_Claude Code on behalf of Guillaume Nodet_
--
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]