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


##########
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);
+            }

Review Comment:
   Can't this code be moved into the if block that has checked that the 
requirement isn't a version-range? In case of the latter this seems to be 
ignored any-ways.



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