stevestorey opened a new issue, #14151:
URL: https://github.com/apache/maven/issues/14151

   ### Affected version
   
   4.0.0-SNAPSHOT (4.0.x, be1e367). Java 25 (Corretto 25.0.5.1), Linux
   
   ### Bug description
   
   With `-b concurrent`, goals bound to `verify` run before compilation, tests 
and packaging. Checks find nothing to check and pass, so the build reports 
BUILD SUCCESS when it should fail. With `maven-failsafe-plugin` in its usual 
configuration, a failing integration test no longer fails the build:
   
   ```
   [INFO] --- clean:3.5.0:clean (default-clean) @ verify-repro ---
   [INFO] --- failsafe:3.6.1:verify (default) @ verify-repro ---
   ...
   [INFO] --- jar:3.5.1:jar (default-jar) @ verify-repro ---
   [INFO] --- surefire:3.6.1:test (default-test) @ verify-repro ---
   [INFO] --- failsafe:3.6.1:integration-test (default) @ verify-repro ---
   [ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 
0.024 s <<< FAILURE! -- in example.CalcIT
   [INFO] BUILD SUCCESS
   ```
   
   `clean install` then installs the jar. The same happens with `-T1`, so it is 
not a race. Maven 3 and the Maven 4 default builder fail the build.
   
   Reproducer: https://github.com/stevestorey/maven-concurrent-verify-repro. 
`check.sh` runs `clean verify` with one profile per plugin:
   
   ```sh
   MVN=mvn4 ./check.sh -b concurrent -T1C   # BROKEN
   MVN=mvn4 ./check.sh -b concurrent -T1    # BROKEN
   MVN=mvn4 ./check.sh                      # OK (default builder)
   MVN=mvn3 ./check.sh                      # OK
   ```
   
   | Goal | Maven 3.10.2 and Maven 4 default builder | Maven 4 `-b concurrent` |
   | --- | --- | --- |
   | `failsafe:verify` 3.6.1, failing integration test | BUILD FAILURE | BUILD 
SUCCESS |
   | `jacoco:check` 0.8.16, coverage below the minimum | BUILD FAILURE | BUILD 
SUCCESS ("Skipping JaCoCo execution due to missing execution data file") |
   | `dependency:analyze-only` 3.11.0 with `failOnWarning`, unused dependency | 
BUILD FAILURE | BUILD SUCCESS |
   | `gpg:sign` 3.2.8 | jar signed | BUILD SUCCESS, jar not signed |
   
   Without `clean`, `failsafe:verify` reads the previous run's summary: a build 
whose integration tests pass fails if they failed in the build before.
   
   #### This is the plugins' default phase
   
   No execution in the reproducer sets a phase. `verify` is the default phase 
declared by all four goals, three of them in Apache Maven plugins. The 
[lifecycle 
guide](https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html)
 describes `verify` as "run any checks on results of integration tests to 
ensure quality criteria are met", and says "Failsafe and code coverage plugins 
bind goals to integration-test and verify phases".
   
   Under the Maven 4 lifecycle it could be argued that these goals belong in 
`after:verify`, and binding them there does work with `-b concurrent`. But 
Maven 3 skips `after:` phases, so a plugin or POM that supports both can't 
simply move, and existing builds give no sign that their checks have stopped 
working.
   
   #### Cause
   
   `verify` contains `unit-test` and `integration-test`. `BuildPlanExecutor` 
orders contained phases between the `before:` and `after:` steps of their 
container:
   
   ```java
   // for each phase, make sure children phases are executed between before and 
after steps
   lifecycle.allPhases().forEach(phase -> phase.phases().forEach(child -> {
       steps.get(BEFORE + child.name()).executeAfter(steps.get(BEFORE + 
phase.name()));
       steps.get(AFTER + phase.name()).executeAfter(steps.get(AFTER + 
child.name()));
   }));
   ```
   
   The container's own step is only ordered between its `before:` and `after:` 
steps, not relative to its children. `VERIFY` is `after(VALIDATE)`, so a goal 
bound to `verify` is ready once `validate` is done. The build plan (`-X`) for 
the failsafe profile:
   
   ```
   Phase:         verify
   Predecessors:  clean
   ...
   Phase:         integration-test
   Predecessors:  compile, package, clean, after:resources
   ```
   
   #### Expected behaviour
   
   Goals bound to `verify` run after the project's tests, packaging and 
integration tests, as with the default builder.
   
   Possible directions (not tested):
   
   - order a container phase's own step after its children's `after:` steps. 
This would also affect the other container phases, such as `validate`, which 
contains `initialize`;
   - do that only for `verify`, or treat a `verify` binding as `after:verify`.
   
   #### Related
   
   - #14114 (install and deploy run after a test failure) has a different 
cause. Its fix, #14119, is in be1e367 and does not change this ordering.
   - #13230 made `install` and `deploy` wait for `verify`, so that what is 
installed has been verified. Goals bound to `verify` itself don't give that 
guarantee.


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