org.apache.ivy.core.resolve.IvyNode Java Examples
The following examples show how to use
org.apache.ivy.core.resolve.IvyNode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LatestConflictManagerTest.java From ant-ivy with Apache License 2.0 | 6 votes |
/** * 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); } } } }
Example #2
Source File: ConfigurationResolveReport.java From ant-ivy with Apache License 2.0 | 6 votes |
/** * 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); }
Example #3
Source File: ResolveReport.java From ant-ivy with Apache License 2.0 | 6 votes |
public List<String> getAllProblemMessages() { List<String> ret = new ArrayList<>(problemMessages); for (ConfigurationResolveReport r : confReports.values()) { for (IvyNode unresolved : r.getUnresolvedDependencies()) { String errMsg = unresolved.getProblemMessage(); if (errMsg.isEmpty()) { ret.add("unresolved dependency: " + unresolved.getId()); } else { ret.add("unresolved dependency: " + unresolved.getId() + ": " + errMsg); } } for (ArtifactDownloadReport adr : r.getFailedArtifactsReports()) { ret.add("download failed: " + adr.getArtifact()); } } return ret; }
Example #4
Source File: ResolveReport.java From ant-ivy with Apache License 2.0 | 6 votes |
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))); } // update the configurations reports with the dependencies // 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); } } } }
Example #5
Source File: IvyDependencyTree.java From ant-ivy with Apache License 2.0 | 6 votes |
public void doExecute() throws BuildException { prepareAndCheck(); ResolveReport report = getResolvedReport(); if (report == null) { throw new BuildException("No resolution report was available to run the post-resolve task. Make sure resolve was done before this task"); } log("Dependency tree for " + report.getResolveId()); ModuleRevisionId mrid = report.getModuleDescriptor().getModuleRevisionId(); // make dependency tree easier to fetch information for (IvyNode dependency : report.getDependencies()) { populateDependencyTree(dependency); } final List<IvyNode> dependencyList = dependencies.get(mrid); if (dependencyList != null) { printDependencies(mrid, dependencyList, 0, new HashSet<ModuleRevisionId>()); } }
Example #6
Source File: IvyDependencyUpdateChecker.java From ant-ivy with Apache License 2.0 | 6 votes |
private void displayNewDependencyOnLatest(ResolveReport originalReport, ResolveReport latestReport) { List<ModuleRevisionId> listOfNewDependencyOnLatest = new ArrayList<>(); for (IvyNode latest : latestReport.getDependencies()) { boolean dependencyFound = false; for (IvyNode originalDependency : originalReport.getDependencies()) { if (originalDependency.getModuleId().equals(latest.getModuleId())) { dependencyFound = true; } } if (!dependencyFound) { listOfNewDependencyOnLatest.add(latest.getId()); } } if (listOfNewDependencyOnLatest.size() > 0) { log("List of new dependency on latest resolve :"); for (ModuleRevisionId moduleRevisionId : listOfNewDependencyOnLatest) { log("\t" + moduleRevisionId.toString()); } } }
Example #7
Source File: IvyDependencyUpdateChecker.java From ant-ivy with Apache License 2.0 | 6 votes |
private void displayMissingDependencyOnLatest(ResolveReport originalReport, ResolveReport latestReport) { List<ModuleRevisionId> listOfMissingDependencyOnLatest = new ArrayList<>(); for (IvyNode originalDependency : originalReport.getDependencies()) { boolean dependencyFound = false; for (IvyNode latest : latestReport.getDependencies()) { if (originalDependency.getModuleId().equals(latest.getModuleId())) { dependencyFound = true; } } if (!dependencyFound) { listOfMissingDependencyOnLatest.add(originalDependency.getId()); } } if (listOfMissingDependencyOnLatest.size() > 0) { log("List of missing dependency on latest resolve :"); for (ModuleRevisionId moduleRevisionId : listOfMissingDependencyOnLatest) { log("\t" + moduleRevisionId.toString()); } } }
Example #8
Source File: RegexpConflictManager.java From ant-ivy with Apache License 2.0 | 6 votes |
public Collection<IvyNode> resolveConflicts(IvyNode parent, Collection<IvyNode> conflicts) { IvyNode lastNode = null; for (IvyNode node : conflicts) { if (lastNode != null && !matchEquals(node, lastNode)) { String msg = lastNode + ":" + getMatch(lastNode) + " (needed by " + Arrays.asList(lastNode.getAllRealCallers()) + ") conflicts with " + node + ":" + getMatch(node) + " (needed by " + Arrays.asList(node.getAllRealCallers()) + ")"; throw new StrictConflictException(msg); } if (lastNode == null || nodeIsGreater(node, lastNode)) { lastNode = node; } } return Collections.singleton(lastNode); }
Example #9
Source File: LatestCompatibleConflictManager.java From ant-ivy with Apache License 2.0 | 6 votes |
private boolean handleIncompatibleCaller(Stack<IvyNode> callerStack, IvyNode node, IvyNode callerNode, IvyNode conflictParent, IvyNode selectedNode, IvyNode evictedNode, Collection<IvyNodeBlacklist> blacklisted, VersionMatcher versionMatcher) { if (callerStack.subList(0, callerStack.size() - 1).contains(node)) { // circular dependency found and handled: the current top of the stack (node) // was already contained in the rest of the stack, the circle is closed, nothing // else to do return true; } else { callerStack.push(callerNode); Collection<IvyNodeBlacklist> sub = blackListIncompatibleCaller(versionMatcher, conflictParent, selectedNode, evictedNode, callerStack); callerStack.pop(); if (sub == null) { // propagate the fact that a path with nonblacklistable caller has been found return false; } else { blacklisted.addAll(sub); return true; } } }
Example #10
Source File: LatestCompatibleConflictManager.java From ant-ivy with Apache License 2.0 | 6 votes |
@Override public void handleAllBlacklistedRevisions(DependencyDescriptor dd, Collection<ModuleRevisionId> foundBlacklisted) { ResolveData resolveData = IvyContext.getContext().getResolveData(); Collection<IvyNode> blacklisted = new HashSet<>(); for (ModuleRevisionId mrid : foundBlacklisted) { blacklisted.add(resolveData.getNode(mrid)); } for (IvyNode node : blacklisted) { IvyNodeBlacklist bdata = node.getBlacklistData(resolveData.getReport() .getConfiguration()); handleUnsolvableConflict(bdata.getConflictParent(), Arrays.asList(bdata.getEvictedNode(), bdata.getSelectedNode()), bdata.getEvictedNode(), bdata.getSelectedNode()); } }
Example #11
Source File: IvyInternalDepResolver.java From jeka with Apache License 2.0 | 6 votes |
private List<JkModuleDepProblem> moduleProblems(List<IvyNode> ivyNodes) { final List<JkModuleDepProblem> result = new LinkedList<>(); for (final IvyNode ivyNode : ivyNodes) { if (ivyNode.isCompletelyBlacklisted() || ivyNode.isCompletelyEvicted()) { continue; } if (ivyNode.hasProblem()) { final JkModuleId jkModuleId = JkModuleId.of(ivyNode.getModuleId().getOrganisation(), ivyNode.getModuleId().getName()); final JkModuleDepProblem problem = JkModuleDepProblem.of(jkModuleId, ivyNode.getId().getRevision(), ivyNode.getProblemMessage()); result.add(problem); } } return result; }
Example #12
Source File: StrictConflictManager.java From ant-ivy with Apache License 2.0 | 6 votes |
public Collection<IvyNode> resolveConflicts(IvyNode parent, Collection<IvyNode> conflicts) { VersionMatcher versionMatcher = getSettings().getVersionMatcher(); IvyNode lastNode = null; for (IvyNode node : conflicts) { if (versionMatcher.isDynamic(node.getResolvedId())) { // dynamic revision, not enough information to resolve conflict return null; } if (lastNode != null && !lastNode.equals(node)) { throw new StrictConflictException(lastNode, node); } lastNode = node; } return Collections.singleton(lastNode); }
Example #13
Source File: ConfigurationResolveReport.java From ant-ivy with Apache License 2.0 | 5 votes |
public void addDependency(IvyNode node, DownloadReport report) { dependencies.put(node.getId(), node); dependencies.put(node.getResolvedId(), node); List<ArtifactDownloadReport> adrs = new ArrayList<>(); for (Artifact artifact : node.getArtifacts(conf)) { ArtifactDownloadReport artifactReport = report.getArtifactReport(artifact); if (artifactReport != null) { adrs.add(artifactReport); } else { Message.debug("no report found for " + artifact); } } dependencyReports.put(node, adrs); }
Example #14
Source File: IvyArtifactReport.java From ant-ivy with Apache License 2.0 | 5 votes |
private void startModule(TransformerHandler saxHandler, IvyNode dependency) throws SAXException { AttributesImpl moduleAttrs = new AttributesImpl(); moduleAttrs.addAttribute(null, "organisation", "organisation", "CDATA", dependency .getModuleId().getOrganisation()); moduleAttrs.addAttribute(null, "name", "name", "CDATA", dependency.getModuleId().getName()); ResolvedModuleRevision moduleRevision = dependency.getModuleRevision(); moduleAttrs.addAttribute(null, "rev", "rev", "CDATA", moduleRevision.getId().getRevision()); moduleAttrs.addAttribute(null, "status", "status", "CDATA", moduleRevision.getDescriptor() .getStatus()); saxHandler.startElement(null, "module", "module", moduleAttrs); }
Example #15
Source File: ConfigurationResolveReport.java From ant-ivy with Apache License 2.0 | 5 votes |
public IvyNode[] getUnresolvedDependencies() { List<IvyNode> unresolved = new ArrayList<>(); for (IvyNode node : getDependencies()) { if (node.hasProblem()) { unresolved.add(node); } } return unresolved.toArray(new IvyNode[unresolved.size()]); }
Example #16
Source File: ConfigurationResolveReport.java From ant-ivy with Apache License 2.0 | 5 votes |
public IvyNode[] getEvictedNodes() { List<IvyNode> evicted = new ArrayList<>(); for (IvyNode node : getDependencies()) { if (node.isEvicted(conf)) { evicted.add(node); } } return evicted.toArray(new IvyNode[evicted.size()]); }
Example #17
Source File: ConfigurationResolveReport.java From ant-ivy with Apache License 2.0 | 5 votes |
private Set<ModuleRevisionId> getEvictedMrids() { Set<ModuleRevisionId> evicted = new LinkedHashSet<>(); for (IvyNode node : getEvictedNodes()) { evicted.add(node.getId()); } return evicted; }
Example #18
Source File: IvyInternalDepResolver.java From jeka with Apache License 2.0 | 5 votes |
private static JkResolveResult getResolveConf(List<IvyNode> nodes, JkVersionedModule rootVersionedModule, JkResolveResult.JkErrorReport errorReport, IvyArtifactContainer ivyArtifactContainer) { // Compute dependency tree final JkDependencyNode tree = createTree(nodes, rootVersionedModule, ivyArtifactContainer); return JkResolveResult.of(tree, errorReport); }
Example #19
Source File: ConfigurationResolveReport.java From ant-ivy with Apache License 2.0 | 5 votes |
public IvyNode[] getDownloadedNodes() { List<IvyNode> downloaded = new ArrayList<>(); for (IvyNode node : getDependencies()) { if (node.isDownloaded() && node.getRealNode() == node) { downloaded.add(node); } } return downloaded.toArray(new IvyNode[downloaded.size()]); }
Example #20
Source File: ResolveReport.java From ant-ivy with Apache License 2.0 | 5 votes |
public IvyNode[] getEvictedNodes() { Collection<IvyNode> all = new LinkedHashSet<>(); for (ConfigurationResolveReport report : confReports.values()) { all.addAll(Arrays.asList(report.getEvictedNodes())); } return all.toArray(new IvyNode[all.size()]); }
Example #21
Source File: ConfigurationResolveReport.java From ant-ivy with Apache License 2.0 | 5 votes |
public IvyNode[] getSearchedNodes() { List<IvyNode> downloaded = new ArrayList<>(); for (IvyNode node : getDependencies()) { if (node.isSearched() && node.getRealNode() == node) { downloaded.add(node); } } return downloaded.toArray(new IvyNode[downloaded.size()]); }
Example #22
Source File: XmlReportWriter.java From ant-ivy with Apache License 2.0 | 5 votes |
private void outputEvictionInformation(ConfigurationResolveReport report, PrintWriter out, IvyNode dep) { if (dep.isEvicted(report.getConfiguration())) { EvictionData ed = dep.getEvictedData(report.getConfiguration()); Collection<IvyNode> selected = ed.getSelected(); if (selected != null) { for (IvyNode sel : selected) { out.println("\t\t\t\t<evicted-by rev=\"" + XMLHelper.escape(sel.getResolvedId().getRevision()) + "\"/>"); } } } }
Example #23
Source File: XmlReportWriter.java From ant-ivy with Apache License 2.0 | 5 votes |
private void outputMetadataArtifact(PrintWriter out, IvyNode dep) { if (dep.getModuleRevision() != null) { MetadataArtifactDownloadReport madr = dep.getModuleRevision().getReport(); out.print("\t\t\t\t<metadata-artifact"); out.print(" status=\"" + XMLHelper.escape(madr.getDownloadStatus().toString()) + "\""); out.print(" details=\"" + XMLHelper.escape(madr.getDownloadDetails()) + "\""); out.print(" size=\"" + madr.getSize() + "\""); out.print(" time=\"" + madr.getDownloadTimeMillis() + "\""); if (madr.getLocalFile() != null) { out.print(" location=\"" + XMLHelper.escape(madr.getLocalFile().getAbsolutePath()) + "\""); } out.print(" searched=\"" + madr.isSearched() + "\""); if (madr.getOriginalLocalFile() != null) { out.print(" original-local-location=\"" + XMLHelper.escape(madr.getOriginalLocalFile().getAbsolutePath()) + "\""); } ArtifactOrigin origin = madr.getArtifactOrigin(); if (origin != null) { out.print(" origin-is-local=\"" + String.valueOf(origin.isLocal()) + "\""); out.print(" origin-location=\"" + XMLHelper.escape(origin.getLocation()) + "\""); } out.println("/>"); } }
Example #24
Source File: XmlReportWriter.java From ant-ivy with Apache License 2.0 | 5 votes |
private void outputCallers(ConfigurationResolveReport report, PrintWriter out, IvyNode dep) { for (Caller caller : dep.getCallers(report.getConfiguration())) { final DependencyDescriptor dependencyDescriptor = caller.getDependencyDescriptor(); out.println(String.format("\t\t\t\t<caller organisation=\"%s\" name=\"%s\" conf=\"%s\" rev=\"%s\" rev-constraint-default=\"%s\" rev-constraint-dynamic=\"%s\" callerrev=\"%s\"%s/>", XMLHelper.escape(caller.getModuleRevisionId().getOrganisation()), XMLHelper.escape(caller.getModuleRevisionId().getName()), XMLHelper.escape(joinArray(caller.getCallerConfigurations(), ", ")), XMLHelper.escape(caller.getAskedDependencyId().getRevision()), XMLHelper.escape(dependencyDescriptor.getDependencyRevisionId().getRevision()), XMLHelper.escape(dependencyDescriptor.getDynamicConstraintDependencyRevisionId().getRevision()), XMLHelper.escape(caller.getModuleRevisionId().getRevision()), extraToString(dependencyDescriptor.getQualifiedExtraAttributes(), SEPARATOR))); } }
Example #25
Source File: XmlReportWriter.java From ant-ivy with Apache License 2.0 | 5 votes |
private void outputArtifacts(ConfigurationResolveReport report, PrintWriter out, IvyNode dep) { out.println("\t\t\t\t<artifacts>"); for (ArtifactDownloadReport adr : report.getDownloadReports(dep.getResolvedId())) { out.print("\t\t\t\t\t<artifact name=\"" + XMLHelper.escape(adr.getName()) + "\" type=\"" + XMLHelper.escape(adr.getType()) + "\" ext=\"" + XMLHelper.escape(adr.getExt()) + "\""); out.print(extraToString(adr.getArtifact().getQualifiedExtraAttributes(), SEPARATOR)); out.print(" status=\"" + XMLHelper.escape(adr.getDownloadStatus().toString()) + "\""); out.print(" details=\"" + XMLHelper.escape(adr.getDownloadDetails()) + "\""); out.print(" size=\"" + adr.getSize() + "\""); out.print(" time=\"" + adr.getDownloadTimeMillis() + "\""); if (adr.getLocalFile() != null) { out.print(" location=\"" + XMLHelper.escape(adr.getLocalFile().getAbsolutePath()) + "\""); } if (adr.getUnpackedLocalFile() != null) { out.print(" unpackedFile=\"" + XMLHelper.escape(adr.getUnpackedLocalFile().getAbsolutePath()) + "\""); } ArtifactOrigin origin = adr.getArtifactOrigin(); if (origin != null) { out.println(">"); out.println("\t\t\t\t\t\t<origin-location is-local=\"" + String.valueOf(origin.isLocal()) + "\"" + " location=\"" + XMLHelper.escape(origin.getLocation()) + "\"/>"); out.println("\t\t\t\t\t</artifact>"); } else { out.println("/>"); } } out.println("\t\t\t\t</artifacts>"); }
Example #26
Source File: LatestConflictManager.java From ant-ivy with Apache License 2.0 | 5 votes |
protected ArtifactInfo[] toArtifactInfo(Collection<IvyNode> conflicts) { List<ArtifactInfo> artifacts = new ArrayList<>(conflicts.size()); for (IvyNode node : conflicts) { artifacts.add(new IvyNodeArtifactInfo(node)); } return artifacts.toArray(new ArtifactInfo[artifacts.size()]); }
Example #27
Source File: FixedConflictManager.java From ant-ivy with Apache License 2.0 | 5 votes |
public Collection<IvyNode> resolveConflicts(IvyNode parent, Collection<IvyNode> conflicts) { Collection<IvyNode> resolved = new ArrayList<>(conflicts.size()); for (IvyNode node : conflicts) { String revision = node.getResolvedId().getRevision(); if (revisions.contains(revision)) { resolved.add(node); } } return resolved; }
Example #28
Source File: RegexpConflictManager.java From ant-ivy with Apache License 2.0 | 5 votes |
private String getMatch(IvyNode node) { String revision = node.getId().getRevision(); Matcher matcher = pattern.matcher(revision); if (matcher.matches()) { String match = matcher.group(1); if (match != null) { return match; } warnOrThrow("First group of pattern: '" + pattern + "' does not match: " + revision + " " + node); } else { warnOrThrow("Pattern: '" + pattern + "' does not match: " + revision + " " + node); } return revision; }
Example #29
Source File: LatestCompatibleConflictManager.java From ant-ivy with Apache License 2.0 | 5 votes |
private void blackListIncompatibleCallerAndRestartResolveIfPossible(IvySettings settings, IvyNode parent, IvyNode selected, IvyNode evicted) { Stack<IvyNode> callerStack = new Stack<>(); callerStack.push(evicted); Collection<IvyNodeBlacklist> toBlacklist = blackListIncompatibleCaller( settings.getVersionMatcher(), parent, selected, evicted, callerStack); if (toBlacklist != null) { final StringBuilder blacklisted = new StringBuilder(); for (IvyNodeBlacklist blacklist : toBlacklist) { if (blacklisted.length() > 0) { blacklisted.append(" "); } IvyNode blacklistedNode = blacklist.getBlacklistedNode(); blacklistedNode.blacklist(blacklist); blacklisted.append(blacklistedNode); } String rootModuleConf = parent.getData().getReport().getConfiguration(); evicted.markEvicted(new EvictionData(rootModuleConf, parent, this, Collections .singleton(selected), "with blacklisting of " + blacklisted)); if (settings.debugConflictResolution()) { Message.debug("evicting " + evicted + " by " + evicted.getEvictedData(rootModuleConf)); } throw new RestartResolveProcess("trying to handle incompatibilities between " + selected + " and " + evicted); } }
Example #30
Source File: LatestCompatibleConflictManager.java From ant-ivy with Apache License 2.0 | 5 votes |
/** * Tries to blacklist exactly one version for all callers paths. * * @param versionMatcher * the version matcher to use to interpret versions * @param conflictParent * the node in which the conflict is occurring * @param selectedNode * the node in favor of which the conflict is resolved * @param evictedNode * the node which will be evicted if we are able to blacklist all paths * @param callerStack * ditto * @return the collection of blacklisting to do, null if a blacklist is not possible in at least * one caller path */ private Collection<IvyNodeBlacklist> blackListIncompatibleCaller(VersionMatcher versionMatcher, IvyNode conflictParent, IvyNode selectedNode, IvyNode evictedNode, Stack<IvyNode> callerStack) { Collection<IvyNodeBlacklist> blacklisted = new ArrayList<>(); IvyNode node = callerStack.peek(); String rootModuleConf = conflictParent.getData().getReport().getConfiguration(); for (Caller caller : node.getCallers(rootModuleConf)) { IvyNode callerNode = node.findNode(caller.getModuleRevisionId()); if (callerNode.isBlacklisted(rootModuleConf)) { continue; } if (versionMatcher.isDynamic(caller.getAskedDependencyId())) { blacklisted.add(new IvyNodeBlacklist(conflictParent, selectedNode, evictedNode, node, rootModuleConf)); if (node.isEvicted(rootModuleConf) && !handleIncompatibleCaller(callerStack, node, callerNode, conflictParent, selectedNode, evictedNode, blacklisted, versionMatcher)) { return null; } } else if (!handleIncompatibleCaller(callerStack, node, callerNode, conflictParent, selectedNode, evictedNode, blacklisted, versionMatcher)) { return null; } } if (blacklisted.isEmpty() && !callerStack.subList(0, callerStack.size() - 1).contains(node)) { return null; } return blacklisted; }