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"));
}
}
}
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;
}
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;
}
Aggregations