use of org.jfrog.build.api.Dependency 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;
}
use of org.jfrog.build.api.Dependency 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;
}
use of org.jfrog.build.api.Dependency in project build-info by JFrogDev.
the class ModuleBuilderTest method testBuilderAddMethods.
/**
* Validates the module values after using the builder add methods
*/
public void testBuilderAddMethods() {
Artifact artifact = new Artifact();
Dependency dependency = new Dependency();
String propertyKey = "key";
String propertyValue = "value";
Module module = new ModuleBuilder().id("test").addArtifact(artifact).addDependency(dependency).addProperty(propertyKey, propertyValue).build();
assertEquals(module.getId(), "test", "Unexpected module id");
assertFalse(module.getArtifacts().isEmpty(), "A module artifact should have been added.");
assertEquals(module.getArtifacts().get(0), artifact, "Unexpected module artifact.");
assertFalse(module.getDependencies().isEmpty(), "A module dependency should have been added.");
assertEquals(module.getDependencies().get(0), dependency, "Unexpected dependency artifact.");
assertTrue(module.getProperties().containsKey(propertyKey), "A module property should have been added.");
assertEquals(module.getProperties().get(propertyKey), propertyValue, "Unexpected module property value.");
}
Aggregations