Skip to content

Expose Maven logging output capabilities in Maven 4.1 - #13208

Draft
wilx wants to merge 1 commit into
apache:masterfrom
wilx:output-capabilities-4.1
Draft

wilx wants to merge 1 commit into
apache:masterfrom
wilx:output-capabilities-4.1

Conversation

@wilx

@wilx wilx commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Plugins currently have to inspect logging internals to learn where Maven writes and which charset it uses. Add an injectable OutputCapabilities service plus an immutable maven.logging.outputCapabilities map in execution-request data for plugins compiled against older Maven APIs.

Capture the actual logging route, report uncertain detection as UNKNOWN, and preserve resident-invocation cleanup without changing output routing or encoding.

Validation: reactor verification (excluding existing IDE .iml files), focused Core ITs, and Linux runtime checks passed. macOS and Windows remain untested.

Provide a singleton service describing the current logging destination and
charset, plus an immutable execution-request data map for plugins compiled
against older Maven APIs. Capture the map at the start of every Maven
execution, preserving retained maps through request reuse and cleanup.

Capture the actual logging route, preserve initialization and cleanup
behavior, and treat negative exec-provider probes as unknown. Cover
injection, request compatibility access, resident lifecycle where supported,
and terminal detection.
@gnodet

gnodet commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Thanks for this contribution — the use case is real and the API design (OutputCapabilities as an injectable service with a fallback Map<String, String> in request data for older-API plugins) is clean.

A few thoughts before this can move forward:

Milestone / branch targeting

This PR targets master (4.1.0), which is the right vehicle. However, the integration points it touches — LookupInvoker, LookupContext, and PlexusContainerCapsule.updateLogging() — are actively being reshaped by the logging feature chain currently under review (#12694, #13180, and related PRs). This PR will need to be rebased on top of feature/console-modes (#13180) before it can be cleanly reviewed, as the context initialization path is changing there.

Interaction with --console=machine

When --console=machine is active (#13180), Maven writes JSON lines to stdout rather than using the terminal for human-readable output. In that case, Destination should be deterministically REDIRECTED (or a new MACHINE value) derived directly from the console mode flag, not from JLine terminal introspection. Right now TerminalOutputCapabilities.destination() will likely give the right answer incidentally (dumb terminal → REDIRECTED), but it's fragile — if the stdout routing ever changes in machine mode, the detection would silently regress. Once rebased on feature/console-modes, the MavenInvoker.determineConsoleMode() result should feed directly into the outputCapabilities supplier in LookupContext.

Backports (#13209, #13210)

I'd recommend keeping the 3.10.x and 4.0.x backports as drafts for now. This is new API surface, not a bug fix, and adding a new injectable service to maintenance branches is invasive. If dependency:tree or other tools have a concrete regression to fix, that's a different conversation — but the general feature belongs in 4.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants