use of org.apache.ivy.core.module.id.ModuleId in project ant-ivy by apache.
the class PomModuleDescriptorBuilder method getDependencyManagements.
public static List<PomDependencyMgt> getDependencyManagements(ModuleDescriptor md) {
List<PomDependencyMgt> result = new ArrayList<>();
if (md instanceof PomModuleDescriptor) {
result.addAll(((PomModuleDescriptor) md).getDependencyManagementMap().values());
} 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 {
String versionKey = DEPENDENCY_MANAGEMENT + EXTRA_INFO_DELIMITER + parts[1] + EXTRA_INFO_DELIMITER + parts[2] + EXTRA_INFO_DELIMITER + "version";
String scopeKey = DEPENDENCY_MANAGEMENT + EXTRA_INFO_DELIMITER + parts[1] + EXTRA_INFO_DELIMITER + parts[2] + EXTRA_INFO_DELIMITER + "scope";
String version = md.getExtraInfoContentByTagName(versionKey);
String scope = md.getExtraInfoContentByTagName(scopeKey);
List<ModuleId> exclusions = getDependencyMgtExclusions(md, parts[1], parts[2]);
result.add(new DefaultPomDependencyMgt(parts[1], parts[2], version, scope, exclusions));
}
}
}
}
return result;
}
use of org.apache.ivy.core.module.id.ModuleId in project ant-ivy by apache.
the class XmlReportWriter method output.
public void output(ConfigurationResolveReport report, String[] confs, OutputStream stream) {
OutputStreamWriter encodedOutStream;
try {
encodedOutStream = new OutputStreamWriter(stream, REPORT_ENCODING);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(REPORT_ENCODING + " is not known on your jvm", e);
}
PrintWriter out = new PrintWriter(new BufferedWriter(encodedOutStream));
ModuleRevisionId mrid = report.getModuleDescriptor().getModuleRevisionId();
// out.println("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
out.println("<?xml version=\"1.0\" encoding=\"" + REPORT_ENCODING + "\"?>");
out.println("<?xml-stylesheet type=\"text/xsl\" href=\"ivy-report.xsl\"?>");
out.println("<ivy-report version=\"1.0\">");
out.println("\t<info");
out.println("\t\torganisation=\"" + XMLHelper.escape(mrid.getOrganisation()) + "\"");
out.println("\t\tmodule=\"" + XMLHelper.escape(mrid.getName()) + "\"");
out.println("\t\trevision=\"" + XMLHelper.escape(mrid.getRevision()) + "\"");
if (mrid.getBranch() != null) {
out.println("\t\tbranch=\"" + XMLHelper.escape(mrid.getBranch()) + "\"");
}
out.println(extraToString(mrid.getExtraAttributes(), "\t\t"));
out.println("\t\tconf=\"" + XMLHelper.escape(report.getConfiguration()) + "\"");
out.println("\t\tconfs=\"" + XMLHelper.escape(joinArray(confs, ", ")) + "\"");
out.println("\t\tdate=\"" + DateUtil.format(report.getDate()) + "\"/>");
out.println("\t<dependencies>");
// create a list of ModuleRevisionIds indicating the position for each dependency
List<ModuleRevisionId> dependencies = new ArrayList<>(report.getModuleRevisionIds());
for (ModuleId mid : report.getModuleIds()) {
out.println("\t\t<module organisation=\"" + XMLHelper.escape(mid.getOrganisation()) + "\"" + " name=\"" + XMLHelper.escape(mid.getName()) + "\">");
for (IvyNode dep : report.getNodes(mid)) {
outputRevision(report, out, dependencies, dep);
}
out.println("\t\t</module>");
}
out.println("\t</dependencies>");
out.println("</ivy-report>");
out.flush();
}
use of org.apache.ivy.core.module.id.ModuleId 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.id.ModuleId 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