@@ -103,10 +103,6 @@ subprojects {
103103 * in a branch if there are only betas and rcs in the branch so we have
104104 * *something* to test against. */
105105VersionCollection 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- }
110106
111107// build metadata from previous build, contains eg hashes for bwc builds
112108String buildMetadataValue = System . getenv(' BUILD_METADATA' )
@@ -140,26 +136,16 @@ task verifyVersions {
140136 if (gradle. startParameter. isOffline()) {
141137 throw new GradleException (" Must run in online mode to verify versions" )
142138 }
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 ).
145142 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+ )
163149 }
164150 }
165151}
@@ -251,20 +237,17 @@ subprojects {
251237 " org.elasticsearch.plugin:percolator-client:${ version} " : ' :modules:percolator' ,
252238 " org.elasticsearch.plugin:rank-eval-client:${ version} " : ' :modules:rank-eval' ,
253239 ]
254-
255- bwcVersions. snapshotProjectNames. each { snapshotName ->
256- Version snapshot = bwcVersions. getSnapshotForProject(snapshotName)
257- if (snapshot != null ) {
258- String snapshotProject = " :distribution:bwc:${ snapshotName} "
259- project(snapshotProject). ext. bwcVersion = snapshot
260- ext. projectSubstitutions[" org.elasticsearch.distribution.deb:elasticsearch:${ snapshot} " ] = snapshotProject
261- ext. projectSubstitutions[" org.elasticsearch.distribution.rpm:elasticsearch:${ snapshot} " ] = snapshotProject
262- ext. projectSubstitutions[" org.elasticsearch.distribution.zip:elasticsearch:${ snapshot} " ] = snapshotProject
263- if (snapshot. onOrAfter(' 6.3.0' )) {
264- ext. projectSubstitutions[" org.elasticsearch.distribution.deb:elasticsearch-oss:${ snapshot} " ] = snapshotProject
265- ext. projectSubstitutions[" org.elasticsearch.distribution.rpm:elasticsearch-oss:${ snapshot} " ] = snapshotProject
266- ext. projectSubstitutions[" org.elasticsearch.distribution.zip:elasticsearch-oss:${ snapshot} " ] = snapshotProject
267- }
240+ // substitute unreleased versions with projects that check out and build locally
241+ bwcVersions. forPreviousUnreleased { VersionCollection.UnreleasedVersionInfo unreleasedVersion ->
242+ Version unreleased = unreleasedVersion. version
243+ String snapshotProject = " :distribution:bwc:${ unreleasedVersion.gradleProjectName} "
244+ ext. projectSubstitutions[" org.elasticsearch.distribution.deb:elasticsearch:${ unreleased} " ] = snapshotProject
245+ ext. projectSubstitutions[" org.elasticsearch.distribution.rpm:elasticsearch:${ unreleased} " ] = snapshotProject
246+ ext. projectSubstitutions[" org.elasticsearch.distribution.zip:elasticsearch:${ unreleased} " ] = snapshotProject
247+ if (unreleased. onOrAfter(' 6.3.0' )) {
248+ ext. projectSubstitutions[" org.elasticsearch.distribution.deb:elasticsearch-oss:${ unreleased} " ] = snapshotProject
249+ ext. projectSubstitutions[" org.elasticsearch.distribution.rpm:elasticsearch-oss:${ unreleased} " ] = snapshotProject
250+ ext. projectSubstitutions[" org.elasticsearch.distribution.zip:elasticsearch-oss:${ unreleased} " ] = snapshotProject
268251 }
269252 }
270253
0 commit comments