Search in sources :

Example 11 with Dependency

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;
}
Also used : DownloadableArtifact(org.jfrog.build.api.dependency.DownloadableArtifact) Dependency(org.jfrog.build.api.Dependency)

Example 12 with Dependency

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;
}
Also used : FileSpec(org.jfrog.build.extractor.clientConfiguration.util.spec.FileSpec) Dependency(org.jfrog.build.api.Dependency)

Example 13 with Dependency

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.");
}
Also used : Dependency(org.jfrog.build.api.Dependency) Module(org.jfrog.build.api.Module) Artifact(org.jfrog.build.api.Artifact)

Aggregations

Dependency (org.jfrog.build.api.Dependency)13 File (java.io.File)4 Artifact (org.jfrog.build.api.Artifact)3 Module (org.jfrog.build.api.Module)3 DownloadableArtifact (org.jfrog.build.api.dependency.DownloadableArtifact)3 Test (org.testng.annotations.Test)3 RandomAccessFile (java.io.RandomAccessFile)2 Properties (java.util.Properties)2 DependenciesDownloaderHelper (org.jfrog.build.extractor.clientConfiguration.util.DependenciesDownloaderHelper)2 EndResolveEvent (org.apache.ivy.core.event.resolve.EndResolveEvent)1 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)1 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)1 ConfigurationResolveReport (org.apache.ivy.core.report.ConfigurationResolveReport)1 ResolveReport (org.apache.ivy.core.report.ResolveReport)1 Project (org.apache.tools.ant.Project)1 DependencyBuilder (org.jfrog.build.api.builder.DependencyBuilder)1 BuildInfoExtractorUtils.getModuleIdString (org.jfrog.build.extractor.BuildInfoExtractorUtils.getModuleIdString)1 BuildInfoExtractorUtils.getTypeString (org.jfrog.build.extractor.BuildInfoExtractorUtils.getTypeString)1 FileSpec (org.jfrog.build.extractor.clientConfiguration.util.spec.FileSpec)1