Search in sources :

Example 26 with IvyNode

use of org.apache.ivy.core.resolve.IvyNode 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();
}
Also used : ModuleId(org.apache.ivy.core.module.id.ModuleId) ArrayList(java.util.ArrayList) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) OutputStreamWriter(java.io.OutputStreamWriter) IvyNode(org.apache.ivy.core.resolve.IvyNode) PrintWriter(java.io.PrintWriter) BufferedWriter(java.io.BufferedWriter)

Aggregations

IvyNode (org.apache.ivy.core.resolve.IvyNode)26 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)12 ArrayList (java.util.ArrayList)7 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)5 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)4 ModuleId (org.apache.ivy.core.module.id.ModuleId)4 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)4 EvictionData (org.apache.ivy.core.resolve.IvyNodeEviction.EvictionData)4 HashSet (java.util.HashSet)3 ResolveReport (org.apache.ivy.core.report.ResolveReport)3 IvyNodeBlacklist (org.apache.ivy.core.resolve.IvyNodeBlacklist)3 VersionMatcher (org.apache.ivy.plugins.version.VersionMatcher)3 IOException (java.io.IOException)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 LinkedHashSet (java.util.LinkedHashSet)2 Artifact (org.apache.ivy.core.module.descriptor.Artifact)2 Configuration (org.apache.ivy.core.module.descriptor.Configuration)2 DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)2