apache / apache/maven-enforcer

RequireSameVersion failed even with defined versions of failsafe,surefire,surefire-report-plugin

Open
#916 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
161
Forks
180
Avg merge
1d 20m
Merged PRs (30d)
8

Description

### Affected version

3.6.1,3.6.0

### Bug description

I have defined the maven-enforcer-rule `RequireSameVersions` to keep the versions of
* maven-surefire-plugin
* maven-failsafe-plugin
* maven-surefire-report-plugin
in sync. in my `parent-pom.xml` in the example project.

You can reproduce the failure with this [example project](https://github.com/khmarbaise/maven-enforcer-plugin-requireSameVersion) by running `mvn verify`:
```
[INFO] --- enforcer:3.6.1:enforce (enforce-maven) @ enforcer-test ---
[INFO] Rule 1: org.apache.maven.enforcer.rules.version.RequireMavenVersion passed
[INFO] Rule 2: org.apache.maven.enforcer.rules.RequirePluginVersions passed
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.255 s
[INFO] Finished at: 2025-07-31T20:52:53+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.6.1:enforce (enforce-maven) on project enforcer-test:
[ERROR] Rule 0: org.apache.maven.enforcer.rules.RequireSameVersions failed with message:
[ERROR] Found entries with different versions
[ERROR] Entries with version 3.5.3
[ERROR] - org.apache.maven.plugins:maven-surefire-plugin:maven-plugin (buildPlugin)
[ERROR] Entries with version RELEASE
[ERROR] - org.apache.maven.plugins:maven-surefire-report-plugin:maven-plugin (reportPlugin)
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
```

If you change the plugin version for maven-enforcer-plugin in `parent-pom.xml` to 3.6.0 the failure will look the same.

If you change maven-enforcer-plugin version to `3.5.0` there is no failure anymore. The first occurence is obviously in `3.6.0`.

If you omit the `reporting` area from `parent-pom.xml` you will no issue at all.

The same behaviour can be observed with Maven versions like this:
* 4.0.0-rc4
* 3.9.11
* 3.9.10
* 3.9.9
* 3.8.8

It is not related to maven core it is clearly related to the maven-enforcer-plugin.

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the failure from the linked example project by running `mvn verify`, then inspect the `RequireSameVersions` configuration in `parent-pom.xml`, including the build plugins and reporting area. Done means the surefire, failsafe, and surefire-report plugins are recognized as having the same defined version on supported Maven and enforcer-plugin versions.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.