rmannibucau commented on code in PR #12695:
URL: https://github.com/apache/maven/pull/12695#discussion_r4357236279


##########
api/maven-api-core/src/main/java/org/apache/maven/api/build/report/FailureReport.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.api.build.report;
+
+import java.time.Instant;
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Immutable;
+import org.apache.maven.api.annotations.Nonnull;
+import org.apache.maven.api.annotations.Nullable;
+
+/**
+ * Details about a build failure.
+ *
+ * @since 4.1.0
+ * @see BuildReport#failures()
+ */
+@Experimental
+@Immutable
+public interface FailureReport {
+
+    /**
+     * The GAV of the module where the failure occurred
+     * ({@code groupId:artifactId:version}).
+     *
+     * @return the module identifier, never {@code null}
+     */
+    @Nonnull
+    String module();
+
+    /**
+     * The mojo that failed, formatted as {@code artifactId:version:goal}
+     * (e.g. {@code "maven-compiler-plugin:3.15.0:compile"}).
+     *
+     * @return the mojo identifier, or {@code null} if the failure was not 
mojo-specific
+     */
+    @Nullable
+    String mojo();
+
+    /**
+     * When the failure occurred (wall-clock time).
+     *
+     * @return the failure instant, never {@code null}
+     */
+    @Nonnull
+    Instant timestamp();
+
+    /**
+     * The simple class name of the root cause exception
+     * (e.g. {@code "MojoFailureException"}, {@code 
"LifecycleExecutionException"}).
+     * <p>
+     * Useful for programmatic triage — tools can pattern-match on known
+     * exception types without parsing the message.
+     *
+     * @return the exception type name, or {@code null} if unavailable
+     */
+    @Nullable
+    String exceptionType();
+
+    /**
+     * The exception message.
+     *
+     * @return the error message, never {@code null}
+     */
+    @Nonnull
+    String message();

Review Comment:
   why not keeping the exception there?



##########
api/maven-api-core/src/main/java/org/apache/maven/api/build/report/ModuleReport.java:
##########
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.api.build.report;
+
+import java.time.Duration;
+import java.time.Instant;
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.annotations.Immutable;
+import org.apache.maven.api.annotations.Nonnull;
+import org.apache.maven.api.annotations.Nullable;
+
+/**
+ * Build results for a single module in a reactor build.
+ *
+ * @since 4.1.0
+ * @see BuildReport#modules()
+ */
+@Experimental
+@Immutable
+public interface ModuleReport {
+
+    /**
+     * The module's group ID.
+     *
+     * @return the group ID, never {@code null}
+     */
+    @Nonnull
+    String groupId();
+
+    /**
+     * The module's artifact ID.
+     *
+     * @return the artifact ID, never {@code null}
+     */
+    @Nonnull
+    String artifactId();
+
+    /**
+     * The module's version.
+     *
+     * @return the version string, never {@code null}
+     */
+    @Nonnull
+    String version();
+
+    /**
+     * The build outcome for this module.
+     *
+     * @return the status, never {@code null}
+     */
+    @Nonnull
+    BuildStatus status();
+
+    /**
+     * When this module started building (wall-clock time).
+     *
+     * @return the start instant, never {@code null}
+     */
+    @Nonnull
+    Instant startTime();
+
+    /**
+     * How long this module took to build.
+     *
+     * @return the duration, never {@code null}
+     */
+    @Nonnull
+    Duration duration();
+
+    /**
+     * The trace identifier associated with this module build.
+     * <p>
+     * Tracing extensions can provide this value by setting the
+     * {@code otel.trace_id} key in the SLF4J MDC before the module starts.
+     *
+     * @return the trace identifier, or {@code null} if no tracing context was 
provided
+     * @since 4.1.0
+     */
+    @Nullable
+    String traceId();

Review Comment:
   i'd create a TracingContext wrapper or alike with traceid+spanId+parentSpanId
   
   also not sure we must use `String` for these values since often they can be 
stored as long so maybe Object or alike



##########
impl/maven-core/src/main/java/org/apache/maven/internal/build/DefaultModuleReport.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.internal.build;
+
+import java.time.Duration;
+import java.time.Instant;
+import java.util.List;
+
+import org.apache.maven.api.build.report.BuildStatus;
+import org.apache.maven.api.build.report.LogEvent;
+import org.apache.maven.api.build.report.ModuleReport;
+import org.apache.maven.api.build.report.MojoReport;
+
+/**
+ * Internal immutable implementation of {@link ModuleReport}.
+ */
+record DefaultModuleReport(

Review Comment:
   think we can make mojos/output read only at instantiation time so no need of 
overrides (same for most records)



##########
impl/maven-core/src/main/java/org/apache/maven/internal/build/BuildReportJsonWriter.java:
##########
@@ -0,0 +1,440 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.internal.build;
+
+import org.apache.maven.api.BuildEnvironment;
+import org.apache.maven.api.build.report.BuildReport;
+import org.apache.maven.api.build.report.FailureReport;
+import org.apache.maven.api.build.report.LogEvent;
+import org.apache.maven.api.build.report.ModuleReport;
+import org.apache.maven.api.build.report.MojoReport;
+import org.apache.maven.api.services.BuilderProblem;
+
+/**
+ * Serializes a {@link BuildReport} to JSON without any external library 
dependency.
+ * <p>
+ * The output is human-readable (indented with 2 spaces) and designed to be
+ * stable across Maven versions — field order is fixed, and new fields are
+ * appended at the end of each object.
+ */
+final class BuildReportJsonWriter {

Review Comment:
   i'd avoid the strinbuilder totally and pass directly the 
outputstream/writer, no need to have it in mem at all



-- 
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]

Reply via email to