/** * gives all the modules ids concerned by this report, from the most dependent to the least one * * @return a list of ModuleId */ public List getModuleIds() { List ret = new ArrayList(); List sortedDependencies = new ArrayList(dependencies); for (Iterator iter = sortedDependencies.iterator(); iter.hasNext(); ) { IvyNode dependency = (IvyNode) iter.next(); ModuleId mid = dependency.getResolvedId().getModuleId(); if (!ret.contains(mid)) { ret.add(mid); } } return ret; }
public void setDependencies(List dependencies, Filter artifactFilter) { this.dependencies = dependencies; // collect list of artifacts artifacts = new ArrayList(); for (Iterator iter = dependencies.iterator(); iter.hasNext(); ) { IvyNode dependency = (IvyNode) iter.next(); if (!dependency.isCompletelyEvicted() && !dependency.hasProblem()) { artifacts.addAll(Arrays.asList(dependency.getSelectedArtifacts(artifactFilter))); } // update the configurations reports with the dependencies // these reports will be completed later with download information, if any String[] dconfs = dependency.getRootModuleConfigurations(); for (int j = 0; j < dconfs.length; j++) { ConfigurationResolveReport configurationReport = getConfigurationReport(dconfs[j]); if (configurationReport != null) { configurationReport.addDependency(dependency); } } } }
public ResolvedModuleRevision parse( final ResolvedResource mdRef, DependencyDescriptor dd, ResolveData data) throws ParseException { DependencyDescriptor nsDd = dd; dd = toSystem(nsDd); ModuleRevisionId mrid = dd.getDependencyRevisionId(); ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance().getParser(mdRef.getResource()); if (parser == null) { Message.warn("no module descriptor parser available for " + mdRef.getResource()); return null; } Message.verbose("\t" + getName() + ": found md file for " + mrid); Message.verbose("\t\t=> " + mdRef); Message.debug("\tparser = " + parser); ModuleRevisionId resolvedMrid = mrid; // first check if this dependency has not yet been resolved if (getSettings().getVersionMatcher().isDynamic(mrid)) { resolvedMrid = ModuleRevisionId.newInstance(mrid, mdRef.getRevision()); IvyNode node = data.getNode(resolvedMrid); if (node != null && node.getModuleRevision() != null) { // this revision has already be resolved : return it if (node.getDescriptor() != null && node.getDescriptor().isDefault()) { Message.verbose( "\t" + getName() + ": found already resolved revision: " + resolvedMrid + ": but it's a default one, maybe we can find a better one"); } else { Message.verbose("\t" + getName() + ": revision already resolved: " + resolvedMrid); node.getModuleRevision().getReport().setSearched(true); return node.getModuleRevision(); } } } Artifact moduleArtifact = parser.getMetadataArtifact(resolvedMrid, mdRef.getResource()); return getRepositoryCacheManager() .cacheModuleDescriptor(this, mdRef, dd, moduleArtifact, downloader, getCacheOptions(data)); }
/** * When the resolver has many choices, this function helps choosing one * * @param rress the list of resolved resource which the resolver found to fit the requirement * @param rmdparser the parser of module descriptor * @param mrid the module being resolved * @param date the current date * @return the selected resource */ public ResolvedResource findResource( ResolvedResource[] rress, ResourceMDParser rmdparser, ModuleRevisionId mrid, Date date) { String name = getName(); VersionMatcher versionMatcher = getSettings().getVersionMatcher(); ResolvedResource found = null; List sorted = getLatestStrategy().sort(rress); List rejected = new ArrayList(); List foundBlacklisted = new ArrayList(); IvyContext context = IvyContext.getContext(); for (ListIterator iter = sorted.listIterator(sorted.size()); iter.hasPrevious(); ) { ResolvedResource rres = (ResolvedResource) iter.previous(); // we start by filtering based on information already available, // even though we don't even know if the resource actually exist. // But checking for existence is most of the time more costly than checking // name, blacklisting and first level version matching if (filterNames(new ArrayList(Collections.singleton(rres.getRevision()))).isEmpty()) { Message.debug("\t" + name + ": filtered by name: " + rres); continue; } ModuleRevisionId foundMrid = ModuleRevisionId.newInstance(mrid, rres.getRevision()); ResolveData data = context.getResolveData(); if (data != null && data.getReport() != null && data.isBlacklisted(data.getReport().getConfiguration(), foundMrid)) { Message.debug("\t" + name + ": blacklisted: " + rres); rejected.add(rres.getRevision() + " (blacklisted)"); foundBlacklisted.add(foundMrid); continue; } if (!versionMatcher.accept(mrid, foundMrid)) { Message.debug("\t" + name + ": rejected by version matcher: " + rres); rejected.add(rres.getRevision()); continue; } if (rres.getResource() != null && !rres.getResource().exists()) { Message.debug("\t" + name + ": unreachable: " + rres + "; res=" + rres.getResource()); rejected.add(rres.getRevision() + " (unreachable)"); continue; } if ((date != null && rres.getLastModified() > date.getTime())) { Message.verbose("\t" + name + ": too young: " + rres); rejected.add(rres.getRevision() + " (" + rres.getLastModified() + ")"); continue; } if (versionMatcher.needModuleDescriptor(mrid, foundMrid)) { ResolvedResource r = rmdparser.parse(rres.getResource(), rres.getRevision()); if (r == null) { Message.debug("\t" + name + ": impossible to get module descriptor resource: " + rres); rejected.add(rres.getRevision() + " (no or bad MD)"); continue; } ModuleDescriptor md = ((MDResolvedResource) r).getResolvedModuleRevision().getDescriptor(); if (md.isDefault()) { Message.debug( "\t" + name + ": default md rejected by version matcher" + "requiring module descriptor: " + rres); rejected.add(rres.getRevision() + " (MD)"); continue; } else if (!versionMatcher.accept(mrid, md)) { Message.debug("\t" + name + ": md rejected by version matcher: " + rres); rejected.add(rres.getRevision() + " (MD)"); continue; } else { found = r; } } else { found = rres; } if (found != null) { break; } } if (found == null && !rejected.isEmpty()) { logAttempt(rejected.toString()); } if (found == null && !foundBlacklisted.isEmpty()) { // all acceptable versions have been blacklisted, this means that an unsolvable conflict // has been found DependencyDescriptor dd = context.getDependencyDescriptor(); IvyNode parentNode = context.getResolveData().getNode(dd.getParentRevisionId()); ConflictManager cm = parentNode.getConflictManager(mrid.getModuleId()); cm.handleAllBlacklistedRevisions(dd, foundBlacklisted); } return found; }