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


##########
maven-core/src/main/java/org/apache/maven/toolchain/RequirementMatcherFactory.java:
##########
@@ -57,31 +61,78 @@ public String toString() {
     }
 
     private static final class VersionMatcher implements RequirementMatcher {
-        DefaultArtifactVersion version;
+        private final String version;
 
         private VersionMatcher(String version) {
-            this.version = new DefaultArtifactVersion(version);
+            this.version = version;
         }
 
         @Override
         public boolean matches(String requirement) {
-            try {
-                VersionRange range = 
VersionRange.createFromVersionSpec(requirement);
-                if (range.hasRestrictions()) {
-                    return range.containsVersion(version);
+            String r = requirement != null ? 
requirement.toLowerCase(Locale.ENGLISH) : null;
+            String v = version != null ? version.toLowerCase(Locale.ENGLISH) : 
null;
+            if (v == null && r == null) {
+                return true; // null == null
+            }
+            if (v == null || r == null) {
+                return false; // null != non-null
+            }
+            if (v.equals(r)) {
+                return true; // str == str (ignoring case)
+            }
+            return matchesRequirement(v, r);
+        }
+
+        private static final VersionScheme VERSION_SCHEME = new 
GenericVersionScheme();
+
+        private static boolean matchesRequirement(String version, String 
requirement) {
+            boolean interval = false;
+            boolean included = false;
+            if (requirement.endsWith("+")) {
+                interval = true;
+                included = true;
+                requirement = requirement.substring(0, requirement.length() - 
1);
+            } else if (requirement.endsWith("-")) {
+                interval = true;
+                requirement = requirement.substring(0, requirement.length() - 
1);
+            }
+            final String req = requirement;
+
+            // if requirement is not a version range itself
+            if (!req.contains("[") && !req.contains("(") && 
!req.contains(",")) {
+                if (!interval) {
+                    return version.startsWith(req + "."); // "11" -> "11.xxx"

Review Comment:
   For possible 1.8 support, see this similar case: 
https://github.com/apache/maven/commit/c2e4be2ee0a71c5031a59e371a21c2719643efb5



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