Search in sources :

Example 1 with ModuleBuilder

use of org.jfrog.build.extractor.builder.ModuleBuilder in project build-info by JFrogDev.

the class BuildInfoRecorder method finalizeModule.

private void finalizeModule(MavenProject project) {
    try {
        extractArtifactsAndDependencies(project);
        ModuleBuilder module = currentModule.get();
        if (module == null) {
            logger.warn("Skipping Artifactory Build-Info module finalization: Null current module.");
            return;
        }
        addModuleToBuild(project, module);
    } finally {
        cleanUpModule();
    }
}
Also used : ModuleBuilder(org.jfrog.build.extractor.builder.ModuleBuilder)

Example 2 with ModuleBuilder

use of org.jfrog.build.extractor.builder.ModuleBuilder in project build-info by JFrogDev.

the class PipBuildInfoExtractor method createBuild.

private BuildInfo createBuild(List<Dependency> dependenciesList, String moduleName) {
    Module module = new ModuleBuilder().type(ModuleType.PYPI).id(moduleName).dependencies(dependenciesList).build();
    List<Module> modules = new ArrayList<>();
    modules.add(module);
    BuildInfo buildInfo = new BuildInfo();
    buildInfo.setModules(modules);
    return buildInfo;
}
Also used : ModuleBuilder(org.jfrog.build.extractor.builder.ModuleBuilder) BuildInfo(org.jfrog.build.extractor.ci.BuildInfo) ArrayList(java.util.ArrayList) Module(org.jfrog.build.extractor.ci.Module)

Example 3 with ModuleBuilder

use of org.jfrog.build.extractor.builder.ModuleBuilder in project build-info by JFrogDev.

the class BuildInfo method ToBuildInfo.

public static BuildInfo ToBuildInfo(org.jfrog.build.api.Build build) {
    BuildInfoBuilder builder = new BuildInfoBuilder(build.getName());
    builder.number(build.getNumber()).setProject(build.getProject()).agent(build.getAgent() == null ? null : new Agent(build.getAgent().getName(), build.getAgent().getVersion())).buildAgent(build.getBuildAgent() == null ? null : new BuildAgent(build.getBuildAgent().getName(), build.getBuildAgent().getVersion())).started(build.getStarted()).startedMillis(build.getStartedMillis()).durationMillis(build.getDurationMillis()).principal(build.getPrincipal()).artifactoryPrincipal(build.getArtifactoryPrincipal()).artifactoryPluginVersion(build.getArtifactoryPluginVersion()).url(build.getUrl()).parentName(build.getParentName()).parentNumber(build.getParentNumber()).buildRunParameters(build.getRunParameters() == null ? null : build.getRunParameters().stream().map(rp -> new MatrixParameter(rp.getKey(), rp.getValue())).collect(Collectors.toList())).statuses(build.getStatuses()).properties(build.getProperties()).vcs(build.getVcs() == null ? null : build.getVcs().stream().map(Vcs::ToBuildInfoVcs).collect(Collectors.toList())).buildRetention(build.getBuildRetention() == null ? null : BuildRetention.ToBuildInfoRetention(build.getBuildRetention())).issues(build.getIssues() == null ? null : Issues.ToBuildInfoIssues(build.getIssues()));
    if (build.getModules() != null) {
        builder.modules(build.getModules().stream().map(m -> new ModuleBuilder().type(m.getType()).id(m.getId()).repository(m.getRepository()).sha1(m.getSha1()).md5(m.getMd5()).artifacts(m.getArtifacts() == null ? null : m.getArtifacts().stream().map(Artifact::ToBuildInfoArtifact).collect(Collectors.toList())).dependencies(m.getDependencies() == null ? null : m.getDependencies().stream().map(Dependency::ToBuildDependency).collect(Collectors.toList())).properties(m.getProperties()).excludedArtifacts(m.getExcludedArtifacts() == null ? null : m.getExcludedArtifacts().stream().map(Artifact::ToBuildInfoArtifact).collect(Collectors.toList())).build()).collect(Collectors.toList()));
    }
    return builder.build();
}
Also used : BuildInfoBuilder(org.jfrog.build.extractor.builder.BuildInfoBuilder) ModuleBuilder(org.jfrog.build.extractor.builder.ModuleBuilder)

Example 4 with ModuleBuilder

use of org.jfrog.build.extractor.builder.ModuleBuilder in project build-info by JFrogDev.

the class BuildInfoMavenBuilderTest method testDuplicateModuleDependencies.

/**
 * Validates adding same dependencies with different scopes to different modules
 */
