Search in sources :

Example 11 with ExtraInfoHolder

use of org.apache.ivy.core.module.descriptor.ExtraInfoHolder in project ant-ivy by apache.

the class PomModuleDescriptorBuilder method getDependencyManagementMap.

public static Map<ModuleId, String> getDependencyManagementMap(ModuleDescriptor md) {
    Map<ModuleId, String> ret = new LinkedHashMap<>();
    if (md instanceof PomModuleDescriptor) {
        for (Map.Entry<ModuleId, PomDependencyMgt> e : ((PomModuleDescriptor) md).getDependencyManagementMap().entrySet()) {
            PomDependencyMgt dependencyMgt = e.getValue();
            ret.put(e.getKey(), dependencyMgt.getVersion());
        }
    } else {
        for (ExtraInfoHolder extraInfoHolder : md.getExtraInfos()) {
            String key = extraInfoHolder.getName();
            if (key.startsWith(DEPENDENCY_MANAGEMENT)) {
                String[] parts = key.split(EXTRA_INFO_DELIMITER);
                if (parts.length != DEPENDENCY_MANAGEMENT_KEY_PARTS_COUNT) {
                    Message.warn("what seem to be a dependency management extra info " + "doesn't match expected pattern: " + key);
                } else {
                    ret.put(ModuleId.newInstance(parts[1], parts[2]), extraInfoHolder.getContent());
                }
            }
        }
    }
    return ret;
}
Also used : ModuleId(org.apache.ivy.core.module.id.ModuleId) ExtraInfoHolder(org.apache.ivy.core.module.descriptor.ExtraInfoHolder) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Example 12 with ExtraInfoHolder

use of org.apache.ivy.core.module.descriptor.ExtraInfoHolder in project ant-ivy by apache.

the class PomModuleDescriptorBuilder method overwriteExtraInfoIfExists.

private void overwriteExtraInfoIfExists(String key, String value) {
    boolean found = false;
    for (ExtraInfoHolder extraInfoHolder : ivyModuleDescriptor.getExtraInfos()) {
        if (extraInfoHolder.getName().equals(key)) {
            extraInfoHolder.setContent(value);
            found = true;
        }
    }
    if (!found) {
        ivyModuleDescriptor.getExtraInfos().add(new ExtraInfoHolder(key, value));
    }
}
Also used : ExtraInfoHolder(org.apache.ivy.core.module.descriptor.ExtraInfoHolder)

Example 13 with ExtraInfoHolder

use of org.apache.ivy.core.module.descriptor.ExtraInfoHolder in project ant-ivy by apache.

the class PomModuleDescriptorBuilder method getDependencyMgtExclusions.

private static List<ModuleId> getDependencyMgtExclusions(ModuleDescriptor descriptor, String groupId, String artifactId) {
    if (descriptor instanceof PomModuleDescriptor) {
        PomDependencyMgt dependencyMgt = ((PomModuleDescriptor) descriptor).getDependencyManagementMap().get(ModuleId.newInstance(groupId, artifactId));
        if (dependencyMgt != null) {
            return dependencyMgt.getExcludedModules();
        }
    }
    String exclusionPrefix = getDependencyMgtExtraInfoPrefixForExclusion(groupId, artifactId);
    List<ModuleId> exclusionIds = new LinkedList<>();
    for (ExtraInfoHolder extraInfoHolder : descriptor.getExtraInfos()) {
        String key = extraInfoHolder.getName();
        if (key.startsWith(exclusionPrefix)) {
            String fullExclusion = extraInfoHolder.getContent();
            String[] exclusionParts = fullExclusion.split(EXTRA_INFO_DELIMITER);
            if (exclusionParts.length != 2) {
                Message.error(WRONG_NUMBER_OF_PARTS_MSG + exclusionParts.length + " : " + fullExclusion);
                continue;
            }
            exclusionIds.add(ModuleId.newInstance(exclusionParts[0], exclusionParts[1]));
        }
    }
    return exclusionIds;
}
Also used : ModuleId(org.apache.ivy.core.module.id.ModuleId) ExtraInfoHolder(org.apache.ivy.core.module.descriptor.ExtraInfoHolder) LinkedList(java.util.LinkedList)

Aggregations

ExtraInfoHolder (org.apache.ivy.core.module.descriptor.ExtraInfoHolder)13 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)4 ModuleId (org.apache.ivy.core.module.id.ModuleId)4 Test (org.junit.Test)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Date (java.util.Date)2 LinkedHashMap (java.util.LinkedHashMap)2 Configuration (org.apache.ivy.core.module.descriptor.Configuration)2 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)2 License (org.apache.ivy.core.module.descriptor.License)2 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)2 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 GregorianCalendar (java.util.GregorianCalendar)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 DefaultArtifact (org.apache.ivy.core.module.descriptor.DefaultArtifact)1 DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)1 DefaultExcludeRule (org.apache.ivy.core.module.descriptor.DefaultExcludeRule)1