Search in sources :

Example 1 with OverrideDependencyDescriptorMediator

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()));
}
Also used : OverrideDependencyDescriptorMediator(org.apache.ivy.core.module.descriptor.OverrideDependencyDescriptorMediator) ModuleId(org.apache.ivy.core.module.id.ModuleId)

Example 2 with OverrideDependencyDescriptorMediator

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));
}
Also used : OverrideDependencyDescriptorMediator(org.apache.ivy.core.module.descriptor.OverrideDependencyDescriptorMediator) ModuleId(org.apache.ivy.core.module.id.ModuleId)

Example 3 with OverrideDependencyDescriptorMediator

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());
        }
    }
}
Also used : OverrideDependencyDescriptorMediator(org.apache.ivy.core.module.descriptor.OverrideDependencyDescriptorMediator) OverrideDependencyDescriptorMediator(org.apache.ivy.core.module.descriptor.OverrideDependencyDescriptorMediator) DependencyDescriptorMediator(org.apache.ivy.core.module.descriptor.DependencyDescriptorMediator) MapMatcher(org.apache.ivy.plugins.matcher.MapMatcher) Map(java.util.Map)

Aggregations

OverrideDependencyDescriptorMediator (org.apache.ivy.core.module.descriptor.OverrideDependencyDescriptorMediator)3 ModuleId (org.apache.ivy.core.module.id.ModuleId)2 Map (java.util.Map)1 DependencyDescriptorMediator (org.apache.ivy.core.module.descriptor.DependencyDescriptorMediator)1 MapMatcher (org.apache.ivy.plugins.matcher.MapMatcher)1