use of org.apache.ivy.core.resolve.IvyNode in project ant-ivy by apache.
the class IvyDependencyTree method doExecute.
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>());
}
}
use of org.apache.ivy.core.resolve.IvyNode in project ant-ivy by apache.
the class IvyDependencyUpdateChecker method displayDependencyUpdates.
private void displayDependencyUpdates(ResolveReport originalReport, ResolveReport latestReport) {
log("Dependencies updates available :");
boolean dependencyUpdateDetected = false;
for (IvyNode latest : latestReport.getDependencies()) {
for (IvyNode originalDependency : originalReport.getDependencies()) {
if (originalDependency.getModuleId().equals(latest.getModuleId())) {
if (!originalDependency.getResolvedId().getRevision().equals(latest.getResolvedId().getRevision())) {
// is this dependency a transitive or a direct dependency?
// (unfortunately .isTransitive() methods do not have the same meaning)
boolean isTransitiveDependency = latest.getDependencyDescriptor(latest.getRoot()) == null;
if (!isTransitiveDependency || showTransitive) {
log(String.format("\t%s#%s%s\t%s -> %s", originalDependency.getResolvedId().getOrganisation(), originalDependency.getResolvedId().getName(), isTransitiveDependency ? " (transitive)" : "", originalDependency.getResolvedId().getRevision(), latest.getResolvedId().getRevision()));
dependencyUpdateDetected = true;
}
}
}
}
}
if (!dependencyUpdateDetected) {
log("\tAll dependencies are up to date");
}
}
use of org.apache.ivy.core.resolve.IvyNode in project ant-ivy by apache.
the class LogReportOutputter method output.
public void output(ResolveReport report, ResolutionCacheManager cacheMgr, ResolveOptions options) throws IOException {
IvySettings settings = IvyContext.getContext().getSettings();
if (settings.logModulesInUse() && ResolveOptions.LOG_DEFAULT.equals(options.getLog())) {
Message.info("\t:: modules in use:");
List<IvyNode> dependencies = new ArrayList<>(report.getDependencies());
Collections.sort(dependencies);
if (dependencies.size() > 0) {
String[] confs = report.getConfigurations();
for (IvyNode node : dependencies) {
if (node.isCompletelyEvicted() || node.hasProblem()) {
continue;
}
List<String> nodeConfs = new ArrayList<>(confs.length);
for (String conf : confs) {
if (report.getConfigurationReport(conf).getModuleRevisionIds().contains(node.getResolvedId())) {
nodeConfs.add(conf);
}
}
Message.info("\t" + node + " from " + node.getModuleRevision().getResolver().getName() + " in " + nodeConfs);
}
}
}
IvyNode[] evicted = report.getEvictedNodes();
if (evicted.length > 0 && ResolveOptions.LOG_DEFAULT.equals(options.getLog())) {
Message.info("\t:: evicted modules:");
for (IvyNode evictedNode : evicted) {
Collection<String> allEvictingNodes = evictedNode.getAllEvictingNodesDetails();
if (allEvictingNodes == null) {
Message.info("\t" + evictedNode + " transitively in " + Arrays.asList(evictedNode.getEvictedConfs()));
} else if (allEvictingNodes.isEmpty()) {
Message.info("\t" + evictedNode + " by [] (" + evictedNode.getAllEvictingConflictManagers() + ") in " + Arrays.asList(evictedNode.getEvictedConfs()));
} else {
Message.info("\t" + evictedNode + " by " + allEvictingNodes + " in " + Arrays.asList(evictedNode.getEvictedConfs()));
}
for (String conf : evictedNode.getEvictedConfs()) {
EvictionData evictedData = evictedNode.getEvictedData(conf);
if (evictedData.getParent() != null) {
Message.verbose("\t in " + evictedData.getParent() + " with " + evictedData.getConflictManager());
}
}
}
}
if (ResolveOptions.LOG_DEFAULT.equals(options.getLog())) {
// CheckStyle:MagicNumber| OFF
char[] sep = new char[69];
Arrays.fill(sep, '-');
Message.rawinfo("\t" + new String(sep));
StringBuilder line = new StringBuilder("\t");
append(line, "", 18);
append(line, "modules", 31);
line.append("|");
append(line, "artifacts", 15);
line.append("|");
Message.rawinfo(line.toString());
line = new StringBuilder("\t");
append(line, "conf", 18);
append(line, "number", 7);
append(line, "search", 7);
append(line, "dwnlded", 7);
append(line, "evicted", 7);
line.append("|");
append(line, "number", 7);
append(line, "dwnlded", 7);
// CheckStyle:MagicNumber| ON
line.append("|");
Message.rawinfo(line.toString());
Message.rawinfo("\t" + new String(sep));
for (String conf : report.getConfigurations()) {
output(report.getConfigurationReport(conf));
}
Message.rawinfo("\t" + new String(sep));
}
IvyNode[] unresolved = report.getUnresolvedDependencies();
if (unresolved.length > 0) {
Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::");
Message.warn("\t:: UNRESOLVED DEPENDENCIES ::");
Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::");
}
for (IvyNode anUnresolved : unresolved) {
Message.warn("\t:: " + anUnresolved + ": " + anUnresolved.getProblemMessage());
}
if (unresolved.length > 0) {
Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::\n");
}
ArtifactDownloadReport[] errors = report.getFailedArtifactsReports();
if (errors.length > 0) {
Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::");
Message.warn("\t:: FAILED DOWNLOADS ::");
Message.warn("\t:: ^ see resolution messages for details ^ ::");
Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::");
}
for (ArtifactDownloadReport error : errors) {
Message.warn("\t:: " + error.getArtifact());
}
if (errors.length > 0) {
Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::\n");
}
}
use of org.apache.ivy.core.resolve.IvyNode in project ant-ivy by apache.
the class BasicResolver method parse.
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() + ": revision already resolved: " + resolvedMrid);
node.getModuleRevision().getReport().setSearched(true);
return node.getModuleRevision();
}
Message.verbose("\t" + getName() + ": found already resolved revision: " + resolvedMrid + ": but it's a default one, maybe we can find a better one");
}
}
Artifact moduleArtifact = parser.getMetadataArtifact(resolvedMrid, mdRef.getResource());
return getRepositoryCacheManager().cacheModuleDescriptor(this, mdRef, dd, moduleArtifact, downloader, getCacheOptions(data));
}
use of org.apache.ivy.core.resolve.IvyNode in project ant-ivy by apache.
the class CacheResolver method getDependency.
@Override
public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data) throws ParseException {
clearIvyAttempts();
ModuleRevisionId mrid = dd.getDependencyRevisionId();
// check revision
ResolvedModuleRevision rmr = getRepositoryCacheManager().findModuleInCache(dd, mrid, getCacheOptions(data), null);
if (rmr != null) {
Message.verbose("\t" + getName() + ": revision in cache: " + mrid);
return rmr;
} else if (!getSettings().getVersionMatcher().isDynamic(mrid)) {
Message.verbose("\t" + getName() + ": no ivy file in cache found for " + mrid);
return null;
} else {
ensureConfigured();
ResolvedResource ivyRef = findIvyFileRef(dd, data);
if (ivyRef != null) {
Message.verbose("\t" + getName() + ": found ivy file in cache for " + mrid);
Message.verbose("\t\t=> " + ivyRef);
ModuleRevisionId resolvedMrid = ModuleRevisionId.newInstance(mrid, ivyRef.getRevision());
IvyNode node = data.getNode(resolvedMrid);
if (node != null && node.getModuleRevision() != null) {
// this revision has already be resolved : return it
Message.verbose("\t" + getName() + ": revision already resolved: " + resolvedMrid);
return node.getModuleRevision();
}
rmr = getRepositoryCacheManager().findModuleInCache(dd.clone(ModuleRevisionId.newInstance(dd.getDependencyRevisionId(), ivyRef.getRevision())), dd.getDependencyRevisionId(), getCacheOptions(data), null);
if (rmr != null) {
Message.verbose("\t" + getName() + ": revision in cache: " + resolvedMrid);
return rmr;
} else {
Message.error("\t" + getName() + ": inconsistent cache: clean it and resolve again");
return null;
}
} else {
Message.verbose("\t" + getName() + ": no ivy file in cache found for " + mrid);
return null;
}
}
}
Aggregations