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):
This is a 100% reproducible for a project with the big number of modules.
Affected version
4.0.0-rc-6
Bug description
Maven 4 creates
target/project-local-repounder 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:
pom.xmlshould have a parent, let's call itsuper-pom/pom.xmlsuper-pom/pom.xmlshould have other direct child modules, which do not inherit rootpom.xml./mvnw clean install -T1CMultiThreadedBuilderwill schedulesuper-pom/pom.xmlas a first project to build in the reactor, it finishes alonepom.xmland other modules which definesuper-pomas direct parent$projectRoot/target/project-local-repotargetis empty and fails:(the root project is called
pt). See timeline diagram that demonstrates this (pt-cleanis long and executed in parallel):This is a 100% reproducible for a project with the big number of modules.