sakshi8778 opened a new pull request, #12716:
URL: https://github.com/apache/maven/pull/12716
This plan outlines the implementation of mvnlog, a CLI tool to explore Maven
build reports. When run with --web, it serves an interactive web-based report
viewer from a lightweight embedded Java HTTP server.
User Review Required
IMPORTANT
The implementation leverages the built-in JDK
com.sun.net.httpserver.HttpServer which has zero external dependencies and runs
out of the box in standard JRE/JDK configurations (since Java 6).
TIP
To capture detailed performance timings ( mojo starts/ends, warnings/errors,
and logs per mojo), the core Maven execution listener will be updated to
intercept these details during the build and serialize them into
.mvn/reports/build-report-<timestamp>.json upon session completion.
Open Questions
None. The requirements and architecture are fully specified.
Proposed Changes
Maven API CLI Layer
[MODIFY]
Tools.java
Add definitions for MVNLOG_CMD = "mvnlog" and MVNLOG_NAME = "Maven Log
Viewer Tool".
[MODIFY]
ParserRequest.java
Add static factory builder methods: mvnlog(String[] args,
MessageBuilderFactory messageBuilderFactory) and mvnlog(List<String> args,
MessageBuilderFactory messageBuilderFactory).
[NEW]
LogOptions.java
Define options interface for mvnlog (methods web(), port(), and file()).
Core Logging Layer
[MODIFY]
BuildEventListener.java
Add void mojoFinished(ExecutionEvent event, String status) to track mojo
execution endings.
Update void projectFinished(String projectId) to void projectFinished(String
projectId, String status) to record module build status.
[MODIFY]
LoggingExecutionListener.java
Invoke buildEventListener.mojoFinished(...) in mojoSucceeded, mojoFailed,
and mojoSkipped.
Update calls to buildEventListener.projectFinished(...) to include status
("SUCCESS", "FAILED", or "SKIPPED").
[MODIFY]
SimpleBuildEventListener.java
Implement updated interface methods as no-ops.
[NEW]
BuildReportEventListener.java
Implements BuildEventListener. Intercepts all session events and log
messages, tracks start/end times of projects and mojos, groups log messages per
active mojo, and formats warnings/errors as structured problems.
Writes the structured report to .mvn/reports/build-report-<timestamp>.json
upon session success or failure.
CLI & Launcher Layer
[MODIFY]
LookupInvoker.java
Update doDetermineBuildEventListener to wrap the default listener in
BuildReportEventListener when running Maven builds.
[NEW]
MavenLogCling.java
Entry point for the new mvnlog command, extending ClingSupport.
[NEW]
LogContext.java
Context holder for mvnlog execution.
[NEW]
LogParser.java
Parses the arguments for mvnlog command.
[NEW]
CommonsCliLogOptions.java
Command line option parser implementing LogOptions.
[NEW]
LogInvoker.java
Renders build report as formatted console output by default.
If --web is provided, spins up a com.sun.net.httpserver.HttpServer, opens
the default web browser via java.awt.Desktop.browse(URI), and terminates after
30 minutes of inactivity or Ctrl+C.
[NEW]
report.html
Interactive web report viewer. Bundled in classpath. Features dark/light
themes, module gantt charts, collapsible logs per mojo, filterable problems
list, syntax highlighting for failures, and virtual scrolling build log viewer.
Scripts & Packaging
[MODIFY]
mvn
Add --log script argument handling to run
org.apache.maven.cling.MavenLogCling.
[MODIFY]
mvn.cmd
Add --log batch argument handling to run
org.apache.maven.cling.MavenLogCling.
[NEW]
mvnlog
Script launcher that routes arguments to mvn --log "$@".
[NEW]
mvnlog.cmd
Windows command script that routes arguments to mvn.cmd --log %*.
[MODIFY]
component.xml
Include mvnlog in the unix shell script zip/tar.gz packaging group.
Verification Plan
Automated Tests
Build the project using Maven: mvn clean install -DskipTests (to confirm
compile success)
Run CLI parsing and execution tests.
Verify JSON formatting output.
Manual Verification
Execute a sample multi-module build to generate the
.mvn/reports/build-report-<timestamp>.json report.
Run mvnlog --web to launch the web-based report viewer on a custom port and
check timeline rendering, problem sorting, and log search details.
--
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]