use of org.apache.ivy.core.module.descriptor.OverrideDependencyDescriptorMediator in project ant-ivy by apache.
the class PomModuleDescriptorBuilder method addDependencyMgt.
public void addDependencyMgt(PomDependencyMgt dep) {
ivyModuleDescriptor.addDependencyManagement(dep);
String key = getDependencyMgtExtraInfoKeyForVersion(dep.getGroupId(), dep.getArtifactId());
overwriteExtraInfoIfExists(key, dep.getVersion());
if (dep.getScope() != null) {
String scopeKey = getDependencyMgtExtraInfoKeyForScope(dep.getGroupId(), dep.getArtifactId());
overwriteExtraInfoIfExists(scopeKey, dep.getScope());
}
if (!dep.getExcludedModules().isEmpty()) {
String exclusionPrefix = getDependencyMgtExtraInfoPrefixForExclusion(dep.getGroupId(), dep.getArtifactId());
int index = 0;
for (ModuleId excludedModule : dep.getExcludedModules()) {
overwriteExtraInfoIfExists(exclusionPrefix + index, excludedModule.getOrganisation() + EXTRA_INFO_DELIMITER + excludedModule.getName());
index++;
}
}
// dependency management info is also used for version mediation of transitive dependencies
ivyModuleDescriptor.addDependencyDescriptorMediator(ModuleId.newInstance(dep.getGroupId(), dep.getArtifactId()), ExactPatternMatcher.INSTANCE, new OverrideDependencyDescriptorMediator(null, dep.getVersion()));
}
use of org.apache.ivy.core.module.descriptor.OverrideDependencyDescriptorMediator in project ant-ivy by apache.
the class IvyOverride method addOverride.
void addOverride(DefaultModuleDescriptor md, IvySettings settings) {
String matcherName = (matcher == null) ? PatternMatcher.EXACT : matcher;
String orgPattern = (org == null) ? PatternMatcher.ANY_EXPRESSION : org;
String modulePattern = (module == null) ? PatternMatcher.ANY_EXPRESSION : module;
md.addDependencyDescriptorMediator(new ModuleId(orgPattern, modulePattern), settings.getMatcher(matcherName), new OverrideDependencyDescriptorMediator(branch, rev));
}
use of org.apache.ivy.core.module.descriptor.OverrideDependencyDescriptorMediator 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