use of org.apache.ivy.plugins.matcher.MapMatcher in project ant-ivy by apache.
the class MatcherLookup method get.
/**
* @param attrs
* A map of attributes that matcher should match.
*
* @return a list of matchers that can apply to module withs specified attributes
*/
public List<MapMatcher> get(Map<String, String> attrs) {
List<MapMatcher> matchers = new ArrayList<>();
// Step 1: find matchers from nonExactMatchers list
if (!nonExactMatchers.isEmpty()) {
for (MapMatcher matcher : nonExactMatchers) {
if (matcher.matches(attrs)) {
matchers.add(matcher);
}
}
}
// Step 2: find matchers from exactMatchers list of key
String key = key(attrs);
List<MapMatcher> exactMatchers = lookup.get(key);
if (exactMatchers != null) {
for (MapMatcher matcher : exactMatchers) {
if (matcher.matches(attrs)) {
matchers.add(matcher);
}
}
}
// Step 3: (iff key != DEFAULT) find matchers from exactMatchers of DEFAULT
if (!DEFAULT.equals(key)) {
List<MapMatcher> defaultExactMatchers = lookup.get(DEFAULT);
if (defaultExactMatchers != null) {
for (MapMatcher matcher : defaultExactMatchers) {
if (matcher.matches(attrs)) {
matchers.add(matcher);
}
}
}
}
return matchers;
}
use of org.apache.ivy.plugins.matcher.MapMatcher in project ant-ivy by apache.
the class ModuleRules method dump.
/**
* Dump the list of rules to {@link Message#debug(String)}
*
* @param prefix
* the prefix to use for each line dumped
*/
public void dump(String prefix) {
if (rules.isEmpty()) {
Message.debug(prefix + "NONE");
return;
}
for (Map.Entry<MapMatcher, T> entry : rules.entrySet()) {
MapMatcher midm = entry.getKey();
T rule = entry.getValue();
Message.debug(prefix + midm + " -> " + rule);
}
}
use of org.apache.ivy.plugins.matcher.MapMatcher in project ant-ivy by apache.
the class IvySettings method addModuleConfiguration.
/**
* regular expressions as explained in Pattern class may be used in attributes
*
* @param attributes Map
* @param matcher PatternMatcher
* @param resolverName String
* @param branch String
* @param conflictManager String
* @param resolveMode String
*/
public synchronized void addModuleConfiguration(Map<String, String> attributes, PatternMatcher matcher, String resolverName, String branch, String conflictManager, String resolveMode) {
checkResolverName(resolverName);
moduleSettings.defineRule(new MapMatcher(attributes, matcher), new ModuleSettings(resolverName, branch, conflictManager, resolveMode));
}
use of org.apache.ivy.plugins.matcher.MapMatcher in project ant-ivy by apache.
the class XmlModuleDescriptorWriter method printAllMediators.
private static void printAllMediators(ModuleDescriptor md, PrintWriter out) {
Map<MapMatcher, DependencyDescriptorMediator> mediators = md.getAllDependencyDescriptorMediators().getAllRules();
for (Map.Entry<MapMatcher, DependencyDescriptorMediator> mediatorRule : mediators.entrySet()) {
MapMatcher matcher = mediatorRule.getKey();
DependencyDescriptorMediator mediator = mediatorRule.getValue();
if (mediator instanceof OverrideDependencyDescriptorMediator) {
OverrideDependencyDescriptorMediator oddm = (OverrideDependencyDescriptorMediator) mediator;
out.print(String.format("\t\t<override org=\"%s\" module=\"%s\" matcher=\"%s\"", XMLHelper.escape(matcher.getAttributes().get(IvyPatternHelper.ORGANISATION_KEY)), XMLHelper.escape(matcher.getAttributes().get(IvyPatternHelper.MODULE_KEY)), XMLHelper.escape(matcher.getPatternMatcher().getName())));
if (oddm.getBranch() != null) {
out.print(" branch=\"" + XMLHelper.escape(oddm.getBranch()) + "\"");
}
if (oddm.getVersion() != null) {
out.print(" rev=\"" + XMLHelper.escape(oddm.getVersion()) + "\"");
}
out.println("/>");
} else {
Message.verbose("ignoring unhandled DependencyDescriptorMediator: " + mediator.getClass());
}
}
}
Aggregations