Java Code Examples for org.apache.ivy.core.resolve.ResolveOptions#setDownload()

The following examples show how to use org.apache.ivy.core.resolve.ResolveOptions#setDownload() . 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: MavenResolver.java    From IJava with MIT License 6 votes vote down vote up
private List<File> resolveFromIvyFile(Ivy ivy, File ivyFile, List<String> scopes) throws IOException, ParseException {
    ResolveOptions resolveOptions = new ResolveOptions();
    resolveOptions.setTransitive(true);
    resolveOptions.setDownload(true);
    resolveOptions.setConfs(!scopes.isEmpty()
            ? scopes.toArray(new String[0])
            : DEFAULT_RESOLVE_CONFS
    );

    ResolveReport resolved = ivy.resolve(ivyFile, resolveOptions);
    if (resolved.hasError())
        // TODO better error...
        throw new RuntimeException("Error resolving '" + ivyFile + "'. " + resolved.getAllProblemMessages());

    return Arrays.stream(resolved.getAllArtifactsReports())
            .map(ArtifactDownloadReport::getLocalFile)
            .collect(Collectors.toList());
}
 
Example 2
Source File: ResolveIvyFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private ResolveData createResolveData(Ivy ivy, String configurationName) {
    ResolveOptions options = new ResolveOptions();
    options.setDownload(false);
    options.setConfs(WrapUtil.toArray(configurationName));
    return new ResolveData(ivy.getResolveEngine(), options);
}
 
Example 3
Source File: MavenResolver.java    From IJava with MIT License 4 votes vote down vote up
public List<File> resolveMavenDependency(String canonical, Set<String> repos, int verbosity) throws IOException, ParseException {
    ChainResolver rootResolver = this.searchAllReposResolver(repos);

    Ivy ivy = this.createDefaultIvyInstance(verbosity);
    IvySettings settings = ivy.getSettings();

    settings.addResolver(rootResolver);
    rootResolver.setCheckmodified(true);
    settings.setDefaultResolver(rootResolver.getName());

    ivy.getLoggerEngine().info("Searching for dependencies in: " + rootResolver.getResolvers());

    ResolveOptions resolveOptions = new ResolveOptions();
    resolveOptions.setTransitive(true);
    resolveOptions.setDownload(true);

    ModuleRevisionId artifactIdentifier = MavenResolver.parseCanonicalArtifactName(canonical);
    DefaultModuleDescriptor containerModule = DefaultModuleDescriptor.newCallerInstance(
            artifactIdentifier,
            DEFAULT_RESOLVE_CONFS,
            true, // Transitive
            repos != null // Changing - the resolver will set this based on SNAPSHOT since they are all m2 compatible
            // but if `repos` is specified, we want to force a lookup.
    );

    ResolveReport resolved = ivy.resolve(containerModule, resolveOptions);
    if (resolved.hasError()) {
        MessageLogger logger = ivy.getLoggerEngine();
        Arrays.stream(resolved.getAllArtifactsReports())
                .forEach(r -> {
                    logger.error("download " + r.getDownloadStatus() + ": " + r.getArtifact() + " of " + r.getType());
                    if (r.getArtifactOrigin() == null)
                        logger.error("\tCouldn't find artifact.");
                    else
                        logger.error("\tfrom: " + r.getArtifactOrigin());
                });

        // TODO better error...
        throw new RuntimeException("Error resolving '" + canonical + "'. " + resolved.getAllProblemMessages());
    }

    return Arrays.stream(resolved.getAllArtifactsReports())
            .filter(a -> JAR_TYPE.equalsIgnoreCase(a.getType()))
            .map(ArtifactDownloadReport::getLocalFile)
            .collect(Collectors.toList());
}
 
Example 4
Source File: ResolveIvyFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private ResolveData createResolveData(Ivy ivy, String configurationName) {
    ResolveOptions options = new ResolveOptions();
    options.setDownload(false);
    options.setConfs(WrapUtil.toArray(configurationName));
    return new ResolveData(ivy.getResolveEngine(), options);
}
 
Example 5
Source File: IvyDependencyUpdateChecker.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
public void doExecute() throws BuildException {
    prepareAndCheck();

    ModuleDescriptor originalModuleDescriptor = getResolvedReport().getModuleDescriptor();
    // clone module descriptor
    DefaultModuleDescriptor latestModuleDescriptor = new DefaultModuleDescriptor(
            originalModuleDescriptor.getModuleRevisionId(),
            originalModuleDescriptor.getStatus(), originalModuleDescriptor.getPublicationDate());
    // copy configurations
    for (Configuration configuration : originalModuleDescriptor.getConfigurations()) {
        latestModuleDescriptor.addConfiguration(configuration);
    }
    // clone dependency and add new one with the requested revisionToCheck
    for (DependencyDescriptor dependencyDescriptor : originalModuleDescriptor.getDependencies()) {
        ModuleRevisionId upToDateMrid = ModuleRevisionId.newInstance(
            dependencyDescriptor.getDependencyRevisionId(), revisionToCheck);
        latestModuleDescriptor.addDependency(dependencyDescriptor.clone(upToDateMrid));
    }

    // resolve
    ResolveOptions resolveOptions = new ResolveOptions();
    resolveOptions.setDownload(isDownload());
    resolveOptions.setLog(getLog());
    resolveOptions.setConfs(splitToArray(getConf()));
    resolveOptions.setCheckIfChanged(checkIfChanged);

    ResolveReport latestReport;
    try {
        latestReport = getIvyInstance().getResolveEngine().resolve(latestModuleDescriptor,
            resolveOptions);

        displayDependencyUpdates(getResolvedReport(), latestReport);
        if (showTransitive) {
            displayNewDependencyOnLatest(getResolvedReport(), latestReport);
            displayMissingDependencyOnLatest(getResolvedReport(), latestReport);
        }

    } catch (ParseException | IOException e) {
        throw new BuildException("impossible to resolve dependencies:\n\t" + e, e);
    }

}