Skip to content

Commit f28cc07

Browse files
committed
Back port build changes from elastic#39102
This back-ports how versions are determined and bwc test are set up from elastic#39102 without enabling the bwc from current version tests so it's easier/possible to backmerge future buld changes. It's expected that the tets are lacking many of the required fixes in this version to enable them.
1 parent 52fd102 commit f28cc07

File tree

8 files changed

+89
-74
lines changed

8 files changed

+89
-74
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ class ClusterFormationTasks {
216216
}
217217
if (unreleasedInfo != null) {
218218
dependency = project.dependencies.project(
219-
path: ":distribution:bwc:${unreleasedInfo.gradleProjectName}", configuration: snapshotProject)
219+
path: unreleasedInfo.gradleProjectPath, configuration: snapshotProject
220+
)
220221
} else if (internalBuild && elasticsearchVersion.equals(VersionProperties.elasticsearch)) {
221222
dependency = project.dependencies.project(path: ":distribution:archives:${snapshotProject}")
222223
} else {

buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,10 @@ class VagrantTestPlugin implements Plugin<Project> {
199199
// handle snapshots pointing to bwc build
200200
UPGRADE_FROM_ARCHIVES.each {
201201
dependencies.add(project.dependencies.project(
202-
path: ":distribution:bwc:${unreleasedInfo.gradleProjectName}", configuration: it))
202+
path: "${unreleasedInfo.gradleProjectPath}", configuration: it))
203203
if (upgradeFromVersion.onOrAfter('6.3.0')) {
204204
dependencies.add(project.dependencies.project(
205-
path: ":distribution:bwc:${unreleasedInfo.gradleProjectName}", configuration: "oss-${it}"))
205+
path: "${unreleasedInfo.gradleProjectPath}", configuration: "oss-${it}"))
206206
}
207207
}
208208
} else {

buildSrc/src/main/java/org/elasticsearch/gradle/VersionCollection.java

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
* <ul>
5858
* <li>the unreleased <b>major</b>, M+1.0.0 on the `master` branch</li>
5959
* <li>the unreleased <b>minor</b>, M.N.0 on the `M.x` (x is literal) branch</li>
60-
* <li>the unreleased <b>bugfix</b>, M.N.c (c &gt; 0) on the `M.b` branch</li>
60+
* <li>the unreleased <b>bugfix</b>, M.N.c (c &gt; 0) on the `M.N` branch</li>
6161
* <li>the unreleased <b>maintenance</b>, M-1.d.e ( d &gt; 0, e &gt; 0) on the `(M-1).d` branch</li>
6262
* </ul>
6363
* In addition to these, there will be a fifth one when a minor reaches feature freeze, we call this the <i>staged</i>
@@ -74,7 +74,7 @@
7474
* We can reliably figure out which the unreleased versions are due to the convention of always adding the next unreleased
7575
* version number to server in all branches when a version is released.
7676
* E.x when M.N.c is released M.N.c+1 is added to the Version class mentioned above in all the following branches:
77-
* `M.b`, `M.x` and `master` so we can reliably assume that the leafs of the version tree are unreleased.
77+
* `M.N`, `M.x` and `master` so we can reliably assume that the leafs of the version tree are unreleased.
7878
* This convention is enforced by checking the versions we consider to be unreleased against an
7979
* authoritative source (maven central).
8080
* We are then able to map the unreleased version to branches in git and Gradle projects that are capable of checking
@@ -93,12 +93,12 @@ public class VersionCollection {
9393
public class UnreleasedVersionInfo {
9494
public final Version version;
9595
public final String branch;
96-
public final String gradleProjectName;
96+
public final String gradleProjectPath;
9797

98-
UnreleasedVersionInfo(Version version, String branch, String gradleProjectName) {
98+
UnreleasedVersionInfo(Version version, String branch, String gradleProjectPath) {
9999
this.version = version;
100100
this.branch = branch;
101-
this.gradleProjectName = gradleProjectName;
101+
this.gradleProjectPath = gradleProjectPath;
102102
}
103103
}
104104

@@ -135,11 +135,8 @@ protected VersionCollection(List<String> versionLines, Version currentVersionPro
135135

136136
Map<Version, UnreleasedVersionInfo> unreleased = new HashMap<>();
137137
for (Version unreleasedVersion : getUnreleased()) {
138-
if (unreleasedVersion.equals(currentVersion)) {
139-
continue;
140-
}
141138
unreleased.put(unreleasedVersion,
142-
new UnreleasedVersionInfo(unreleasedVersion, getBranchFor(unreleasedVersion), getGradleProjectNameFor(unreleasedVersion)));
139+
new UnreleasedVersionInfo(unreleasedVersion, getBranchFor(unreleasedVersion), getGradleProjectPathFor(unreleasedVersion)));
143140
}
144141
this.unreleased = Collections.unmodifiableMap(unreleased);
145142
}
@@ -176,17 +173,19 @@ public void forPreviousUnreleased(Consumer<UnreleasedVersionInfo> consumer) {
176173
.map(version -> new UnreleasedVersionInfo(
177174
version,
178175
getBranchFor(version),
179-
getGradleProjectNameFor(version)
176+
getGradleProjectPathFor(version)
180177
)
181178
)
182179
.collect(Collectors.toList());
183180

184181
collect.forEach(uvi -> consumer.accept(uvi));
185182
}
186183

187-
private String getGradleProjectNameFor(Version version) {
184+
private String getGradleProjectPathFor(Version version) {
185+
// We have Gradle projects set up to check out and build unreleased versions based on the our branching
186+
// conventions described in this classes javadoc
188187
if (version.equals(currentVersion)) {
189-
throw new IllegalArgumentException("The Gradle project to build " + version + " is the current build.");
188+
return ":distribution";
190189
}
191190

192191
Map<Integer, List<Version>> releasedMajorGroupedByMinor = getReleasedMajorGroupedByMinor();
@@ -197,27 +196,33 @@ private String getGradleProjectNameFor(Version version) {
197196
.collect(Collectors.toList());
198197
if (unreleasedStagedOrMinor.size() > 2) {
199198
if (unreleasedStagedOrMinor.get(unreleasedStagedOrMinor.size() - 2).equals(version)) {
200-
return "minor";
199+
return ":distribution:bwc:minor";
201200
} else{
202-
return "staged";
201+
return ":distribution:bwc:staged";
203202
}
204203
} else {
205-
return "minor";
204+
return ":distribution:bwc:minor";
206205
}
207206
} else {
208207
if (releasedMajorGroupedByMinor
209208
.getOrDefault(version.getMinor(), emptyList())
210209
.contains(version)) {
211-
return "bugfix";
210+
return ":distribution:bwc:bugfix";
212211
} else {
213-
return "maintenance";
212+
return ":distribution:bwc:maintenance";
214213
}
215214
}
216215
}
217216

218217
private String getBranchFor(Version version) {
219-
switch (getGradleProjectNameFor(version)) {
220-
case "minor":
218+
// based on the rules described in this classes javadoc, figure out the branch on which an unreleased version
219+
// lives.
220+
// We do this based on the Gradle project path because there's a direct correlation, so we dont have to duplicate
221+
// the logic from there
222+
switch (getGradleProjectPathFor(version)) {
223+
case ":distribution":
224+
return "master";
225+
case ":distribution:bwc:minor":
221226
// The .x branch will always point to the latest minor (for that major), so a "minor" project will be on the .x branch
222227
// unless there is more recent (higher) minor.
223228
final Version latestInMajor = getLatestVersionByKey(groupByMajor, version.getMajor());
@@ -226,9 +231,9 @@ private String getBranchFor(Version version) {
226231
} else {
227232
return version.getMajor() + "." + version.getMinor();
228233
}
229-
case "staged":
230-
case "maintenance":
231-
case "bugfix":
234+
case ":distribution:bwc:staged":
235+
case ":distribution:bwc:maintenance":
236+
case ":distribution:bwc:bugfix":
232237
return version.getMajor() + "." + version.getMinor();
233238
default:
234239
throw new IllegalStateException("Unexpected Gradle project name");
@@ -237,6 +242,7 @@ private String getBranchFor(Version version) {
237242

238243
public List<Version> getUnreleased() {
239244
List<Version> unreleased = new ArrayList<>();
245+
240246
// The current version is being worked, is always unreleased
241247
unreleased.add(currentVersion);
242248

@@ -345,6 +351,7 @@ public List<Version> getIndexCompatible() {
345351
.filter(version -> version.equals(currentVersion) == false)
346352
.collect(Collectors.toList())
347353
);
354+
348355
}
349356

350357
public List<Version> getWireCompatible() {

buildSrc/src/test/java/org/elasticsearch/gradle/VersionCollectionTests.java

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -110,24 +110,24 @@ public void testExceptionOnTooManyMajors() {
110110

111111
public void testWireCompatible() {
112112
assertVersionsEquals(
113-
singletonList("6.5.0-SNAPSHOT"),
113+
asList("6.5.0"),
114114
getVersionCollection("7.0.0-alpha1").getWireCompatible()
115115
);
116116
assertVersionsEquals(
117117
asList(
118118
"5.6.0", "5.6.1", "5.6.2", "5.6.3", "5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10",
119-
"5.6.11", "5.6.12", "5.6.13-SNAPSHOT",
119+
"5.6.11", "5.6.12", "5.6.13",
120120
"6.0.0", "6.0.1", "6.1.0", "6.1.1", "6.1.2", "6.1.3", "6.1.4",
121121
"6.2.0", "6.2.1", "6.2.2", "6.2.3", "6.2.4",
122-
"6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2-SNAPSHOT"
122+
"6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2"
123123
),
124124
getVersionCollection("6.5.0").getWireCompatible()
125125
);
126126

127127
assertVersionsEquals(
128128
asList(
129129
"5.6.0", "5.6.1", "5.6.2", "5.6.3", "5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10",
130-
"5.6.11", "5.6.12", "5.6.13-SNAPSHOT", "6.0.0", "6.0.1", "6.1.0", "6.1.1", "6.1.2", "6.1.3", "6.1.4",
130+
"5.6.11", "5.6.12", "5.6.13", "6.0.0", "6.0.1", "6.1.0", "6.1.1", "6.1.2", "6.1.3", "6.1.4",
131131
"6.2.0", "6.2.1", "6.2.2", "6.2.3", "6.2.4", "6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1"
132132
),
133133
getVersionCollection("6.4.2").getWireCompatible()
@@ -136,16 +136,16 @@ public void testWireCompatible() {
136136
assertVersionsEquals(
137137
asList(
138138
"5.6.0", "5.6.1", "5.6.2", "5.6.3", "5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10",
139-
"5.6.11", "5.6.12", "5.6.13-SNAPSHOT",
139+
"5.6.11", "5.6.12", "5.6.13",
140140
"6.0.0", "6.0.1", "6.1.0", "6.1.1", "6.1.2", "6.1.3", "6.1.4",
141141
"6.2.0", "6.2.1", "6.2.2", "6.2.3", "6.2.4",
142-
"6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2-SNAPSHOT", "6.5.0-SNAPSHOT"
142+
"6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2", "6.5.0"
143143
),
144144
getVersionCollection("6.6.0").getWireCompatible()
145145
);
146146

147147
assertVersionsEquals(
148-
singletonList("7.3.0"),
148+
asList("7.3.0"),
149149
getVersionCollection("8.0.0").getWireCompatible()
150150
);
151151
assertVersionsEquals(
@@ -157,26 +157,26 @@ public void testWireCompatible() {
157157

158158
public void testWireCompatibleUnreleased() {
159159
assertVersionsEquals(
160-
singletonList("6.5.0-SNAPSHOT"),
160+
asList("6.5.0"),
161161
getVersionCollection("7.0.0-alpha1").getUnreleasedWireCompatible()
162162
);
163163
assertVersionsEquals(
164-
asList("5.6.13-SNAPSHOT", "6.4.2-SNAPSHOT"),
164+
asList("5.6.13", "6.4.2"),
165165
getVersionCollection("6.5.0").getUnreleasedWireCompatible()
166166
);
167167

168168
assertVersionsEquals(
169-
singletonList("5.6.13-SNAPSHOT"),
169+
asList("5.6.13"),
170170
getVersionCollection("6.4.2").getUnreleasedWireCompatible()
171171
);
172172

173173
assertVersionsEquals(
174-
asList("5.6.13-SNAPSHOT", "6.4.2-SNAPSHOT", "6.5.0-SNAPSHOT"),
174+
asList("5.6.13", "6.4.2", "6.5.0"),
175175
getVersionCollection("6.6.0").getUnreleasedWireCompatible()
176176
);
177177

178178
assertVersionsEquals(
179-
singletonList("7.3.0"),
179+
asList("7.3.0"),
180180
getVersionCollection("8.0.0").getUnreleasedWireCompatible()
181181
);
182182
assertVersionsEquals(
@@ -190,7 +190,7 @@ public void testIndexCompatible() {
190190
asList(
191191
"6.0.0", "6.0.1", "6.1.0", "6.1.1", "6.1.2", "6.1.3", "6.1.4",
192192
"6.2.0", "6.2.1", "6.2.2", "6.2.3", "6.2.4", "6.3.0", "6.3.1",
193-
"6.3.2", "6.4.0", "6.4.1", "6.4.2-SNAPSHOT", "6.5.0-SNAPSHOT"
193+
"6.3.2", "6.4.0", "6.4.1", "6.4.2", "6.5.0"
194194
),
195195
getVersionCollection("7.0.0-alpha1").getIndexCompatible()
196196
);
@@ -199,9 +199,9 @@ public void testIndexCompatible() {
199199
asList(
200200
"5.0.0", "5.0.1", "5.0.2", "5.1.1", "5.1.2", "5.2.0", "5.2.1", "5.2.2", "5.3.0", "5.3.1", "5.3.2", "5.3.3",
201201
"5.4.0", "5.4.1", "5.4.2", "5.4.3", "5.5.0", "5.5.1", "5.5.2", "5.5.3", "5.6.0", "5.6.1", "5.6.2", "5.6.3",
202-
"5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10", "5.6.11", "5.6.12", "5.6.13-SNAPSHOT",
202+
"5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10", "5.6.11", "5.6.12", "5.6.13",
203203
"6.0.0", "6.0.1", "6.1.0", "6.1.1", "6.1.2", "6.1.3", "6.1.4", "6.2.0", "6.2.1", "6.2.2", "6.2.3", "6.2.4",
204-
"6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2-SNAPSHOT"
204+
"6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2"
205205
),
206206
getVersionCollection("6.5.0").getIndexCompatible()
207207
);
@@ -210,7 +210,7 @@ public void testIndexCompatible() {
210210
asList(
211211
"5.0.0", "5.0.1", "5.0.2", "5.1.1", "5.1.2", "5.2.0", "5.2.1", "5.2.2", "5.3.0", "5.3.1", "5.3.2", "5.3.3",
212212
"5.4.0", "5.4.1", "5.4.2", "5.4.3", "5.5.0", "5.5.1", "5.5.2", "5.5.3", "5.6.0", "5.6.1", "5.6.2", "5.6.3",
213-
"5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10", "5.6.11", "5.6.12", "5.6.13-SNAPSHOT",
213+
"5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10", "5.6.11", "5.6.12", "5.6.13",
214214
"6.0.0", "6.0.1", "6.1.0", "6.1.1", "6.1.2", "6.1.3", "6.1.4", "6.2.0", "6.2.1", "6.2.2", "6.2.3", "6.2.4",
215215
"6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1"
216216
),
@@ -221,9 +221,9 @@ public void testIndexCompatible() {
221221
asList(
222222
"5.0.0", "5.0.1", "5.0.2", "5.1.1", "5.1.2", "5.2.0", "5.2.1", "5.2.2", "5.3.0", "5.3.1", "5.3.2", "5.3.3",
223223
"5.4.0", "5.4.1", "5.4.2", "5.4.3", "5.5.0", "5.5.1", "5.5.2", "5.5.3", "5.6.0", "5.6.1", "5.6.2", "5.6.3",
224-
"5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10", "5.6.11", "5.6.12", "5.6.13-SNAPSHOT",
224+
"5.6.4", "5.6.5", "5.6.6", "5.6.7", "5.6.8", "5.6.9", "5.6.10", "5.6.11", "5.6.12", "5.6.13",
225225
"6.0.0", "6.0.1", "6.1.0", "6.1.1", "6.1.2", "6.1.3", "6.1.4", "6.2.0", "6.2.1", "6.2.2", "6.2.3", "6.2.4",
226-
"6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2-SNAPSHOT", "6.5.0-SNAPSHOT"
226+
"6.3.0", "6.3.1", "6.3.2", "6.4.0", "6.4.1", "6.4.2", "6.5.0"
227227
),
228228
getVersionCollection("6.6.0").getIndexCompatible()
229229
);
@@ -236,22 +236,22 @@ public void testIndexCompatible() {
236236

237237
public void testIndexCompatibleUnreleased() {
238238
assertVersionsEquals(
239-
asList("6.4.2-SNAPSHOT", "6.5.0-SNAPSHOT"),
239+
asList("6.4.2", "6.5.0"),
240240
getVersionCollection("7.0.0-alpha1").getUnreleasedIndexCompatible()
241241
);
242242

243243
assertVersionsEquals(
244-
asList("5.6.13-SNAPSHOT", "6.4.2-SNAPSHOT"),
244+
asList("5.6.13", "6.4.2"),
245245
getVersionCollection("6.5.0").getUnreleasedIndexCompatible()
246246
);
247247

248248
assertVersionsEquals(
249-
singletonList("5.6.13-SNAPSHOT"),
249+
asList("5.6.13"),
250250
getVersionCollection("6.4.2").getUnreleasedIndexCompatible()
251251
);
252252

253253
assertVersionsEquals(
254-
asList("5.6.13-SNAPSHOT", "6.4.2-SNAPSHOT", "6.5.0-SNAPSHOT"),
254+
asList("5.6.13", "6.4.2", "6.5.0"),
255255
getVersionCollection("6.6.0").getUnreleasedIndexCompatible()
256256
);
257257

@@ -315,29 +315,29 @@ public void testGetBranch() {
315315
);
316316
}
317317

318-
public void testGetGradleProjectName() {
319-
assertUnreleasedGradleProjectNames(
320-
asList("bugfix", "minor"),
318+
public void testGetGradleProjectPath() {
319+
assertUnreleasedGradleProjectPaths(
320+
asList(":distribution:bwc:bugfix", ":distribution:bwc:minor"),
321321
getVersionCollection("7.0.0-alpha1")
322322
);
323-
assertUnreleasedGradleProjectNames(
324-
asList("maintenance", "bugfix"),
323+
assertUnreleasedGradleProjectPaths(
324+
asList(":distribution:bwc:maintenance", ":distribution:bwc:bugfix"),
325325
getVersionCollection("6.5.0")
326326
);
327-
assertUnreleasedGradleProjectNames(
328-
singletonList("maintenance"),
327+
assertUnreleasedGradleProjectPaths(
328+
singletonList(":distribution:bwc:maintenance"),
329329
getVersionCollection("6.4.2")
330330
);
331-
assertUnreleasedGradleProjectNames(
332-
asList("maintenance", "bugfix", "minor"),
331+
assertUnreleasedGradleProjectPaths(
332+
asList(":distribution:bwc:maintenance", ":distribution:bwc:bugfix", ":distribution:bwc:minor"),
333333
getVersionCollection("6.6.0")
334334
);
335-
assertUnreleasedGradleProjectNames(
336-
asList("bugfix", "staged", "minor"),
335+
assertUnreleasedGradleProjectPaths(
336+
asList(":distribution:bwc:bugfix", ":distribution:bwc:staged", ":distribution:bwc:minor"),
337337
getVersionCollection("8.0.0")
338338
);
339-
assertUnreleasedGradleProjectNames(
340-
asList("maintenance", "staged", "minor"),
339+
assertUnreleasedGradleProjectPaths(
340+
asList(":distribution:bwc:maintenance", ":distribution:bwc:staged", ":distribution:bwc:minor"),
341341
getVersionCollection("7.1.0")
342342
);
343343
}
@@ -390,10 +390,10 @@ public void testCompareToAuthoritativeNotReallyRelesed() {
390390
vc.compareToAuthoritative(authoritativeReleasedVersions);
391391
}
392392

393-
private void assertUnreleasedGradleProjectNames(List<String> expectedNAmes, VersionCollection versionCollection) {
393+
private void assertUnreleasedGradleProjectPaths(List<String> expectedNAmes, VersionCollection versionCollection) {
394394
List<String> actualNames = new ArrayList<>();
395395
versionCollection.forPreviousUnreleased(unreleasedVersion ->
396-
actualNames.add(unreleasedVersion.gradleProjectName)
396+
actualNames.add(unreleasedVersion.gradleProjectPath)
397397
);
398398
assertEquals(expectedNAmes, actualNames);
399399
}

distribution/build.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,3 +516,16 @@ subprojects {
516516
}
517517
}
518518
}
519+
520+
['archives:windows-zip','archives:oss-windows-zip',
521+
'archives:darwin-tar','archives:oss-darwin-tar',
522+
'archives:linux-tar', 'archives:oss-linux-tar',
523+
'packages:rpm', 'packages:deb',
524+
'packages:oss-rpm', 'packages:oss-deb',
525+
].forEach { subName ->
526+
Project subproject = project("${project.path}:${subName}")
527+
Configuration configuration = configurations.create(subproject.name)
528+
dependencies {
529+
"${configuration.name}" project(subproject.path)
530+
}
531+
}

distribution/bwc/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import static org.elasticsearch.gradle.BuildPlugin.getJavaHome
3333
* unreleased versions are when Gradle projects are set up, so we use "build-unreleased-version-*" as placeholders
3434
* and configure them to build various versions here.
3535
*/
36-
bwcVersions.forPreviousUnreleased { VersionCollection.UnreleasedVersionInfo unreleasedVersion -> project("${project.path}:${unreleasedVersion.gradleProjectName}") {
36+
bwcVersions.forPreviousUnreleased { VersionCollection.UnreleasedVersionInfo unreleasedVersion -> project("${unreleasedVersion.gradleProjectPath}") {
3737
Version bwcVersion = unreleasedVersion.version
3838
String bwcBranch = unreleasedVersion.branch
3939
apply plugin: 'distribution'

0 commit comments

Comments
 (0)