arturobernalg commented on issue #13590:
URL: https://github.com/apache/maven/issues/13590#issuecomment-6231462412

   I could reproduce this on current master (4.1.0-SNAPSHOT) with a small 
reactor: a parent with 4 independent jar modules, each with 
`jakarta.ws.rs:jakarta.ws.rs-api:3.1.0` in `provided` scope and 
`flatten-maven-plugin` 1.6.0 bound to `process-resources`, and one class 
importing `jakarta.ws.rs.core.Response`. `mvn -b concurrent -T 4 package` 
failed 12 times out of 12 with `package jakarta.ws.rs.core does not exist`. It 
passes with `-b concurrent -T 1`, with the default builder at `-T 4`, and with 
flatten bound to `process-classes`, as reported.
   
   My reading of the code: `concurrent.MojoExecutor#useProjectLock` returns 
`false`, so nothing serializes `ensureDependenciesAreResolved` plus the mojo 
execution for the same project. That method replaces the resolved artifacts and 
the artifact filter of the shared `MavenProject` (`setResolvedArtifacts`, 
`setArtifactFilter`), and the mojo reads them when it is configured. If 
`flatten` (collection of `runtime`) does this between the resolution of 
`compile` and the configuration of the compiler, `provided` is not in the set 
it sees.
   
   As an experiment I overrode `getProjectLock` in the concurrent executor so 
that mojos which declare a resolution or collection requirement take a 
per-project `ReentrantLock` around resolution and execution, and mojos without 
such a requirement are not blocked. The same reactor then passed 10 times out 
of 12 instead of 0 out of 12. So this is part of the cause, but there is still 
another shared state involved that I have not found, and I have not opened a PR 
for it. @gnodet, does this match how you expect the concurrent builder to work 
with project state?


-- 
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]

Reply via email to