Skip to content

Conversation

@cstamas
Copy link
Member

@cstamas cstamas commented Dec 18, 2025

Java is consistent when reporting versions, but users are not. No need to go below 1.8, as Maven 3.9 is Java 8 only. This PR makes "8/1.8" work for ranges as well, not only for standalone version.

Fixes #11575

Java is consistent when reporting versions, but users are not.

Fixes apache#11575
@cstamas cstamas added this to the 3.9.13 milestone Dec 18, 2025
@cstamas cstamas self-assigned this Dec 18, 2025
@cstamas cstamas added bug Something isn't working mvn3 labels Dec 18, 2025
@cstamas cstamas marked this pull request as ready for review December 18, 2025 13:17
}
VersionConstraint constraint;
try {
constraint = versionScheme.parseVersionConstraint(requiredVersion.equals("8") ? "1.8" : requiredVersion);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two lines above you substring currentVersion here it's about requiredVersion. Is it intended or are you accidently mixing variables?

public class MavenPluginJavaPrerequisiteCheckerTest {

@Test
public void testMatchesVersion() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Parameterized tests here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the change as you asked, but now fails with checkstyle:

Error:  src/test/java/org/apache/maven/plugin/internal/MavenPluginJavaPrerequisiteCheckerTest.java:[67,19] (design) VisibilityModifier: Variable 'requiredVersion' must be private and have accessor methods.
Error:  src/test/java/org/apache/maven/plugin/internal/MavenPluginJavaPrerequisiteCheckerTest.java:[70,19] (design) VisibilityModifier: Variable 'currentVersion' must be private and have accessor methods.
Error:  src/test/java/org/apache/maven/plugin/internal/MavenPluginJavaPrerequisiteCheckerTest.java:[73,20] (design) VisibilityModifier: Variable 'expected' must be private and have accessor methods.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clearly the two are not aligned: as if I make field private or just non-public, I get

Cannot set parameter 'requiredVersion'. Ensure that the field 'requiredVersion' is public.

So one want this, other want that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do it simple, you can try to add suppress for checkstyle, by the way I'm working on move test to JUnit 5 in #11547

Copy link
Member

@slawekjaranowski slawekjaranowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to change a PR title to be more descriptive what is fixed 😄

@slawekjaranowski slawekjaranowski linked an issue Dec 18, 2025 that may be closed by this pull request
@kwin
Copy link
Member

kwin commented Dec 19, 2025

What about Maven 4? Shouldn't the versions be interpreted the same?

@cstamas
Copy link
Member Author

cstamas commented Dec 19, 2025

What about Maven 4? Shouldn't the versions be interpreted the same?

Maven4 is Java 17+, hence it does not need to handle 8/1.8 (both are less than 17).

Maven 3 can run on Java 8 and higher, and the problem is really ONLY when it runs on Java 8 (as it reports 1.8 as version), but users are inconsistent, and may use "8" or "1.8", depending on their mood.

@cstamas cstamas changed the title [3.9.x] Make up for users inconsistency [3.9.x] MavenPluginJavaPrerequisiteChecker: Handle 8/1.8 Java version in ranges as well Dec 19, 2025
@cstamas cstamas merged commit c2e4be2 into apache:maven-3.9.x Dec 19, 2025
18 checks passed
@cstamas cstamas deleted the maven-3.9.x-gh-11575 branch December 19, 2025 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working mvn3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Java prerequisites for Maven Plugins fails for Java 8

4 participants