public void testDuplicateModuleDependencies() {
    ModuleBuilder module1 = new ModuleBuilder().type(ModuleType.MAVEN).id("id");
    module1.addDependency(new DependencyBuilder().id("dep1").scopes(CommonUtils.newHashSet("compile")).build());
    module1.addDependency(new DependencyBuilder().id("dep2").scopes(CommonUtils.newHashSet("compile")).build());
    ModuleBuilder module2 = new ModuleBuilder().type(ModuleType.MAVEN).id("id");
    module2.addDependency(new DependencyBuilder().id("dep1").scopes(CommonUtils.newHashSet("compile", "test")).build());
    module2.addDependency(new DependencyBuilder().id("dep2").scopes(CommonUtils.newHashSet("compile", "test")).build());
    BuildInfoMavenBuilder builder = new BuildInfoMavenBuilder("test").number("4").started("test");
    builder.addModule(module1.build());
    builder.addModule(module2.build());
    BuildInfo buildInfo = builder.build();
    List<Module> modules = buildInfo.getModules();
    assertFalse(modules.isEmpty(), "A buildInfo module should have been added.");
    assertEquals(modules.size(), 1, "Expected to find only 1 module.");
    assertEquals(modules.get(0).getId(), "id", "Expected to find module with id = 'id'.");
    assertEquals(modules.get(0).getType(), "maven", "Expected to find module with type = 'maven'.");
    List<Dependency> dependencies = modules.get(0).getDependencies();
    assertEquals(dependencies.size(), 2, "Expected to find only 2 dependencies.");
    assertTrue(dependencies.get(0).getScopes().contains("compile"), "Expected to find compile scope");
    assertTrue(dependencies.get(0).getScopes().contains("test"), "Expected to find test scope");
    assertTrue(dependencies.get(1).getScopes().contains("compile"), "Expected to find compile scope");
    assertTrue(dependencies.get(1).getScopes().contains("test"), "Expected to find test scope");
}
Also used : DependencyBuilder(org.jfrog.build.extractor.builder.DependencyBuilder) BuildInfoMavenBuilder(org.jfrog.build.extractor.builder.BuildInfoMavenBuilder) ModuleBuilder(org.jfrog.build.extractor.builder.ModuleBuilder)

Example 5 with ModuleBuilder

use of org.jfrog.build.extractor.builder.ModuleBuilder in project build-info by JFrogDev.

the class BuildInfoMavenBuilderTest method testDuplicateModules.

/**
 * Validates adding duplicate modules, the builder should container only unique ones
 */
public void testDuplicateModules() {
    Module module1 = new ModuleBuilder().type(ModuleType.MAVEN).id("id").build();
    Module module2 = new ModuleBuilder().type(ModuleType.MAVEN).id("id").build();
    BuildInfoMavenBuilder builder = new BuildInfoMavenBuilder("test").number("4").started("test");
    builder.addModule(module1);
    builder.addModule(module2);
    BuildInfo buildInfo = builder.build();
    List<Module> modules = buildInfo.getModules();
    assertFalse(modules.isEmpty(), "A buildInfo module should have been added.");
    assertEquals(modules.size(), 1, "Expected to find only 1 module.");
    assertEquals(modules.get(0).getId(), "id", "Expected to find module with id = 'id'.");
    assertEquals(modules.get(0).getType(), "maven", "Expected to find module with type = 'maven'.");
}
Also used : BuildInfoMavenBuilder(org.jfrog.build.extractor.builder.BuildInfoMavenBuilder) ModuleBuilder(org.jfrog.build.extractor.builder.ModuleBuilder)

Aggregations

ModuleBuilder (org.jfrog.build.extractor.builder.ModuleBuilder)17 Module (org.jfrog.build.extractor.ci.Module)7 BuildInfo (org.jfrog.build.extractor.ci.BuildInfo)6 IOException (java.io.IOException)3 BuildInfoMavenBuilder (org.jfrog.build.extractor.builder.BuildInfoMavenBuilder)3 ArrayList (java.util.ArrayList)2 BuildInfoExtractorUtils.getModuleIdString (org.jfrog.build.extractor.BuildInfoExtractorUtils.getModuleIdString)2 BuildInfoExtractorUtils.getTypeString (org.jfrog.build.extractor.BuildInfoExtractorUtils.getTypeString)2 BuildInfoBuilder (org.jfrog.build.extractor.builder.BuildInfoBuilder)2 DependencyBuilder (org.jfrog.build.extractor.builder.DependencyBuilder)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 ArtifactBuilder (org.jfrog.build.extractor.builder.ArtifactBuilder)1 Artifact (org.jfrog.build.extractor.ci.Artifact)1 Dependency (org.jfrog.build.extractor.ci.Dependency)1 ArtifactoryClientConfiguration (org.jfrog.build.extractor.clientConfiguration.ArtifactoryClientConfiguration)1 IncludeExcludePatterns (org.jfrog.build.extractor.clientConfiguration.IncludeExcludePatterns)1 ArtifactoryManager (org.jfrog.build.extractor.clientConfiguration.client.artifactory.ArtifactoryManager)1 DeployDetails (org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails)1 ArtifactoryTask (org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask)1