@@ -76,7 +76,7 @@ for (String line : versionLines) {
7676 int minor = Integer . parseInt(match. group(2 ))
7777 int bugfix = Integer . parseInt(match. group(3 ))
7878 boolean unreleased = match. group(4 ) != null
79- Version foundVersion = new Version (major, minor, bugfix, false , unreleased)
79+ Version foundVersion = new Version (major, minor, bugfix, unreleased , unreleased)
8080 if (currentVersion != foundVersion) {
8181 versions. add(foundVersion)
8282 }
@@ -112,6 +112,41 @@ allprojects {
112112 }
113113}
114114
115+ task verifyVersions {
116+ doLast {
117+ if (gradle. startParameter. isOffline()) {
118+ throw new GradleException (" Must run in online mode to verify versions" )
119+ }
120+ // Read the list from maven central
121+ Node xml
122+ new URL (' https://repo1.maven.org/maven2/org/elasticsearch/elasticsearch/maven-metadata.xml' ). openStream(). withStream { s ->
123+ xml = new XmlParser (). parse(s)
124+ }
125+ Set<Version > knownVersions = new TreeSet<> (xml. versioning. versions. version. collect { it. text() }. findAll { it ==~ / \d\.\d\.\d / }. collect { Version . fromString(it) })
126+
127+ // Limit the known versions to those that should be index compatible, and are not future versions
128+ knownVersions = knownVersions. findAll { it. major >= 2 && it. before(VersionProperties . elasticsearch) }
129+
130+ /* Limit the listed versions to those that have been marked as released.
131+ * Versions not marked as released don't get the same testing and we want
132+ * to make sure that we flip all unreleased versions to released as soon
133+ * as possible after release. */
134+ Set<Version > actualVersions = new TreeSet<> (indexCompatVersions. findAll { false == it. snapshot })
135+
136+ // Finally, compare!
137+ if (knownVersions. equals(actualVersions) == false ) {
138+ throw new GradleException (" out-of-date released versions\n Actual :" + actualVersions + " \n Expected:" + knownVersions +
139+ " \n Update Version.java. Note that Version.CURRENT doesn't count because it is not released." )
140+ }
141+ }
142+ }
143+
144+ task branchConsistency {
145+ description ' Ensures this branch is internally consistent. For example, that versions constants match released versions.'
146+ group ' Verification'
147+ dependsOn verifyVersions
148+ }
149+
115150subprojects {
116151 project. afterEvaluate {
117152 // include license and notice in jars
0 commit comments