Search in sources :

Example 1 with FileSpec

use of org.jfrog.build.extractor.clientConfiguration.util.spec.FileSpec in project build-info by JFrogDev.

the class DependenciesDownloaderHelper method downloadDependencies.

/**
 * Download dependencies by the provided spec using the provided in the constructor client.
 * returns list of downloaded artifacts
 *
 * @param downloadSpec the download spec
 * @return list of downloaded artifacts
 * @throws IOException in case of IO error
 */
public List<Dependency> downloadDependencies(Spec downloadSpec) throws IOException {
    AqlDependenciesHelper aqlHelper = new AqlDependenciesHelper(downloader, "", log);
    WildcardsDependenciesHelper wildcardHelper = new WildcardsDependenciesHelper(downloader, "", log);
    List<Dependency> resolvedDependencies = Lists.newArrayList();
    for (FileSpec file : downloadSpec.getFiles()) {
        log.debug("Downloading dependencies using spec: \n" + file.toString());
        validateFileSpec(file);
        String buildName = getBuildName(file.getBuild());
        String buildNumber = getBuildNumber(buildName, file.getBuild());
        if (StringUtils.isNotBlank(buildName) && StringUtils.isBlank(buildNumber)) {
            return resolvedDependencies;
        }
        if (file.getPattern() != null) {
            wildcardHelper.setTarget(file.getTarget());
            wildcardHelper.setFlatDownload(BooleanUtils.toBoolean(file.getFlat()));
            wildcardHelper.setRecursive(!"false".equalsIgnoreCase(file.getRecursive()));
            wildcardHelper.setProps(file.getProps());
            wildcardHelper.setBuildName(buildName);
            wildcardHelper.setBuildNumber(buildNumber);
            log.info(String.format("Downloading artifacts using pattern: %s%s", file.getPattern(), SpecsHelper.getExcludePatternsLogStr(file.getExcludePatterns())));
            resolvedDependencies.addAll(wildcardHelper.retrievePublishedDependencies(file.getPattern(), file.getExcludePatterns(), Boolean.valueOf(file.getExplode())));
        } else if (file.getAql() != null) {
            aqlHelper.setTarget(file.getTarget());
            aqlHelper.setFlatDownload(BooleanUtils.toBoolean(file.getFlat()));
            aqlHelper.setBuildName(buildName);
            aqlHelper.setBuildNumber(buildNumber);
            resolvedDependencies.addAll(aqlHelper.retrievePublishedDependencies(file.getAql(), null, Boolean.valueOf(file.getExplode())));
        }
    }
    return resolvedDependencies;
}
Also used : FileSpec(org.jfrog.build.extractor.clientConfiguration.util.spec.FileSpec) Dependency(org.jfrog.build.api.Dependency)

Aggregations

Dependency (org.jfrog.build.api.Dependency)1 FileSpec (org.jfrog.build.extractor.clientConfiguration.util.spec.FileSpec)1