}
return false;
}
public ModuleDescriptor toFixedModuleDescriptor(IvySettings settings, List<ModuleId> midToKeep) {
DefaultModuleDescriptor fixedmd = new DefaultModuleDescriptor(md.getModuleRevisionId(),
md.getStatus(), new Date());
// copy configurations
List<String> resolvedConfs = Arrays.asList(getConfigurations());
for (String conf : resolvedConfs) {
fixedmd.addConfiguration(new Configuration(conf));
}
if (midToKeep != null && !midToKeep.isEmpty()) {
// add dependency we want to keep from the original module descriptor
DependencyDescriptor[] deps = md.getDependencies();
for (int i = 0; i < deps.length; i++) {
if (midToKeep.contains(deps[i].getDependencyId())) {
DefaultDependencyDescriptor dep = new DefaultDependencyDescriptor(fixedmd,
deps[i].getDependencyRevisionId(), true, false, false);
List<String> confs = Arrays.asList(deps[i].getModuleConfigurations());
if (confs.size() == 1 && confs.get(0).equals("*")) {
confs = resolvedConfs;
}
for (String conf : confs) {
String[] extendedConfs = getExtendingConfs(conf);
String[] depConfs = deps[i].getDependencyConfigurations(conf);
for (String extendedConf : extendedConfs) {
if (resolvedConfs.contains(extendedConf)) {
for (String depConf : depConfs) {
dep.addDependencyConfiguration(extendedConf, depConf);
}
}
}
}
fixedmd.addDependency(dep);
}
}
}
// add resolved dependencies
for (int i = 0; i < dependencies.size(); i++) {
IvyNode node = (IvyNode) dependencies.get(i);
if (midToKeep != null && midToKeep.contains(node.getModuleId())) {
continue;
}
String[] rootConfs = node.getRootModuleConfigurations();
for (int j = 0; j < rootConfs.length; j++) {
if (node.isEvicted(rootConfs[j])) {
continue;
}
if (node.getAllArtifacts().length == 0) {
// no artifact: it was probably useful transitively, hence it is useless here
break;
}
DefaultDependencyDescriptor dep = new DefaultDependencyDescriptor(fixedmd,
node.getResolvedId(), true, false, false);
String[] targetConfs = node.getConfigurations(rootConfs[j]);
for (int k = 0; k < targetConfs.length; k++) {
dep.addDependencyConfiguration(rootConfs[j], targetConfs[k]);
}
fixedmd.addDependency(dep);
}
}
return fixedmd;
}