Skip to content

Commit 811a244

Browse files
authored
BI-538 - Schema changes for aggregated builds (#398)
1 parent f71c163 commit 811a244

File tree

51 files changed

+529
-284
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+529
-284
lines changed

build-info-api/src/main/java/org/jfrog/build/api/Build.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -308,14 +308,16 @@ public void setArtifactoryPrincipal(String artifactoryPrincipal) {
308308
*
309309
* @return Artifactory plugin version
310310
*/
311-
public String getArtifactoryPluginVersion() {return artifactoryPluginVersion;}
311+
public String getArtifactoryPluginVersion() {
312+
return artifactoryPluginVersion;
313+
}
312314

313315
/**
314316
* Sets the Artifactory plugin version of the build
315317
*
316318
* @param artifactoryPluginVersion Artifactory plugin version
317319
*/
318-
public void setArtifactoryPluginVersion (String artifactoryPluginVersion){
320+
public void setArtifactoryPluginVersion(String artifactoryPluginVersion) {
319321
this.artifactoryPluginVersion = artifactoryPluginVersion;
320322
}
321323

@@ -559,7 +561,7 @@ public String toString() {
559561
", durationMillis=" + durationMillis +
560562
", principal='" + principal + '\'' +
561563
", artifactoryPrincipal='" + artifactoryPrincipal + '\'' +
562-
", artifactoryPluginVersion='" + artifactoryPluginVersion + '\''+
564+
", artifactoryPluginVersion='" + artifactoryPluginVersion + '\'' +
563565
", url='" + url + '\'' +
564566
", parentName='" + parentName + '\'' +
565567
", parentNumber='" + parentNumber + '\'' +

build-info-api/src/main/java/org/jfrog/build/api/Module.java

+102-18
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717
package org.jfrog.build.api;
1818

1919
import com.thoughtworks.xstream.annotations.XStreamAlias;
20+
import org.apache.commons.lang.ArrayUtils;
21+
import org.apache.commons.lang.StringUtils;
2022

21-
import java.util.Collection;
22-
import java.util.Collections;
23-
import java.util.List;
24-
import java.util.Optional;
23+
import java.util.*;
2524
import java.util.stream.Collectors;
2625
import java.util.stream.Stream;
2726

@@ -35,8 +34,16 @@
3534
@XStreamAlias(MODULE)
3635
public class Module extends BaseBuildBean {
3736

37+
private String type;
38+
3839
private String id;
3940

41+
private String repository;
42+
43+
private String md5;
44+
45+
private String sha1;
46+
4047
@XStreamAlias(ARTIFACTS)
4148
private List<Artifact> artifacts;
4249

@@ -46,6 +53,24 @@ public class Module extends BaseBuildBean {
4653
@XStreamAlias(DEPENDENCIES)
4754
private List<Dependency> dependencies;
4855

56+
/**
57+
* Returns the type of the module
58+
*
59+
* @return Module type
60+
*/
61+
public String getType() {
62+
return type;
63+
}
64+
65+
/**
66+
* Sets the type of the module
67+
*
68+
* @param type Module type
69+
*/
70+
public void setType(String type) {
71+
this.type = type;
72+
}
73+
4974
/**
5075
* Returns the ID of the module
5176
*
@@ -64,6 +89,60 @@ public void setId(String id) {
6489
this.id = id;
6590
}
6691

92+
/**
93+
* Sets the repository of the module
94+
*
95+
* @param repository Module repository
96+
*/
97+
public void setRepository(String repository) {
98+
this.repository = repository;
99+
}
100+
101+
/**
102+
* Returns the repository of the module
103+
*
104+
* @return Module repository
105+
*/
106+
public String getRepository() {
107+
return repository;
108+
}
109+
110+
/**
111+
* Sets the sha1 of the module
112+
*
113+
* @param sha1 Module sha1
114+
*/
115+
public void setSha1(String sha1) {
116+
this.sha1 = sha1;
117+
}
118+
119+
/**
120+
* Returns the sha1 of the module
121+
*
122+
* @return Module sha1
123+
*/
124+
public String getSha1() {
125+
return sha1;
126+
}
127+
128+
/**
129+
* Sets the md5 of the module
130+
*
131+
* @param md5 Module md5
132+
*/
133+
public void setMd5(String md5) {
134+
this.md5 = md5;
135+
}
136+
137+
/**
138+
* Returns the md5 of the module
139+
*
140+
* @return Module md5
141+
*/
142+
public String getMd5() {
143+
return md5;
144+
}
145+
67146
/**
68147
* Returns the list of artifacts that have been deployed by the module
69148
*
@@ -127,6 +206,10 @@ public void append(Module other) {
127206
artifacts = appendBuildFileLists(artifacts, other.getArtifacts());
128207
excludedArtifacts = appendBuildFileLists(excludedArtifacts, other.getExcludedArtifacts());
129208
dependencies = appendBuildFileLists(dependencies, other.getDependencies());
209+
type = StringUtils.defaultIfEmpty(type, other.type);
210+
repository = StringUtils.defaultIfEmpty(repository, other.repository);
211+
md5 = StringUtils.defaultIfEmpty(md5, other.md5);
212+
sha1 = StringUtils.defaultIfEmpty(sha1, other.sha1);
130213
}
131214

132215
private <T extends BaseBuildBean> List<T> appendBuildFileLists(List<T> a, List<T> b) {
@@ -141,26 +224,27 @@ private <T extends BaseBuildBean> List<T> appendBuildFileLists(List<T> a, List<T
141224

142225
@Override
143226
public boolean equals(Object o) {
144-
if (this == o) return true;
145-
if (o == null || getClass() != o.getClass()) return false;
227+
if (this == o) {
228+
return true;
229+
}
230+
if (o == null || getClass() != o.getClass()) {
231+
return false;
232+
}
146233

147234
Module module = (Module) o;
148235

149-
if (getId() != null ? !getId().equals(module.getId()) : module.getId() != null) return false;
150-
if (getArtifacts() != null ? !getArtifacts().equals(module.getArtifacts()) : module.getArtifacts() != null)
151-
return false;
152-
if (getExcludedArtifacts() != null ? !getExcludedArtifacts().equals(module.getExcludedArtifacts()) : module.getExcludedArtifacts() != null)
153-
return false;
154-
return getDependencies() != null ? getDependencies().equals(module.getDependencies()) : module.getDependencies() == null;
155-
236+
return StringUtils.equals(getType(), module.getType()) &&
237+
StringUtils.equals(getId(), module.getId()) &&
238+
StringUtils.equals(getRepository(), module.getRepository()) &&
239+
StringUtils.equals(getSha1(), module.getSha1()) &&
240+
StringUtils.equals(getMd5(), module.getMd5()) &&
241+
ArrayUtils.isEquals(getArtifacts(), module.getArtifacts()) &&
242+
ArrayUtils.isEquals(getExcludedArtifacts(), module.getExcludedArtifacts()) &&
243+
ArrayUtils.isEquals(getDependencies(), module.getDependencies());
156244
}
157245

158246
@Override
159247
public int hashCode() {
160-
int result = getId() != null ? getId().hashCode() : 0;
161-
result = 31 * result + (getArtifacts() != null ? getArtifacts().hashCode() : 0);
162-
result = 31 * result + (getExcludedArtifacts() != null ? getExcludedArtifacts().hashCode() : 0);
163-
result = 31 * result + (getDependencies() != null ? getDependencies().hashCode() : 0);
164-
return result;
248+
return Objects.hash(getType(), getId(), getRepository(), getSha1(), getMd5(), getArtifacts(), getExcludedArtifacts(), getDependencies());
165249
}
166250
}

build-info-api/src/main/java/org/jfrog/build/api/builder/BuildInfoBuilder.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public BuildInfoBuilder artifactoryPrincipal(String artifactoryPrincipal) {
218218
return this;
219219
}
220220

221-
public BuildInfoBuilder artifactoryPluginVersion(String artifactoryPluginVersion){
221+
public BuildInfoBuilder artifactoryPluginVersion(String artifactoryPluginVersion) {
222222
this.artifactoryPluginVersion = artifactoryPluginVersion;
223223
return this;
224224
}
@@ -309,7 +309,7 @@ public BuildInfoBuilder modules(ConcurrentHashMap<String, Module> modules) {
309309
*/
310310
public BuildInfoBuilder modules(List<Module> modules) {
311311
ConcurrentHashMap<String, Module> modulesMap = new ConcurrentHashMap<String, Module>();
312-
for(Module module : modules) {
312+
for (Module module : modules) {
313313
modulesMap.put(module.getId(), module);
314314
}
315315

@@ -386,7 +386,7 @@ public BuildInfoBuilder addRunParameters(MatrixParameter parameter) {
386386
*/
387387
public BuildInfoBuilder addModule(Module module) {
388388
if (modules == null) {
389-
synchronized(this) {
389+
synchronized (this) {
390390
if (modules == null) {
391391
modules = new ConcurrentHashMap<String, Module>();
392392
}

build-info-api/src/main/java/org/jfrog/build/api/builder/BuildInfoMavenBuilder.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,11 @@ public BuildInfoMavenBuilder artifactoryPrincipal(String artifactoryPrincipal) {
160160

161161
/**
162162
* Sets the Artifactory plugin version of the build
163+
*
163164
* @param artifactoryPluginVersion Build Artifactory plugin version
164165
* @return Builder instance
165166
*/
166-
public BuildInfoMavenBuilder artifactoryPluginVersion(String artifactoryPluginVersion){
167+
public BuildInfoMavenBuilder artifactoryPluginVersion(String artifactoryPluginVersion) {
167168
super.artifactoryPluginVersion(artifactoryPluginVersion);
168169
return this;
169170
}

build-info-api/src/main/java/org/jfrog/build/api/builder/ModuleBuilder.java

+54
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@
3131
*/
3232
public class ModuleBuilder {
3333

34+
private ModuleType type;
3435
private String id;
36+
private String repository;
37+
private String sha1;
38+
private String md5;
3539
private List<Artifact> artifacts;
3640
private List<Artifact> excludedArtifacts;
3741
private List<Dependency> dependencies;
@@ -47,14 +51,31 @@ public Module build() {
4751
throw new IllegalArgumentException("Cannot build module entity without Module ID value");
4852
}
4953
Module module = new Module();
54+
if (type != null) {
55+
module.setType(type.name().toLowerCase());
56+
}
5057
module.setId(id.trim());
58+
module.setRepository(repository);
59+
module.setSha1(sha1);
60+
module.setMd5(md5);
5161
module.setArtifacts(artifacts);
5262
module.setDependencies(dependencies);
5363
module.setProperties(properties);
5464
module.setExcludedArtifacts(excludedArtifacts);
5565
return module;
5666
}
5767

68+
/**
69+
* Sets the type of the module
70+
*
71+
* @param type Module type
72+
* @return Builder instance
73+
*/
74+
public ModuleBuilder type(ModuleType type) {
75+
this.type = type;
76+
return this;
77+
}
78+
5879
/**
5980
* Sets the ID of the module
6081
*
@@ -66,6 +87,39 @@ public ModuleBuilder id(String id) {
6687
return this;
6788
}
6889

90+
/**
91+
* Sets the repository of the module
92+
*
93+
* @param repository Module repository
94+
* @return Builder instance
95+
*/
96+
public ModuleBuilder repository(String repository) {
97+
this.repository = repository;
98+
return this;
99+
}
100+
101+
/**
102+
* Sets sha1 of the module
103+
*
104+
* @param sha1 Module sha1
105+
* @return Builder instance
106+
*/
107+
public ModuleBuilder sha1(String sha1) {
108+
this.sha1 = sha1;
109+
return this;
110+
}
111+
112+
/**
113+
* Sets md5 of the module
114+
*
115+
* @param md5 Module md5
116+
* @return Builder instance
117+
*/
118+
public ModuleBuilder md5(String md5) {
119+
this.md5 = md5;
120+
return this;
121+
}
122+
69123
/**
70124
* Sets the list of artifacts that have been deployed by the module
71125
*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package org.jfrog.build.api.builder;
2+
3+
/**
4+
* @author yahavi
5+
*/
6+
public enum ModuleType {
7+
BUILD, GENERIC, MAVEN, GRADLE, IVY, DOCKER, NPM, NUGET, GO, PYPI
8+
}

build-info-api/src/main/java/org/jfrog/build/api/builder/PromotionBuilder.java

+1-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@
44
import org.jfrog.build.api.release.Promotion;
55

66
import java.text.SimpleDateFormat;
7-
import java.util.Collection;
8-
import java.util.Date;
9-
import java.util.HashMap;
10-
import java.util.HashSet;
11-
import java.util.Map;
12-
import java.util.Set;
7+
import java.util.*;
138

149
/**
1510
* @author Noam Y. Tenne

build-info-api/src/main/java/org/jfrog/build/api/builder/dependency/BuildPatternArtifactsRequestBuilder.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@
2929
public class BuildPatternArtifactsRequestBuilder {
3030

3131
private String buildName;
32-
private String buildNumber;
33-
private boolean transitive;
34-
private List<Pattern> patterns;
32+
private String buildNumber;
33+
private boolean transitive;
34+
private List<Pattern> patterns;
3535

3636
public BuildPatternArtifactsRequestBuilder() {
3737
patterns = new ArrayList<>();
3838
}
3939

40-
public BuildPatternArtifactsRequest build(){
40+
public BuildPatternArtifactsRequest build() {
4141
if (buildName == null) {
4242
throw new IllegalArgumentException("BuildPatternArtifactsRequest must have a build name.");
4343
}
@@ -51,18 +51,18 @@ public BuildPatternArtifactsRequest build(){
5151
return request;
5252
}
5353

54-
public BuildPatternArtifactsRequestBuilder buildName(String buildName){
54+
public BuildPatternArtifactsRequestBuilder buildName(String buildName) {
5555
this.buildName = buildName;
5656
return this;
5757
}
5858

59-
public BuildPatternArtifactsRequestBuilder buildNumber(String buildNumber){
59+
public BuildPatternArtifactsRequestBuilder buildNumber(String buildNumber) {
6060
this.buildNumber = buildNumber;
6161
return this;
6262
}
6363
//no support for transitivity
6464

65-
public BuildPatternArtifactsRequestBuilder pattern(String pattern){
65+
public BuildPatternArtifactsRequestBuilder pattern(String pattern) {
6666
patterns.add(new Pattern(pattern));
6767
return this;
6868
}

0 commit comments

Comments
 (0)