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;
}
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));
}
}
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;
}
Aggregations