use of org.apache.ivy.core.resolve.IvyNode in project ant-ivy by apache.
the class IvyArtifactReport method doExecute.
public void doExecute() throws BuildException {
prepareAndCheck();
if (tofile == null) {
throw new BuildException("no destination file name: please provide it through parameter 'tofile'");
}
pattern = getProperty(pattern, getSettings(), "ivy.retrieve.pattern");
try {
String[] confs = splitToArray(getConf());
ModuleDescriptor md = null;
if (getResolveId() == null) {
md = getResolvedDescriptor(getOrganisation(), getModule(), false);
} else {
md = getResolvedDescriptor(getResolveId());
}
IvyNode[] dependencies = getIvyInstance().getResolveEngine().getDependencies(md, ((ResolveOptions) new ResolveOptions().setLog(getLog())).setConfs(confs).setResolveId(getResolveId()).setValidate(doValidate(getSettings())), null);
Map<ArtifactDownloadReport, Set<String>> artifactsToCopy = getIvyInstance().getRetrieveEngine().determineArtifactsToCopy(ModuleRevisionId.newInstance(getOrganisation(), getModule(), getRevision()), pattern, ((RetrieveOptions) new RetrieveOptions().setLog(getLog())).setConfs(confs).setResolveId(getResolveId()));
Map<ModuleRevisionId, Set<ArtifactDownloadReport>> moduleRevToArtifactsMap = new HashMap<>();
for (ArtifactDownloadReport artifact : artifactsToCopy.keySet()) {
Set<ArtifactDownloadReport> moduleRevArtifacts = moduleRevToArtifactsMap.get(artifact.getArtifact().getModuleRevisionId());
if (moduleRevArtifacts == null) {
moduleRevArtifacts = new HashSet<>();
moduleRevToArtifactsMap.put(artifact.getArtifact().getModuleRevisionId(), moduleRevArtifacts);
}
moduleRevArtifacts.add(artifact);
}
generateXml(dependencies, moduleRevToArtifactsMap, artifactsToCopy);
} catch (ParseException e) {
log(e.getMessage(), Project.MSG_ERR);
throw new BuildException("syntax errors in ivy file: " + e, e);
} catch (IOException e) {
throw new BuildException("impossible to generate report: " + e, e);
}
}
use of org.apache.ivy.core.resolve.IvyNode in project ant-ivy by apache.
the class LatestCompatibleConflictManager method resolveConflicts.
@Override
public Collection<IvyNode> resolveConflicts(IvyNode parent, Collection<IvyNode> conflicts) {
if (conflicts.size() < 2) {
return conflicts;
}
VersionMatcher versionMatcher = getSettings().getVersionMatcher();
Iterator<IvyNode> iter = conflicts.iterator();
IvyNode node = iter.next();
ModuleRevisionId mrid = node.getResolvedId();
if (versionMatcher.isDynamic(mrid)) {
while (iter.hasNext()) {
IvyNode other = iter.next();
if (versionMatcher.isDynamic(other.getResolvedId()) || !versionMatcher.accept(mrid, other.getResolvedId()) && !handleIncompatibleConflict(parent, conflicts, node, other)) {
// or incompatibility found
return null;
}
}
// no incompatibility nor dynamic version found, let's return the latest static version
if (conflicts.size() == 2) {
// very common special case of only two modules in conflict,
// let's return the second one (static)
Iterator<IvyNode> it = conflicts.iterator();
it.next();
return Collections.singleton(it.next());
}
Collection<IvyNode> newConflicts = new LinkedHashSet<>(conflicts);
newConflicts.remove(node);
return super.resolveConflicts(parent, newConflicts);
} else {
// the first node is a static revision, let's see if all other versions match
while (iter.hasNext()) {
IvyNode other = iter.next();
if (!versionMatcher.accept(other.getResolvedId(), mrid) && !handleIncompatibleConflict(parent, conflicts, node, other)) {
// incompatibility found
return null;
}
}
// no incompatibility found, let's return this static version
return Collections.singleton(node);
}
}
use of org.apache.ivy.core.resolve.IvyNode in project ant-ivy by apache.
the class LatestCompatibleConflictManager method blackListIncompatibleCallerAndRestartResolveIfPossible.
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);
}
}
use of org.apache.ivy.core.resolve.IvyNode in project ant-ivy by apache.
the class LatestCompatibleConflictManager method handleAllBlacklistedRevisions.
@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());
}
}
use of org.apache.ivy.core.resolve.IvyNode in project ant-ivy by apache.
the class StrictConflictManager method resolveConflicts.
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);
}
Aggregations