Search in sources :

Example 11 with IvyNode

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

the class ConfigurationResolveReport method getModuleIds.

/**
 * gives all the modules ids concerned by this report, from the most dependent to the least one
 *
 * @return a list of ModuleId
 */
public List<ModuleId> getModuleIds() {
    if (modulesIds == null) {
        List<IvyNode> sortedDependencies = resolveEngine.getSortEngine().sortNodes(getDependencies(), SortOptions.SILENT);
        Collections.reverse(sortedDependencies);
        for (IvyNode dependency : sortedDependencies) {
            ModuleId mid = dependency.getResolvedId().getModuleId();
            Collection<IvyNode> deps = modulesIdsMap.get(mid);
            if (deps == null) {
                deps = new LinkedHashSet<>();
                modulesIdsMap.put(mid, deps);
            }
            deps.add(dependency);
        }
        modulesIds = new ArrayList<>(modulesIdsMap.keySet());
    }
    return Collections.unmodifiableList(modulesIds);
}
Also used : ModuleId(org.apache.ivy.core.module.id.ModuleId) IvyNode(org.apache.ivy.core.resolve.IvyNode)

Example 12 with IvyNode

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

the class ResolveReport method toFixedModuleDescriptor.

public ModuleDescriptor toFixedModuleDescriptor(IvySettings settings, List<ModuleId> midToKeep) {
    DefaultModuleDescriptor fixedmd = new DefaultModuleDescriptor(md.getModuleRevisionId(), md.getStatus(), new Date());
    // copy namespaces
    for (Map.Entry<String, String> ns : md.getExtraAttributesNamespaces().entrySet()) {
        fixedmd.addExtraAttributeNamespace(ns.getKey(), ns.getValue());
    }
    // copy info
    fixedmd.setDescription(md.getDescription());
    fixedmd.setHomePage(md.getHomePage());
    fixedmd.getExtraInfos().addAll(md.getExtraInfos());
    // copy configurations
    List<String> resolvedConfs = Arrays.asList(getConfigurations());
    for (String conf : resolvedConfs) {
        fixedmd.addConfiguration(new Configuration(conf));
    }
    // copy artifacts
    for (String conf : resolvedConfs) {
        for (Artifact a : md.getArtifacts(conf)) {
            fixedmd.addArtifact(conf, a);
        }
    }
    // add resolved dependencies
    for (IvyNode dep : dependencies) {
        ModuleRevisionId depMrid;
        boolean force;
        if (midToKeep != null && midToKeep.contains(dep.getModuleId())) {
            depMrid = dep.getId();
            force = false;
        } else {
            depMrid = dep.getResolvedId();
            force = true;
        }
        DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(fixedmd, depMrid, force, false, false);
        boolean evicted = true;
        for (String rootConf : dep.getRootModuleConfigurations()) {
            if (dep.isEvicted(rootConf)) {
                continue;
            }
            evicted = false;
            for (String targetConf : dep.getConfigurations(rootConf)) {
                dd.addDependencyConfiguration(rootConf, targetConf);
            }
        }
        if (!evicted) {
            fixedmd.addDependency(dd);
        }
    }
    return fixedmd;
}
Also used : Configuration(org.apache.ivy.core.module.descriptor.Configuration) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Date(java.util.Date) Artifact(org.apache.ivy.core.module.descriptor.Artifact) IvyNode(org.apache.ivy.core.resolve.IvyNode)

Example 13 with IvyNode

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

the class ResolveReport method setDependencies.

public void setDependencies(List<IvyNode> dependencies, Filter<Artifact> artifactFilter) {
    this.dependencies = dependencies;
    // collect list of artifacts
    artifacts = new ArrayList<>();
    for (IvyNode dependency : dependencies) {
        if (!dependency.isCompletelyEvicted() && !dependency.hasProblem()) {
            artifacts.addAll(Arrays.asList(dependency.getSelectedArtifacts(artifactFilter)));
        }
        // these reports will be completed later with download information, if any
        for (String dconf : dependency.getRootModuleConfigurations()) {
            ConfigurationResolveReport configurationReport = getConfigurationReport(dconf);
            if (configurationReport != null) {
                configurationReport.addDependency(dependency);
            }
        }
    }
}
Also used : IvyNode(org.apache.ivy.core.resolve.IvyNode)

Example 14 with IvyNode

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

the class LatestConflictManagerTest method testIvy388.

/**
 * Test case for IVY-388.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-388">IVY-388</a>
 */
@Test
public void testIvy388() throws Exception {
    ResolveReport report = ivy.resolve(LatestConflictManagerTest.class.getResource("ivy-388.xml"), getResolveOptions());
    List<IvyNode> deps = report.getDependencies();
    Iterator<IvyNode> dependencies = deps.iterator();
    String[] confs = report.getConfigurations();
    while (dependencies.hasNext()) {
        IvyNode node = dependencies.next();
        for (String conf : confs) {
            if (!node.isEvicted(conf)) {
                boolean flag1 = report.getConfigurationReport(conf).getDependency(node.getResolvedId()) != null;
                boolean flag2 = report.getConfigurationReport(conf).getModuleRevisionIds().contains(node.getResolvedId());
                assertEquals("Inconsistent data for node " + node + " in conf " + conf, flag1, flag2);
            }
        }
    }
}
Also used : ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) IvyNode(org.apache.ivy.core.resolve.IvyNode) Test(org.junit.Test)

Example 15 with IvyNode

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

the class ResolveReport method getModuleIds.

/**
 * gives all the modules ids concerned by this report, from the most dependent to the least one
 *
 * @return a list of ModuleId
 */
public List<ModuleId> getModuleIds() {
    List<ModuleId> ret = new ArrayList<>();
    List<IvyNode> sortedDependencies = new ArrayList<>(dependencies);
    for (IvyNode dependency : sortedDependencies) {
        ModuleId mid = dependency.getResolvedId().getModuleId();
        if (!ret.contains(mid)) {
            ret.add(mid);
        }
    }
    return ret;
}
Also used : ModuleId(org.apache.ivy.core.module.id.ModuleId) ArrayList(java.util.ArrayList) IvyNode(org.apache.ivy.core.resolve.IvyNode)

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