Search in sources :

Example 6 with EvictionData

use of org.apache.ivy.core.resolve.IvyNodeEviction.EvictionData in project ant-ivy by apache.

the class IvyNode method markEvicted.

public void markEvicted(String rootModuleConf, IvyNode node, ConflictManager conflictManager, Collection<IvyNode> resolved) {
    EvictionData evictionData = new EvictionData(rootModuleConf, node, conflictManager, resolved);
    markEvicted(evictionData);
}
Also used : EvictionData(org.apache.ivy.core.resolve.IvyNodeEviction.EvictionData)

Example 7 with EvictionData

use of org.apache.ivy.core.resolve.IvyNodeEviction.EvictionData in project ant-ivy by apache.

the class LogReportOutputter method output.

public void output(ResolveReport report, ResolutionCacheManager cacheMgr, ResolveOptions options) throws IOException {
    IvySettings settings = IvyContext.getContext().getSettings();
    if (settings.logModulesInUse() && ResolveOptions.LOG_DEFAULT.equals(options.getLog())) {
        Message.info("\t:: modules in use:");
        List<IvyNode> dependencies = new ArrayList<>(report.getDependencies());
        Collections.sort(dependencies);
        if (dependencies.size() > 0) {
            String[] confs = report.getConfigurations();
            for (IvyNode node : dependencies) {
                if (node.isCompletelyEvicted() || node.hasProblem()) {
                    continue;
                }
                List<String> nodeConfs = new ArrayList<>(confs.length);
                for (String conf : confs) {
                    if (report.getConfigurationReport(conf).getModuleRevisionIds().contains(node.getResolvedId())) {
                        nodeConfs.add(conf);
                    }
                }
                Message.info("\t" + node + " from " + node.getModuleRevision().getResolver().getName() + " in " + nodeConfs);
            }
        }
    }
    IvyNode[] evicted = report.getEvictedNodes();
    if (evicted.length > 0 && ResolveOptions.LOG_DEFAULT.equals(options.getLog())) {
        Message.info("\t:: evicted modules:");
        for (IvyNode evictedNode : evicted) {
            Collection<String> allEvictingNodes = evictedNode.getAllEvictingNodesDetails();
            if (allEvictingNodes == null) {
                Message.info("\t" + evictedNode + " transitively in " + Arrays.asList(evictedNode.getEvictedConfs()));
            } else if (allEvictingNodes.isEmpty()) {
                Message.info("\t" + evictedNode + " by [] (" + evictedNode.getAllEvictingConflictManagers() + ") in " + Arrays.asList(evictedNode.getEvictedConfs()));
            } else {
                Message.info("\t" + evictedNode + " by " + allEvictingNodes + " in " + Arrays.asList(evictedNode.getEvictedConfs()));
            }
            for (String conf : evictedNode.getEvictedConfs()) {
                EvictionData evictedData = evictedNode.getEvictedData(conf);
                if (evictedData.getParent() != null) {
                    Message.verbose("\t  in " + evictedData.getParent() + " with " + evictedData.getConflictManager());
                }
            }
        }
    }
    if (ResolveOptions.LOG_DEFAULT.equals(options.getLog())) {
        // CheckStyle:MagicNumber| OFF
        char[] sep = new char[69];
        Arrays.fill(sep, '-');
        Message.rawinfo("\t" + new String(sep));
        StringBuilder line = new StringBuilder("\t");
        append(line, "", 18);
        append(line, "modules", 31);
        line.append("|");
        append(line, "artifacts", 15);
        line.append("|");
        Message.rawinfo(line.toString());
        line = new StringBuilder("\t");
        append(line, "conf", 18);
        append(line, "number", 7);
        append(line, "search", 7);
        append(line, "dwnlded", 7);
        append(line, "evicted", 7);
        line.append("|");
        append(line, "number", 7);
        append(line, "dwnlded", 7);
        // CheckStyle:MagicNumber| ON
        line.append("|");
        Message.rawinfo(line.toString());
        Message.rawinfo("\t" + new String(sep));
        for (String conf : report.getConfigurations()) {
            output(report.getConfigurationReport(conf));
        }
        Message.rawinfo("\t" + new String(sep));
    }
    IvyNode[] unresolved = report.getUnresolvedDependencies();
    if (unresolved.length > 0) {
        Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::");
        Message.warn("\t::          UNRESOLVED DEPENDENCIES         ::");
        Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::");
    }
    for (IvyNode anUnresolved : unresolved) {
        Message.warn("\t:: " + anUnresolved + ": " + anUnresolved.getProblemMessage());
    }
    if (unresolved.length > 0) {
        Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::\n");
    }
    ArtifactDownloadReport[] errors = report.getFailedArtifactsReports();
    if (errors.length > 0) {
        Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::");
        Message.warn("\t::              FAILED DOWNLOADS            ::");
        Message.warn("\t:: ^ see resolution messages for details  ^ ::");
        Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::");
    }
    for (ArtifactDownloadReport error : errors) {
        Message.warn("\t:: " + error.getArtifact());
    }
    if (errors.length > 0) {
        Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::\n");
    }
}
Also used : ArrayList(java.util.ArrayList) IvySettings(org.apache.ivy.core.settings.IvySettings) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) EvictionData(org.apache.ivy.core.resolve.IvyNodeEviction.EvictionData) IvyNode(org.apache.ivy.core.resolve.IvyNode)

