-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[3.9.x] MavenPluginJavaPrerequisiteChecker: Handle 8/1.8 Java version in ranges as well #11577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Java is consistent when reporting versions, but users are not. Fixes apache#11575
| } | ||
| VersionConstraint constraint; | ||
| try { | ||
| constraint = versionScheme.parseVersionConstraint(requiredVersion.equals("8") ? "1.8" : requiredVersion); |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Parameterized tests here
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
This reverts commit 8c00268.
slawekjaranowski
left a comment
There was a problem hiding this 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 😄
|
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. |
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