use of org.jfrog.build.extractor.builder.BuildInfoMavenBuilder in project build-info by JFrogDev.
the class BuildInfoModelPropertyResolver method resolveProperties.
public BuildInfoMavenBuilder resolveProperties(ExecutionEvent event, ArtifactoryClientConfiguration clientConf) {
BuildInfoMavenBuilder builder = resolveCoreProperties(event, clientConf).artifactoryPrincipal(clientConf.publisher.getName()).artifactoryPluginVersion(clientConf.info.getArtifactoryPluginVersion()).principal(clientConf.info.getPrincipal()).parentName(clientConf.info.getParentBuildName()).parentNumber(clientConf.info.getParentBuildNumber());
String buildUrl = clientConf.info.getBuildUrl();
if (StringUtils.isNotBlank(buildUrl)) {
builder.url(buildUrl);
}
String vcsRevision = clientConf.info.getVcsRevision();
if (StringUtils.isNotBlank(vcsRevision)) {
builder.vcsRevision(vcsRevision);
}
String vcsUrl = clientConf.info.getVcsUrl();
if (StringUtils.isNotBlank(vcsUrl)) {
builder.vcsUrl(vcsUrl);
}
Vcs vcs = new Vcs(vcsUrl, vcsRevision, clientConf.info.getVcsBranch(), clientConf.info.getVcsMessage());
if (!vcs.isEmpty()) {
builder.vcs(Arrays.asList(vcs));
}
BuildAgent buildAgent = new BuildAgent("Maven", getMavenVersion());
builder.buildAgent(buildAgent);
String agentName = clientConf.info.getAgentName();
if (StringUtils.isBlank(agentName)) {
agentName = buildAgent.getName();
}
String agentVersion = clientConf.info.getAgentVersion();
if (StringUtils.isBlank(agentVersion)) {
agentVersion = buildAgent.getVersion();
}
builder.agent(new Agent(agentName, agentVersion));
attachStagingIfNeeded(clientConf, builder);
builder.artifactoryPrincipal(clientConf.publisher.getName());
builder.artifactoryPluginVersion(clientConf.info.getArtifactoryPluginVersion());
String issueTrackerName = clientConf.info.issues.getIssueTrackerName();
if (StringUtils.isNotBlank(issueTrackerName)) {
Issues issues = new Issues();
issues.setAggregateBuildIssues(clientConf.info.issues.getAggregateBuildIssues());
issues.setAggregationBuildStatus(clientConf.info.issues.getAggregationBuildStatus());
issues.setTracker(new IssueTracker(issueTrackerName, clientConf.info.issues.getIssueTrackerVersion()));
Set<Issue> affectedIssuesSet = clientConf.info.issues.getAffectedIssuesSet();
if (!affectedIssuesSet.isEmpty()) {
issues.setAffectedIssues(affectedIssuesSet);
}
builder.issues(issues);
}
for (Map.Entry<String, String> runParam : clientConf.info.getRunParameters().entrySet()) {
MatrixParameter matrixParameter = new MatrixParameter(runParam.getKey(), runParam.getValue());
builder.addRunParameters(matrixParameter);
}
return builder;
}
use of org.jfrog.build.extractor.builder.BuildInfoMavenBuilder 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.BuildInfoMavenBuilder 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'.");
}
use of org.jfrog.build.extractor.builder.BuildInfoMavenBuilder in project build-info by JFrogDev.
the class BuildInfoMavenBuilderTest method testDuplicateModuleArtifacts.
/**
* Validates adding same artifacts to different modules
*/
public void testDuplicateModuleArtifacts() {
ModuleBuilder module1 = new ModuleBuilder().type(ModuleType.MAVEN).id("id");
module1.addArtifact(new ArtifactBuilder("artifact1").md5(MD5).sha1(SHA1).sha256(SHA2).build());
module1.addArtifact(new ArtifactBuilder("artifact2").md5(MD5).sha1(SHA1).sha256(SHA2).build());
ModuleBuilder module2 = new ModuleBuilder().type(ModuleType.MAVEN).id("id");
module2.addArtifact(new ArtifactBuilder("artifact1").md5(MD5).sha1(SHA1).sha256(SHA2).build());
module2.addArtifact(new ArtifactBuilder("artifact2").md5(MD5).sha1(SHA1).sha256(SHA2).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<Artifact> artifacts = modules.get(0).getArtifacts();
assertEquals(artifacts.size(), 2, "Expected to find only 2 artifacts.");
assertEquals(artifacts.get(0).getName(), "artifact1", "Unexpected artifact name.");
assertEquals(artifacts.get(0).getMd5(), MD5, "Unexpected MD5 checksum.");
assertEquals(artifacts.get(0).getSha1(), SHA1, "Unexpected SHA-1 checksum.");
assertEquals(artifacts.get(0).getSha256(), SHA2, "Unexpected SHA-256 checksum.");
assertEquals(artifacts.get(1).getName(), "artifact2", "Unexpected artifact name.");
assertEquals(artifacts.get(1).getMd5(), MD5, "Unexpected MD5 checksum.");
assertEquals(artifacts.get(1).getSha1(), SHA1, "Unexpected SHA-1 checksum.");
assertEquals(artifacts.get(1).getSha256(), SHA2, "Unexpected SHA-256 checksum.");
}
Aggregations