gnodet-bot commented on code in PR #14077: URL: https://github.com/apache/maven/pull/14077#discussion_r4744954413
########## impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlanExecutor.java: ########## @@ -46,9 +46,13 @@ import org.apache.maven.api.Lifecycle; import org.apache.maven.api.MonotonicClock; +import org.apache.maven.api.build.report.BuildStatus; +import org.apache.maven.api.build.report.StepReport; import org.apache.maven.api.plugin.descriptor.AfterLink; import org.apache.maven.api.services.LifecycleRegistry; import org.apache.maven.api.services.MavenException; +import org.apache.maven.impl.build.DefaultStepReport; +import org.apache.maven.impl.build.StepReportData; Review Comment: ⚠️ **Import ordering violation** — `impl.build.DefaultStepReport` and `impl.build.StepReportData` are inserted in the middle of the `api.*` import block, with `api.spi.LifecycleProcessor` appearing *after* them. The `impl.*` imports must come after all `api.*` imports. This will fail Checkstyle. ```suggestion import org.apache.maven.impl.build.DefaultStepReport; ``` ########## api/maven-api-core/src/main/java/org/apache/maven/api/build/report/StepReport.java: ########## @@ -0,0 +1,122 @@ +/* + * 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 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; + +/** + * Report for a single build step in the concurrent builder's execution plan. + * <p> + * Steps are the atomic scheduling units of the concurrent builder. Each step + * belongs to a module and a lifecycle phase (e.g. {@code "before:compile"}, + * {@code "compile"}, {@code "$setup$"}). Steps form a directed acyclic graph + * via their {@link #predecessors()}, which determines the execution order. + * <p> + * This data is only collected when verbose step reporting is enabled + * (e.g. via {@code -Dmaven.build.report.steps=true} or {@code -X}). + * It enables timeline reconstruction, critical-path analysis, and + * scheduling diagnostics. + * + * @since 4.1.0 + * @see BuildReport#steps() Review Comment: ⚠️ **Wrong `@since` version** — every type and method in this PR uses `@since 4.2.0`, but `StepReport` has `@since 4.1.0`. Same issue as `MojoReport.threadName()` from the previous commit. ```suggestion * @since 4.2.0 ``` ########## impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlanExecutor.java: ########## @@ -46,9 +46,13 @@ import org.apache.maven.api.Lifecycle; import org.apache.maven.api.MonotonicClock; +import org.apache.maven.api.build.report.BuildStatus; +import org.apache.maven.api.build.report.StepReport; import org.apache.maven.api.plugin.descriptor.AfterLink; import org.apache.maven.api.services.LifecycleRegistry; import org.apache.maven.api.services.MavenException; +import org.apache.maven.impl.build.DefaultStepReport; +import org.apache.maven.impl.build.StepReportData; import org.apache.maven.api.spi.LifecycleProcessor; Review Comment: Move `StepReportData` import after the `api.*` import group (same fix as `DefaultStepReport` above). ```suggestion import org.apache.maven.impl.build.StepReportData; ``` ########## impl/maven-impl/src/main/java/org/apache/maven/impl/build/StepReportData.java: ########## @@ -0,0 +1,49 @@ +/* + * 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.impl.build; + +import java.util.List; + +import org.apache.maven.api.build.report.StepReport; +import org.apache.maven.api.di.Named; +import org.apache.maven.api.di.Singleton; + +/** + * Shared holder for step reports, populated by the concurrent builder + * after execution and read by {@link BuildReportCollector}. + */ +@Named +@Singleton +public class StepReportData { + + private volatile List<StepReport> steps; + + public void setSteps(List<StepReport> steps) { + this.steps = steps; Review Comment: 🔴 **Stale state between sequential builds (mvnd)** — `StepReportData` is `@Singleton`, so it lives for the entire DI container lifetime. After `BuildPlanExecutor.execute()` calls `setSteps(...)` at the end of a build, those steps persist until the next build's `setSteps()` call overwrites them. If the *next* build uses the sequential builder (not concurrent), `setSteps()` is never called, so `getSteps()` returns the **previous build's step data**. That stale data is then serialized into the new build's report. The fix is to call `stepReportData.clear()` at the start of each build, e.g. in `BuildReportCollector.sessionStarted()` or at the top of `BuildPlanExecutor.execute()` before `ctx.execute()`. -- 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]
