cstamas commented on code in PR #1337:
URL: https://github.com/apache/maven/pull/1337#discussion_r1419569071


##########
maven-core/src/main/java/org/apache/maven/plugin/internal/MavenPluginMavenPrerequisiteChecker.java:
##########
@@ -48,16 +57,35 @@ public void accept(PluginDescriptor pluginDescriptor) {
                 requiredMavenVersion == null || 
requiredMavenVersion.trim().isEmpty();
 
         if (!isBlankVersion) {
-            boolean isRequirementMet = false;
+            VersionScheme versionScheme = versionSchemeProvider.get(); // this 
must happen within session
+            VersionConstraint constraint;
             try {
-                isRequirementMet = 
runtimeInformation.isMavenVersion(requiredMavenVersion);
-            } catch (IllegalArgumentException e) {
+                constraint = 
versionScheme.parseVersionConstraint(requiredMavenVersion);
+            } catch (InvalidVersionSpecificationException e) {
                 logger.warn(
                         "Could not verify plugin's Maven prerequisite as an 
invalid version is given in "
                                 + requiredMavenVersion,
                         e);
                 return;
             }
+
+            Version current;
+            try {
+                String mavenVersion = runtimeInformation.getMavenVersion();
+                if (mavenVersion == null || mavenVersion.isEmpty()) {
+                    throw new IllegalArgumentException("Could not determine 
current Maven version");
+                }
+                current = versionScheme.parseVersion(mavenVersion);

Review Comment:
   No, in Maven the type `Version` can be parsed only within session (as 
session is used to choose schema). RTInfo participates in places like `mvn -v`, 
where there is no session nor should be session at all. So it would be chicken 
or egg situation. RTInfo is good as is, all it should do is expose String 
version, and let anyone interested in it possibly parse/compare/whatever.



-- 
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: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to