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