@Test public void testFeaturePattern() { Pattern pattern = VerifyMojo.getPattern(Arrays.asList("foobiz", "!foo*", "bar", "!ba*", "*")); assertTrue(pattern.matcher("foobiz/1.0").matches()); assertFalse(pattern.matcher("foobaz/1.0").matches()); assertTrue(pattern.matcher("bar/1.0").matches()); assertFalse(pattern.matcher("baz/1.0").matches()); assertTrue(pattern.matcher("biz/1.0").matches()); pattern = VerifyMojo.getPattern(Arrays.asList("!hibernate", " *")); assertTrue(pattern.matcher("framework/4.2.0.SNAPSHOT").matches()); }
static Pattern getPattern(List<String> features) { StringBuilder sb = new StringBuilder(); boolean prevIsNeg = false; for (String feature : features) { if (sb.length() > 0 && !prevIsNeg) { sb.append("|"); } sb.append("("); feature = feature.trim(); boolean negative = feature.startsWith("!"); if (negative) { feature = feature.substring("!".length()); sb.append("(?!"); } String p = feature.replaceAll("\\.", "\\\\.").replaceAll("\\*", ".*"); sb.append(p); if (!feature.contains("/")) { sb.append("/.*"); } if (negative) { sb.append(")"); } prevIsNeg = negative; } for (String feature : features) { sb.append(")"); } return Pattern.compile(sb.toString()); }
VerifyMojo extends MojoSupport { static Pattern getPattern(List<String> features) { StringBuilder sb = new StringBuilder(); boolean prevIsNeg = false; for (String feature : features) { if (sb.length() > 0 && !prevIsNeg) { sb.append("|"); } sb.append("("); feature = feature.trim(); boolean negative = feature.startsWith("!"); if (negative) { feature = feature.substring("!".length()); sb.append("(?!"); } String p = feature.replaceAll("\\.", "\\\\.").replaceAll("\\*", ".*"); sb.append(p); if (!feature.contains("/")) { sb.append("/.*"); } if (negative) { sb.append(")"); } prevIsNeg = negative; } for (String feature : features) { sb.append(")"); } return Pattern.compile(sb.toString()); } }
VerifyMojo extends MojoSupport { static Pattern getPattern(List<String> features) { StringBuilder sb = new StringBuilder(); boolean prevIsNeg = false; for (String feature : features) { if (sb.length() > 0 && !prevIsNeg) { sb.append("|"); } sb.append("("); feature = feature.trim(); boolean negative = feature.startsWith("!"); if (negative) { feature = feature.substring("!".length()); sb.append("(?!"); } String p = feature.replaceAll("\\.", "\\\\.").replaceAll("\\*", ".*"); sb.append(p); if (!feature.contains("/")) { sb.append("/.*"); } if (negative) { sb.append(")"); } prevIsNeg = negative; } for (String feature : features) { sb.append(")"); } return Pattern.compile(sb.toString()); }  }
VerifyMojo extends MojoSupport { static Pattern getPattern(List<String> features) { StringBuilder sb = new StringBuilder(); boolean prevIsNeg = false; for (String feature : features) { if (sb.length() > 0 && !prevIsNeg) { sb.append("|"); } sb.append("("); feature = feature.trim(); boolean negative = feature.startsWith("!"); if (negative) { feature = feature.substring("!".length()); sb.append("(?!"); } String p = feature.replaceAll("\\.", "\\\\.").replaceAll("\\*", ".*"); sb.append(p); if (!feature.contains("/")) { sb.append("/.*"); } if (negative) { sb.append(")"); } prevIsNeg = negative; } for (String feature : features) { sb.append(")"); } return Pattern.compile(sb.toString()); }  @Override void execute(); Map<String, Features> loadRepositories(DownloadManager manager, Set<String> uris); static Set<String> getPrefixedProperties(Map<String, String> properties, String prefix); static Map<String, Map<VersionRange, Map<String, String>>> getMetadata(Map<String, String> properties, String prefix); }
VerifyMojo extends MojoSupport { static Pattern getPattern(List<String> features) { StringBuilder sb = new StringBuilder(); boolean prevIsNeg = false; for (String feature : features) { if (sb.length() > 0 && !prevIsNeg) { sb.append("|"); } sb.append("("); feature = feature.trim(); boolean negative = feature.startsWith("!"); if (negative) { feature = feature.substring("!".length()); sb.append("(?!"); } String p = feature.replaceAll("\\.", "\\\\.").replaceAll("\\*", ".*"); sb.append(p); if (!feature.contains("/")) { sb.append("/.*"); } if (negative) { sb.append(")"); } prevIsNeg = negative; } for (String feature : features) { sb.append(")"); } return Pattern.compile(sb.toString()); }  @Override void execute(); Map<String, Features> loadRepositories(DownloadManager manager, Set<String> uris); static Set<String> getPrefixedProperties(Map<String, String> properties, String prefix); static Map<String, Map<VersionRange, Map<String, String>>> getMetadata(Map<String, String> properties, String prefix);  }