Java Code Examples for org.apache.ivy.core.report.ResolveReport#getDependencies()

The following examples show how to use org.apache.ivy.core.report.ResolveReport#getDependencies() . 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: IvyDependencyUpdateChecker.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
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 2
Source File: IvyDependencyUpdateChecker.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
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 3
Source File: IvyDependencyTree.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
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 4
Source File: LatestConflictManagerTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
/**
 * 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 5
Source File: IvyDependencyUpdateChecker.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
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");
    }
}
 
Example 6
Source File: ResolveEngine.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
public void downloadArtifacts(ResolveReport report, Filter<Artifact> artifactFilter,
        DownloadOptions options) {
    long start = System.currentTimeMillis();

    eventManager.fireIvyEvent(new PrepareDownloadEvent(report.getArtifacts().toArray(
        new Artifact[report.getArtifacts().size()])));

    long totalSize = 0;
    for (IvyNode dependency : report.getDependencies()) {
        checkInterrupted();
        // download artifacts required in all asked configurations
        if (!dependency.isCompletelyEvicted() && !dependency.hasProblem()
                && dependency.getModuleRevision() != null) {
            DependencyResolver resolver = dependency.getModuleRevision()
                    .getArtifactResolver();
            Artifact[] selectedArtifacts = dependency.getSelectedArtifacts(artifactFilter);
            DownloadReport dReport = resolver.download(selectedArtifacts, options);
            for (ArtifactDownloadReport adr : dReport.getArtifactsReports()) {
                if (adr.getDownloadStatus() == DownloadStatus.FAILED) {
                    if (adr.getArtifact().getExtraAttribute("ivy:merged") != null) {
                        Message.warn("\tmerged artifact not found: " + adr.getArtifact()
                                + ". It was required in "
                                + adr.getArtifact().getExtraAttribute("ivy:merged"));
                    } else {
                        Message.warn("\t" + adr);
                        resolver.reportFailure(adr.getArtifact());
                    }
                } else if (adr.getDownloadStatus() == DownloadStatus.SUCCESSFUL) {
                    totalSize += adr.getSize();
                }
            }
            // update concerned reports
            for (String dconf : dependency.getRootModuleConfigurations()) {
                // the report itself is responsible to take into account only
                // artifacts required in its corresponding configuration
                // (as described by the Dependency object)
                if (dependency.isEvicted(dconf)
                        || dependency.isBlacklisted(dconf)) {
                    report.getConfigurationReport(dconf).addDependency(dependency);
                } else {
                    report.getConfigurationReport(dconf).addDependency(dependency,
                            dReport);
                }
            }
        }
    }
    report.setDownloadTime(System.currentTimeMillis() - start);
    report.setDownloadSize(totalSize);
}