@@ -103,10 +103,6 @@ subprojects {
103
103
* in a branch if there are only betas and rcs in the branch so we have
104
104
* *something* to test against. */
105
105
VersionCollection versions = new VersionCollection (file(' server/src/main/java/org/elasticsearch/Version.java' ). readLines(' UTF-8' ))
106
- if (versions. currentVersion != VersionProperties . elasticsearch) {
107
- throw new GradleException (" The last version in Versions.java [${ versions.currentVersion} ] does not match " +
108
- " VersionProperties.elasticsearch [${ VersionProperties.elasticsearch} ]" )
109
- }
110
106
111
107
// build metadata from previous build, contains eg hashes for bwc builds
112
108
String buildMetadataValue = System . getenv(' BUILD_METADATA' )
@@ -140,26 +136,16 @@ task verifyVersions {
140
136
if (gradle. startParameter. isOffline()) {
141
137
throw new GradleException (" Must run in online mode to verify versions" )
142
138
}
143
- // Read the list from maven central
144
- Node xml
139
+ // Read the list from maven central.
140
+ // Fetch the metadata an parse the xml into Version instances because it's more straight forward here
141
+ // rather than bwcVersion ( VersionCollection ).
145
142
new URL (' https://repo1.maven.org/maven2/org/elasticsearch/elasticsearch/maven-metadata.xml' ). openStream(). withStream { s ->
146
- xml = new XmlParser (). parse(s)
147
- }
148
- Set<Version > knownVersions = new TreeSet<> (xml. versioning. versions. version. collect { it. text() }. findAll { it ==~ / \d +\.\d +\.\d +/ }. collect { Version . fromString(it) })
149
-
150
- // Limit the known versions to those that should be index compatible, and are not future versions
151
- knownVersions = knownVersions. findAll { it. major >= bwcVersions. currentVersion. major - 1 && it. before(VersionProperties . elasticsearch) }
152
-
153
- /* Limit the listed versions to those that have been marked as released.
154
- * Versions not marked as released don't get the same testing and we want
155
- * to make sure that we flip all unreleased versions to released as soon
156
- * as possible after release. */
157
- Set<Version > actualVersions = new TreeSet<> (bwcVersions. indexCompatible. findAll { false == it. snapshot })
158
-
159
- // Finally, compare!
160
- if (knownVersions. equals(actualVersions) == false ) {
161
- throw new GradleException (" out-of-date released versions\n Actual :" + actualVersions + " \n Expected:" + knownVersions +
162
- " \n Update Version.java. Note that Version.CURRENT doesn't count because it is not released." )
143
+ bwcVersions. compareToAuthoritative(
144
+ new XmlParser (). parse(s)
145
+ .versioning. versions. version
146
+ .collect { it. text() }. findAll { it ==~ / \d +\.\d +\.\d +/ }
147
+ .collect { Version . fromString(it) }
148
+ )
163
149
}
164
150
}
165
151
}
@@ -255,20 +241,17 @@ subprojects {
255
241
" org.elasticsearch.plugin:percolator-client:${ version} " : ' :modules:percolator' ,
256
242
" org.elasticsearch.plugin:rank-eval-client:${ version} " : ' :modules:rank-eval' ,
257
243
]
258
-
259
- bwcVersions. snapshotProjectNames. each { snapshotName ->
260
- Version snapshot = bwcVersions. getSnapshotForProject(snapshotName)
261
- if (snapshot != null ) {
262
- String snapshotProject = " :distribution:bwc:${ snapshotName} "
263
- project(snapshotProject). ext. bwcVersion = snapshot
264
- ext. projectSubstitutions[" org.elasticsearch.distribution.deb:elasticsearch:${ snapshot} " ] = snapshotProject
265
- ext. projectSubstitutions[" org.elasticsearch.distribution.rpm:elasticsearch:${ snapshot} " ] = snapshotProject
266
- ext. projectSubstitutions[" org.elasticsearch.distribution.zip:elasticsearch:${ snapshot} " ] = snapshotProject
267
- if (snapshot. onOrAfter(' 6.3.0' )) {
268
- ext. projectSubstitutions[" org.elasticsearch.distribution.deb:elasticsearch-oss:${ snapshot} " ] = snapshotProject
269
- ext. projectSubstitutions[" org.elasticsearch.distribution.rpm:elasticsearch-oss:${ snapshot} " ] = snapshotProject
270
- ext. projectSubstitutions[" org.elasticsearch.distribution.zip:elasticsearch-oss:${ snapshot} " ] = snapshotProject
271
- }
244
+ // substitute unreleased versions with projects that check out and build locally
245
+ bwcVersions. forPreviousUnreleased { VersionCollection.UnreleasedVersionInfo unreleasedVersion ->
246
+ Version unreleased = unreleasedVersion. version
247
+ String snapshotProject = " :distribution:bwc:${ unreleasedVersion.gradleProjectName} "
248
+ ext. projectSubstitutions[" org.elasticsearch.distribution.deb:elasticsearch:${ unreleased} " ] = snapshotProject
249
+ ext. projectSubstitutions[" org.elasticsearch.distribution.rpm:elasticsearch:${ unreleased} " ] = snapshotProject
250
+ ext. projectSubstitutions[" org.elasticsearch.distribution.zip:elasticsearch:${ unreleased} " ] = snapshotProject
251
+ if (unreleased. onOrAfter(' 6.3.0' )) {
252
+ ext. projectSubstitutions[" org.elasticsearch.distribution.deb:elasticsearch-oss:${ unreleased} " ] = snapshotProject
253
+ ext. projectSubstitutions[" org.elasticsearch.distribution.rpm:elasticsearch-oss:${ unreleased} " ] = snapshotProject
254
+ ext. projectSubstitutions[" org.elasticsearch.distribution.zip:elasticsearch-oss:${ unreleased} " ] = snapshotProject
272
255
}
273
256
}
274
257
0 commit comments