gnodet opened a new pull request, #12650: URL: https://github.com/apache/maven/pull/12650
## Summary - Fixes the race condition in `ReactorReader` where `maven-clean-plugin` deletes `target/project-local-repo` while other modules are concurrently writing to it during parallel builds - Adds a `ReentrantReadWriteLock` that blocks concurrent installs while the owning project's clean phase is running - Adds `isProjectLocalRepoOwner()` to detect when a project's build directory contains the shared `project-local-repo` - Includes an integration test that reproduces the scenario: root pom with a parent (super-pom) in the reactor ## Problem When the root `pom.xml` has a parent (super-pom) that is also part of the reactor, `MultiThreadedBuilder` schedules the super-pom first, then runs the root pom and sibling modules in parallel. The root pom's `clean` phase (`maven-clean-plugin`) deletes the entire `target/` directory, which includes `project-local-repo`. Concurrently, sibling modules that complete call `installIntoProjectLocalRepository()` which writes into `target/project-local-repo`, causing `maven-clean-plugin` to fail: ``` Failed to clean project: Failed to delete .../target/project-local-repo ``` ## Solution A `ReentrantReadWriteLock` coordinates access to the `project-local-repo` directory: - **Write lock**: acquired when the project that owns the `project-local-repo` directory enters its `clean` phase (`MojoStarted`), released when the clean mojo completes (`MojoSucceeded`/`MojoFailed`). This blocks all concurrent installs while `maven-clean-plugin` is deleting `target/`. - **Read lock**: acquired by `ProjectSucceeded`/`ForkedProjectSucceeded` handlers around `installIntoProjectLocalRepository()`. Multiple installs can proceed concurrently (read locks are shared), but all block while the write lock is held. ## Test plan - [ ] Integration test `MavenITgh12646ProjectLocalRepoCleanRaceTest` — verifies `clean install -T 4` succeeds for a multi-module project where the root pom has a parent in the reactor - [ ] Existing tests pass (compilation verified) - [ ] CI green 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
