Search in sources :

Example 6 with DownloadableArtifact

use of org.jfrog.build.api.dependency.DownloadableArtifact in project build-info by JFrogDev.

the class WildcardsDependenciesHelper method replaceTargetPlaceholders.

private void replaceTargetPlaceholders(String searchPattern, Set<DownloadableArtifact> downloadableArtifacts) {
    searchPattern = StringUtils.substringAfter(searchPattern, "/");
    Pattern pattern = Pattern.compile(PathsUtils.pathToRegExp(searchPattern));
    target = StringUtils.defaultIfEmpty(target, "");
    for (DownloadableArtifact artifact : downloadableArtifacts) {
        if (StringUtils.isEmpty(target) || target.endsWith("/")) {
            artifact.setTargetDirPath(PathsUtils.reformatRegexp(artifact.getFilePath(), target, pattern));
        } else {
            String targetAfterReplacement = PathsUtils.reformatRegexp(artifact.getFilePath(), target, pattern);
            Map<String, String> targetFileName = PathsUtils.replaceFilesName(targetAfterReplacement, artifact.getRelativeDirPath());
            artifact.setRelativeDirPath(targetFileName.get("srcPath"));
            artifact.setTargetDirPath(targetFileName.get("targetPath"));
        }
    }
}
Also used : Pattern(java.util.regex.Pattern) DownloadableArtifact(org.jfrog.build.api.dependency.DownloadableArtifact)

Example 7 with DownloadableArtifact

use of org.jfrog.build.api.dependency.DownloadableArtifact in project build-info by JFrogDev.

the class AqlDependenciesHelper method collectArtifactsToDownload.

public Set<DownloadableArtifact> collectArtifactsToDownload(String aql, boolean explode) throws IOException {
    Set<DownloadableArtifact> downloadableArtifacts = Sets.newHashSet();
    if (StringUtils.isNotBlank(buildName)) {
        aql = addBuildToQuery(aql);
    }
    aql = "items.find(" + aql + ")";
    AqlSearchResult aqlSearchResult = downloader.getClient().searchArtifactsByAql(aql);
    List<AqlSearchResult.SearchEntry> searchResults = aqlSearchResult.getResults();
    for (AqlSearchResult.SearchEntry searchEntry : searchResults) {
        String path = searchEntry.getPath().equals(".") ? "" : searchEntry.getPath() + "/";
        DownloadableArtifact downloadableArtifact = new DownloadableArtifact(StringUtils.stripEnd(artifactoryUrl, "/") + "/" + searchEntry.getRepo(), target, path + searchEntry.getName(), "", "", PatternType.NORMAL);
        downloadableArtifact.setExplode(explode);
        downloadableArtifacts.add(downloadableArtifact);
    }
    return downloadableArtifacts;
}
Also used : AqlSearchResult(org.jfrog.build.api.search.AqlSearchResult) DownloadableArtifact(org.jfrog.build.api.dependency.DownloadableArtifact)

Example 8 with DownloadableArtifact

use of org.jfrog.build.api.dependency.DownloadableArtifact in project build-info by JFrogDev.

the class DependenciesDownloaderHelper method downloadDependencies.

public List<Dependency> downloadDependencies(Set<DownloadableArtifact> downloadableArtifacts) throws IOException {
    List<Dependency> dependencies = Lists.newArrayList();
    Set<DownloadableArtifact> downloadedArtifacts = Sets.newHashSet();
    for (DownloadableArtifact downloadableArtifact : downloadableArtifacts) {
        Dependency dependency = downloadArtifact(downloadableArtifact);
        if (dependency != null) {
            dependencies.add(dependency);
            downloadedArtifacts.add(downloadableArtifact);
            explodeDependenciesIfNeeded(downloadableArtifact);
        }
    }
    removeUnusedArtifactsFromLocal(downloadedArtifacts);
    return dependencies;
}
Also used : DownloadableArtifact(org.jfrog.build.api.dependency.DownloadableArtifact) Dependency(org.jfrog.build.api.Dependency)

Aggregations

DownloadableArtifact (org.jfrog.build.api.dependency.DownloadableArtifact)8 Dependency (org.jfrog.build.api.Dependency)3 File (java.io.File)2 RandomAccessFile (java.io.RandomAccessFile)2 DependenciesDownloaderHelper (org.jfrog.build.extractor.clientConfiguration.util.DependenciesDownloaderHelper)2 Test (org.testng.annotations.Test)2 Pattern (java.util.regex.Pattern)1 PatternResultFileSet (org.jfrog.build.api.dependency.PatternResultFileSet)1 PropertySearchResult (org.jfrog.build.api.dependency.PropertySearchResult)1 AqlSearchResult (org.jfrog.build.api.search.AqlSearchResult)1