Skip to content

project-local-repo clean race condition when root pom has parent #12646

Description

@seregamorph

Affected version

4.0.0-rc-6

Bug description

Maven 4 creates target/project-local-repo under the root project directory, which contains built JAR artifacts and there is a preference to use them in case of module subset builds.
The directory location assumes that the root project is also a root parent for other modules and if it's not, there is a race condition to clean this directory.

How to reproduce the problem:

  • root pom.xml should have a parent, let's call it super-pom/pom.xml
  • the super-pom/pom.xml should have other direct child modules, which do not inherit root pom.xml
  • build the multi-module project as a parallel build, like ./mvnw clean install -T1C
  • the MultiThreadedBuilder will schedule super-pom/pom.xml as a first project to build in the reactor, it finishes alone
  • then, in parallel it starts building root pom.xml and other modules which define super-pom as direct parent
  • maven-clean-plugin of root pom.xml iterates files for removal
  • at the same time(!) other modules start adding file under $projectRoot/target/project-local-repo
  • maven-clean-plugin rechecks that target is empty and fails:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:3.5.0:clean (default-clean) 
on project pt: Failed to clean project: Failed to delete /Users/..../server/target/project-local-repo -> [Help 1]

(the root project is called pt). See timeline diagram that demonstrates this (pt-clean is long and executed in parallel):

Image

This is a 100% reproducible for a project with the big number of modules.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions