slachiewicz commented on issue #14081: URL: https://github.com/apache/maven/issues/14081#issuecomment-7064610979
I investigated this and can confirm the report — it is reproducible on a current `maven-4.0.x` build that includes the #13591 backport, and the analysis is correct. **Reproduction.** Using a locally built `4.0.0-SNAPSHOT` distribution at commit `86279de` (which includes the per-project `ConcurrentProjectLock`) and a small Maven 3 API mojo that reads `project.getArtifacts()` at execute time, I get exactly the reported matrix: | Run | Artifacts seen | | --- | --- | | `-b concurrent -T1C` | 0 (broken) | | `-b concurrent -T1C -Djacoco.skip=true` | 0 | | `-b concurrent -T1` | 1 | | default builder `-T1C` (Maven 4 and Maven 3) | 1 | | jacoco moved to `after:verify` | 1 | **Root cause in core.** `MojoExecutor` creates a fresh `DependencyContext` per build-plan step, and `DependencyContext.isResolutionRequiredForCurrentProject()` is an object-identity comparison against `MavenProject.getDependencyArtifacts()`. A fresh context for a step with *no scopes* therefore still reports that resolution is required, so `ensureDependenciesAreResolved` calls `LifecycleDependencyResolver.resolveProjectDependencies` with empty scope collections; `getDependencies` returns an empty set and `setResolvedArtifacts(empty)` is written to the shared project. The later mojo of the first step skips its own resolution (its context still sees unchanged `dependencyArtifacts`) and filters that empty set through its own scope filter. The #13591 lock covers one mojo at a time, so it cannot protect this step-level assumption — this is the same adjacent gap noted during that PR's review. This is core state corruption, not plugin thread safety: the empty write happens inside `MojoExecutor` before the dependency-free mojo decides whether to skip. **Fix.** I opened #14085 (target `maven-4.0.x`): skip `resolveProjectDependencies` when the step has neither scopes to collect nor scopes to resolve (using `||`, so collection-only mojos still resolve), while leaving the unconditional `setArtifactFilter` write untouched so MNG-3297 still holds. It includes a regression test that fails without the change. `impl/maven-core` test suite: 742 tests, 0 failures; spotless clean. Until a release with the fix, binding the dependency-free mojo to `after:verify` (or using `-T1` / the default builder) avoids the problem. -- 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]
