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();
}
}
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;
}
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();
}
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");
}
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'.");
}
Aggregations