use of org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails in project build-info by JFrogDev.
the class DownloadTest method testDownloadArtifactFromDifferentPath.
public void testDownloadArtifactFromDifferentPath() throws IOException {
String targetDirPath = tempWorkspace.getPath() + File.separatorChar + "testDownloadDupArtifactFromDifferentPath" + File.separatorChar;
FileSpec fileSpec = new FileSpec();
// Upload one file to different locations in Artifactory.
try {
File file = createRandomFile(tempWorkspace.getPath() + File.pathSeparatorChar + "file", 1);
for (int i = 0; i < 3; i++) {
String filePath = TEST_REPO_PATH + "/" + i + "/file";
DeployDetails deployDetails = new DeployDetails.Builder().file(file).artifactPath(filePath).targetRepository(localRepo1).explode(false).packageType(DeployDetails.PackageType.GENERIC).build();
FilesGroup fg = new FilesGroup();
fg.setPattern(localRepo1 + "/" + filePath);
fg.setTarget(targetDirPath);
fileSpec.addFilesGroup(fg);
// Upload artifact
artifactoryManager.upload(deployDetails);
}
DependenciesDownloaderHelper helper = new DependenciesDownloaderHelper(artifactoryManager, tempWorkspace.getPath(), log);
List<Dependency> dependencies = helper.downloadDependencies(fileSpec);
Assert.assertEquals(dependencies.size(), 3);
} finally {
FileUtils.deleteDirectory(tempWorkspace);
}
}
use of org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails in project build-info by JFrogDev.
the class DownloadTest method testDownloadFilesProvider.
/**
* Create and upload files to Artifactory.
* The test files are created according to the data provided in testFilesMap
*/
@DataProvider
private Object[][] testDownloadFilesProvider() throws IOException, NoSuchAlgorithmException {
if (artifactoryManager == null) {
throw new IOException("tests were not initialized successfully. aborting");
}
Map<String, Integer> testFilesMap = new HashMap<String, Integer>() {
{
put("file1", MIN_SIZE_FOR_CONCURRENT_DOWNLOAD);
put("file2", MIN_SIZE_FOR_CONCURRENT_DOWNLOAD - 1);
put("zeroByte", 0);
}
};
Object[][] tests = new Object[testFilesMap.size()][4];
try {
int i = 0;
for (Map.Entry<String, Integer> entry : testFilesMap.entrySet()) {
String fileName = entry.getKey();
int fileSize = entry.getValue();
// Create file and calculate checksum
File file = createRandomFile(tempWorkspace.getPath() + File.pathSeparatorChar + fileName, fileSize);
Map<String, String> checksum = FileChecksumCalculator.calculateChecksums(file, SHA1_ALGORITHM, MD5_ALGORITHM);
DeployDetails deployDetails = new DeployDetails.Builder().file(file).artifactPath(TEST_REPO_PATH + "/" + fileName).targetRepository(localRepo1).md5(checksum.get(MD5_ALGORITHM)).sha1(checksum.get(SHA1_ALGORITHM)).explode(false).packageType(DeployDetails.PackageType.GENERIC).build();
// Upload artifact
artifactoryManager.upload(deployDetails);
long createdFileSize = deployDetails.getFile().length();
tests[i] = new Object[] { checksum, fileName, createdFileSize };
i++;
}
} finally {
FileUtils.deleteDirectory(tempWorkspace);
}
return tests;
}
use of org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails in project build-info by JFrogDev.
the class NpmPublish method doDeploy.
private void doDeploy() throws IOException {
DeployDetails deployDetails = new DeployDetails.Builder().file(path.toFile()).targetRepository(repo).addProperties(properties).artifactPath(npmPackageInfo.getDeployPath()).packageType(DeployDetails.PackageType.NPM).build();
ArtifactoryUploadResponse response = artifactoryManager.upload(deployDetails);
deployedArtifact = new ArtifactBuilder(npmPackageInfo.getModuleId()).md5(response.getChecksums().getMd5()).sha1(response.getChecksums().getSha1()).remotePath(StringUtils.substringBeforeLast(npmPackageInfo.getDeployPath(), "/")).build();
}
use of org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails in project build-info by JFrogDev.
the class NpmExtractorTest method deployTestDependencies.
private void deployTestDependencies(Project... projects) throws IOException {
for (Project project : projects) {
DeployDetails deployDetails = new DeployDetails.Builder().file(project.projectOrigin.toPath().resolve(project.getPackedFileName()).toFile()).targetRepository(localRepo1).artifactPath(project.getTargetPath()).packageType(DeployDetails.PackageType.NPM).build();
artifactoryManager.upload(deployDetails);
}
}
use of org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails in project build-info by JFrogDev.
the class GradleModuleExtractor method extractModule.
@Override
public Module extractModule(Project project) {
Set<GradleDeployDetails> gradleDeployDetails = Sets.newHashSet();
String artifactName = project.getName();
ArtifactoryTask artifactoryTask = ProjectUtils.getBuildInfoTask(project);
if (artifactoryTask != null) {
artifactName = project.getName();
try {
artifactoryTask.collectDescriptorsAndArtifactsForUpload();
} catch (IOException e) {
throw new RuntimeException("Cannot collect deploy details for " + artifactoryTask.getPath(), e);
}
gradleDeployDetails = artifactoryTask.deployDetails;
}
String repo = gradleDeployDetails.stream().map(GradleDeployDetails::getDeployDetails).map(DeployDetails::getTargetRepository).findAny().orElse("");
String moduleId = getModuleIdString(project.getGroup().toString(), artifactName, project.getVersion().toString());
ModuleBuilder builder = new ModuleBuilder().type(ModuleType.GRADLE).id(moduleId).repository(repo);
try {
// Extract the module's artifacts information if a publisher exists.
ArtifactoryClientConfiguration.PublisherHandler publisher = ArtifactoryPluginUtil.getPublisherHandler(project);
if (publisher != null) {
boolean excludeArtifactsFromBuild = publisher.isFilterExcludedArtifactsFromBuild();
IncludeExcludePatterns patterns = new IncludeExcludePatterns(publisher.getIncludePatterns(), publisher.getExcludePatterns());
Iterable<GradleDeployDetails> deployExcludeDetails;
Iterable<GradleDeployDetails> deployIncludeDetails;
if (excludeArtifactsFromBuild) {
deployIncludeDetails = Iterables.filter(gradleDeployDetails, new IncludeExcludePredicate(project, patterns, true));
deployExcludeDetails = Iterables.filter(gradleDeployDetails, new IncludeExcludePredicate(project, patterns, false));
} else {
deployIncludeDetails = Iterables.filter(gradleDeployDetails, new ProjectPredicate(project));
deployExcludeDetails = new ArrayList<>();
}
builder.artifacts(calculateArtifacts(deployIncludeDetails)).excludedArtifacts(calculateArtifacts(deployExcludeDetails));
} else {
log.warn("No publisher config found for project: " + project.getName());
}
builder.dependencies(calculateDependencies(project, moduleId));
} catch (Exception e) {
log.error("Error during extraction: ", e);
}
return builder.build();
}
Aggregations