Example 8 with EvictionData

use of org.apache.ivy.core.resolve.IvyNodeEviction.EvictionData in project ant-ivy by apache.

the class XmlReportWriter method outputRevision.

private void outputRevision(ConfigurationResolveReport report, PrintWriter out, List<ModuleRevisionId> dependencies, IvyNode dep) {
    Map<String, String> extraAttributes;
    ModuleDescriptor md = null;
    if (dep.getModuleRevision() != null) {
        md = dep.getModuleRevision().getDescriptor();
    }
    StringBuilder details = new StringBuilder();
    if (dep.isLoaded()) {
        details.append(" status=\"");
        details.append(XMLHelper.escape(dep.getDescriptor().getStatus()));
        details.append("\" pubdate=\"");
        details.append(DateUtil.format(new Date(dep.getPublication())));
        details.append("\" resolver=\"");
        details.append(XMLHelper.escape(dep.getModuleRevision().getResolver().getName()));
        details.append("\" artresolver=\"");
        details.append(XMLHelper.escape(dep.getModuleRevision().getArtifactResolver().getName()));
        details.append("\"");
    }
    if (dep.isEvicted(report.getConfiguration())) {
        EvictionData ed = dep.getEvictedData(report.getConfiguration());
        if (ed.getConflictManager() != null) {
            details.append(" evicted=\"").append(XMLHelper.escape(ed.getConflictManager().toString())).append("\"");
        } else {
            details.append(" evicted=\"transitive\"");
        }
        details.append(" evicted-reason=\"").append(XMLHelper.escape(ed.getDetail() == null ? "" : ed.getDetail())).append("\"");
    }
    if (dep.hasProblem()) {
        details.append(" error=\"").append(XMLHelper.escape(dep.getProblem().getMessage())).append("\"");
    }
    if (md != null && md.getHomePage() != null) {
        details.append(" homepage=\"").append(XMLHelper.escape(md.getHomePage())).append("\"");
    }
    extraAttributes = (md != null) ? md.getExtraAttributes() : dep.getResolvedId().getExtraAttributes();
    details.append(extraToString(extraAttributes, SEPARATOR));
    out.println(String.format("\t\t\t<revision name=\"%s\"%s%s downloaded=\"%s\" searched=\"%s\"%s conf=\"%s\" position=\"%d\">", XMLHelper.escape(dep.getResolvedId().getRevision()), (dep.getResolvedId().getBranch() == null) ? "" : " branch=\"" + XMLHelper.escape(dep.getResolvedId().getBranch()) + "\"", details, dep.isDownloaded(), dep.isSearched(), (dep.getDescriptor() == null) ? "" : " default=\"" + dep.getDescriptor().isDefault() + "\"", XMLHelper.escape(joinArray(dep.getConfigurations(report.getConfiguration()), ", ")), dependencies.indexOf(dep.getResolvedId())));
    if (md != null) {
        License[] licenses = md.getLicenses();
        for (License license : licenses) {
            out.println(String.format("\t\t\t\t<license name=\"%s\"%s/>", XMLHelper.escape(license.getName()), license.getUrl() == null ? "" : " url=\"" + XMLHelper.escape(license.getUrl()) + "\""));
        }
    }
    outputMetadataArtifact(out, dep);
    outputEvictionInformation(report, out, dep);
    outputCallers(report, out, dep);
    outputArtifacts(report, out, dep);
    out.println("\t\t\t</revision>");
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) EvictionData(org.apache.ivy.core.resolve.IvyNodeEviction.EvictionData) License(org.apache.ivy.core.module.descriptor.License) Date(java.util.Date)

Aggregations

EvictionData (org.apache.ivy.core.resolve.IvyNodeEviction.EvictionData)8 IvyNode (org.apache.ivy.core.resolve.IvyNode)4 HashSet (java.util.HashSet)2 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 LinkedHashSet (java.util.LinkedHashSet)1 Stack (java.util.Stack)1 DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)1 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)1 DependencyDescriptor (org.apache.ivy.core.module.descriptor.DependencyDescriptor)1 License (org.apache.ivy.core.module.descriptor.License)1 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)1 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)1 IvyNodeBlacklist (org.apache.ivy.core.resolve.IvyNodeBlacklist)1 RestartResolveProcess (org.apache.ivy.core.resolve.RestartResolveProcess)1 IvySettings (org.apache.ivy.core.settings.IvySettings)1 ConflictManager (org.apache.ivy.plugins.conflict.ConflictManager)1 VersionMatcher (org.apache.ivy.plugins.version.VersionMatcher)1