use of org.jfrog.build.api.dependency.DownloadableArtifact in project build-info by JFrogDev.
the class AntPatternsDependenciesHelper method performPatternSearch.
private Set<DownloadableArtifact> performPatternSearch(DependencyPattern dependencyPattern) throws IOException {
Set<DownloadableArtifact> downloadableArtifacts = Sets.newHashSet();
String pattern = dependencyPattern.getPattern();
PatternResultFileSet fileSet = downloader.getClient().searchArtifactsByPattern(pattern);
Set<String> filesToDownload = fileSet.getFiles();
log.info("Found " + filesToDownload.size() + " dependencies by doing a pattern search.");
for (String fileToDownload : filesToDownload) {
downloadableArtifacts.add(new DownloadableArtifact(fileSet.getRepoUri(), dependencyPattern.getTargetDirectory(), fileToDownload, dependencyPattern.getMatrixParams(), pattern, dependencyPattern.getPatternType()));
}
return downloadableArtifacts;
}
use of org.jfrog.build.api.dependency.DownloadableArtifact in project build-info by JFrogDev.
the class AntPatternsDependenciesHelper method performPropertySearch.
private Set<DownloadableArtifact> performPropertySearch(DependencyPattern dependencyPattern) throws IOException {
Set<DownloadableArtifact> downloadableArtifacts = Sets.newHashSet();
String pattern = dependencyPattern.getPattern();
String matrixParams = dependencyPattern.getMatrixParams();
PropertySearchResult propertySearchResult = downloader.getClient().searchArtifactsByProperties(matrixParams);
List<PropertySearchResult.SearchEntry> filteredEntries = filterResultEntries(propertySearchResult.getResults(), pattern);
log.info("Found " + filteredEntries.size() + " dependencies by doing a property search.");
for (PropertySearchResult.SearchEntry searchEntry : filteredEntries) {
downloadableArtifacts.add(new DownloadableArtifact(searchEntry.getRepoUri(), dependencyPattern.getTargetDirectory(), searchEntry.getFilePath(), matrixParams, pattern, dependencyPattern.getPatternType()));
}
return downloadableArtifacts;
}
use of org.jfrog.build.api.dependency.DownloadableArtifact in project build-info by JFrogDev.
the class DependenciesDownloaderHelper method removeUnusedArtifactsFromLocal.
private void removeUnusedArtifactsFromLocal(Set<DownloadableArtifact> downloadableArtifacts) throws IOException {
Set<String> forDeletionFiles = Sets.newHashSet();
Set<String> allResolvesFiles = Sets.newHashSet();
for (DownloadableArtifact downloadableArtifact : downloadableArtifacts) {
String fileDestination = downloader.getTargetDir(downloadableArtifact.getTargetDirPath(), downloadableArtifact.getRelativeDirPath());
allResolvesFiles.add(fileDestination);
if (PatternType.DELETE.equals(downloadableArtifact.getPatternType())) {
forDeletionFiles.add(fileDestination);
}
}
downloader.removeUnusedArtifactsFromLocal(allResolvesFiles, forDeletionFiles);
}
use of org.jfrog.build.api.dependency.DownloadableArtifact in project build-info by JFrogDev.
the class DownloadTest method testDownloadArtifact.
@Test(dataProvider = "testDownloadFilesProvider")
public void testDownloadArtifact(Map<String, String> uploadedChecksum, String fileName, long fileSize) throws Exception {
DependenciesDownloaderHelper dependenciesDownloaderHelper = new DependenciesDownloaderHelper(dependenciesClient, ".", log);
String repoUrl = dependenciesClient.getArtifactoryUrl() + "/" + localRepo + "/" + TEST_REPO_PATH;
String targetDirPath = tempWorkspace.getPath() + File.separatorChar + "download" + File.separatorChar;
String url = repoUrl + "/" + fileName;
ArtifactMetaData artifactMetaData = dependenciesDownloaderHelper.downloadArtifactMetaData(url);
Assert.assertEquals(artifactMetaData.getMd5(), uploadedChecksum.get(MD5_ALGORITHM_NAME));
Assert.assertEquals(artifactMetaData.getSha1(), uploadedChecksum.get(SHA1_ALGORITHM_NAME));
Assert.assertEquals(artifactMetaData.getSize(), fileSize);
DownloadableArtifact downloadableArtifact = new DownloadableArtifact(repoUrl, targetDirPath, fileName, "", fileName, PatternType.NORMAL);
Dependency dependency = dependenciesDownloaderHelper.downloadArtifact(downloadableArtifact, artifactMetaData, url, fileName);
Assert.assertEquals(dependency.getId(), fileName);
Assert.assertEquals(dependency.getMd5(), uploadedChecksum.get(MD5_ALGORITHM_NAME));
Assert.assertEquals(dependency.getSha1(), uploadedChecksum.get(SHA1_ALGORITHM_NAME));
Assert.assertEquals((new File(targetDirPath + fileName)).length(), fileSize);
}
use of org.jfrog.build.api.dependency.DownloadableArtifact in project build-info by JFrogDev.
the class DownloadTest method testDownloadArtifactWithoutContentLength.
@Test(dataProvider = "testDownloadFilesProvider")
public void testDownloadArtifactWithoutContentLength(Map<String, String> uploadedChecksum, String fileName, long fileSize) throws Exception {
DependenciesDownloaderHelper dependenciesDownloaderHelper = new DependenciesDownloaderHelper(dependenciesClient, ".", log);
String repoUrl = dependenciesClient.getArtifactoryUrl() + "/" + localRepo + "/" + TEST_REPO_PATH;
String targetDirPath = tempWorkspace.getPath() + File.separatorChar + "download" + File.separatorChar;
String url = repoUrl + "/" + fileName;
ArtifactMetaData artifactMetaData = dependenciesDownloaderHelper.downloadArtifactMetaData(url);
Assert.assertEquals(artifactMetaData.getMd5(), uploadedChecksum.get(MD5_ALGORITHM_NAME));
Assert.assertEquals(artifactMetaData.getSha1(), uploadedChecksum.get(SHA1_ALGORITHM_NAME));
Assert.assertEquals(artifactMetaData.getSize(), fileSize);
// When content-length is missing
artifactMetaData.setSize(0);
DownloadableArtifact downloadableArtifact = new DownloadableArtifact(repoUrl, targetDirPath, fileName, "", fileName, PatternType.NORMAL);
Dependency dependency = dependenciesDownloaderHelper.downloadArtifact(downloadableArtifact, artifactMetaData, url, fileName);
Assert.assertEquals(dependency.getId(), fileName);
Assert.assertEquals(dependency.getMd5(), uploadedChecksum.get(MD5_ALGORITHM_NAME));
Assert.assertEquals(dependency.getSha1(), uploadedChecksum.get(SHA1_ALGORITHM_NAME));
Assert.assertEquals((new File(targetDirPath + fileName)).length(), fileSize);
}
Aggregations