17
17
* under the License.
18
18
*/
19
19
20
- import java.nio.file.Path
21
- import java.util.regex.Matcher
22
- import org.eclipse.jgit.lib.Repository
23
- import org.eclipse.jgit.lib.RepositoryBuilder
24
- import org.gradle.plugins.ide.eclipse.model.SourceFolder
20
+
25
21
import org.apache.tools.ant.taskdefs.condition.Os
26
22
import org.elasticsearch.gradle.BuildPlugin
27
- import org.elasticsearch.gradle.VersionProperties
28
23
import org.elasticsearch.gradle.Version
24
+ import org.elasticsearch.gradle.VersionCollection
25
+ import org.elasticsearch.gradle.VersionProperties
26
+ import org.gradle.plugins.ide.eclipse.model.SourceFolder
27
+
28
+ import java.nio.file.Path
29
29
30
30
// common maven publishing configuration
31
31
subprojects {
@@ -67,72 +67,16 @@ configure(subprojects.findAll { it.projectDir.toPath().startsWith(rootPath) }) {
67
67
}
68
68
}
69
69
70
- /* Introspect all versions of ES that may be tested agains for backwards
70
+ /* Introspect all versions of ES that may be tested against for backwards
71
71
* compatibility. It is *super* important that this logic is the same as the
72
72
* logic in VersionUtils.java, throwing out alphas because they don't have any
73
73
* backwards compatibility guarantees and only keeping the latest beta or rc
74
74
* in a branch if there are only betas and rcs in the branch so we have
75
75
* *something* to test against. */
76
- Version currentVersion = Version . fromString(VersionProperties . elasticsearch. minus(' -SNAPSHOT' ))
77
- int prevMajor = currentVersion. major - 1
78
- File versionFile = file(' core/src/main/java/org/elasticsearch/Version.java' )
79
- List<String > versionLines = versionFile. readLines(' UTF-8' )
80
- List<Version > versions = []
81
- // keep track of the previous major version's last minor, so we know where wire compat begins
82
- int prevMinorIndex = -1 // index in the versions list of the last minor from the prev major
83
- int lastPrevMinor = -1 // the minor version number from the prev major we most recently seen
84
- int prevBugfixIndex = -1 // index in the versions list of the last bugfix release from the prev major
85
- for (String line : versionLines) {
86
- /* Note that this skips alphas and betas which is fine because they aren't
87
- * compatible with anything. */
88
- Matcher match = line =~ / \W +public static final Version V_(\d +)_(\d +)_(\d +)(_beta\d +|_rc\d +)? .*/
89
- if (match. matches()) {
90
- int major = Integer . parseInt(match. group(1 ))
91
- int minor = Integer . parseInt(match. group(2 ))
92
- int bugfix = Integer . parseInt(match. group(3 ))
93
- String suffix = (match. group(4 ) ?: ' ' ). replace(' _' , ' -' )
94
- Version foundVersion = new Version (major, minor, bugfix, suffix, false )
95
- if (currentVersion != foundVersion
96
- && (major == prevMajor || major == currentVersion. major)) {
97
- if (versions. isEmpty() || versions. last() != foundVersion) {
98
- versions. add(foundVersion)
99
- } else {
100
- // Replace the earlier betas with later ones
101
- Version last = versions. set(versions. size() - 1 , foundVersion)
102
- if (last. suffix == ' ' ) {
103
- throw new InvalidUserDataException (" Found two equal versions but"
104
- + " the first one [$last ] wasn't a beta." )
105
- }
106
- }
107
- if (major == prevMajor && minor > lastPrevMinor) {
108
- prevMinorIndex = versions. size() - 1
109
- lastPrevMinor = minor
110
- }
111
- }
112
- if (major == prevMajor) {
113
- prevBugfixIndex = versions. size() - 1
114
- }
115
- }
116
- }
117
- if (versions. toSorted { it. id } != versions) {
118
- println " Versions: ${ versions} "
119
- throw new GradleException (" Versions.java contains out of order version constants" )
120
- }
121
- if (prevBugfixIndex != -1 ) {
122
- versions[prevBugfixIndex] = new Version (versions[prevBugfixIndex]. major, versions[prevBugfixIndex]. minor,
123
- versions[prevBugfixIndex]. bugfix, versions[prevBugfixIndex]. suffix, true )
124
- }
125
- if (currentVersion. bugfix == 0 ) {
126
- // If on a release branch, after the initial release of that branch, the bugfix version will
127
- // be bumped, and will be != 0. On master and N.x branches, we want to test against the
128
- // unreleased version of closest branch. So for those cases, the version includes -SNAPSHOT,
129
- // and the bwc distribution will checkout and build that version.
130
- Version last = versions[-1 ]
131
- versions[-1 ] = new Version (last. major, last. minor, last. bugfix, last. suffix, true )
132
- if (last. bugfix == 0 ) {
133
- versions[-2 ] = new Version (
134
- versions[-2 ]. major, versions[-2 ]. minor, versions[-2 ]. bugfix, versions[-2 ]. suffix, true )
135
- }
76
+ VersionCollection versions = new VersionCollection (file(' core/src/main/java/org/elasticsearch/Version.java' ). readLines(' UTF-8' ))
77
+ if (versions. currentVersion. toString() != VersionProperties . elasticsearch) {
78
+ throw new GradleException (" The last version in Versions.java [${ versions.currentVersion} ] does not match " +
79
+ " VersionProperties.elasticsearch [${ VersionProperties.elasticsearch} ]" )
136
80
}
137
81
138
82
// build metadata from previous build, contains eg hashes for bwc builds
@@ -151,9 +95,10 @@ allprojects {
151
95
// for ide hacks...
152
96
isEclipse = System . getProperty(" eclipse.launcher" ) != null || gradle. startParameter. taskNames. contains(' eclipse' ) || gradle. startParameter. taskNames. contains(' cleanEclipse' )
153
97
isIdea = System . getProperty(" idea.active" ) != null || gradle. startParameter. taskNames. contains(' idea' ) || gradle. startParameter. taskNames. contains(' cleanIdea' )
154
- // for backcompat testing
155
- indexCompatVersions = versions
156
- wireCompatVersions = versions. subList(prevMinorIndex, versions. size())
98
+
99
+ // for BWC testing
100
+ versionCollection = versions
101
+
157
102
buildMetadata = buildMetadataMap
158
103
}
159
104
}
@@ -171,13 +116,13 @@ task verifyVersions {
171
116
Set<Version > knownVersions = new TreeSet<> (xml. versioning. versions. version. collect { it. text() }. findAll { it ==~ / \d\.\d\.\d / }. collect { Version . fromString(it) })
172
117
173
118
// Limit the known versions to those that should be index compatible, and are not future versions
174
- knownVersions = knownVersions. findAll { it. major >= prevMajor && it. before(VersionProperties . elasticsearch) }
119
+ knownVersions = knownVersions. findAll { it. major >= versions . currentVersion . major - 1 && it. before(VersionProperties . elasticsearch) }
175
120
176
121
/* Limit the listed versions to those that have been marked as released.
177
122
* Versions not marked as released don't get the same testing and we want
178
123
* to make sure that we flip all unreleased versions to released as soon
179
124
* as possible after release. */
180
- Set<Version > actualVersions = new TreeSet<> (indexCompatVersions . findAll { false == it. snapshot })
125
+ Set<Version > actualVersions = new TreeSet<> (versions . versionsIndexCompatibleWithCurrent . findAll { false == it. snapshot })
181
126
182
127
// Finally, compare!
183
128
if (knownVersions. equals(actualVersions) == false ) {
@@ -251,32 +196,18 @@ subprojects {
251
196
" org.elasticsearch.plugin:parent-join-client:${ version} " : ' :modules:parent-join' ,
252
197
" org.elasticsearch.plugin:aggs-matrix-stats-client:${ version} " : ' :modules:aggs-matrix-stats' ,
253
198
" org.elasticsearch.plugin:percolator-client:${ version} " : ' :modules:percolator' ,
254
- " org.elasticsearch.plugin:aggs-composite-client:${ version} " : ' :modules:aggs-composite' ,
255
199
]
256
- if (indexCompatVersions[-1 ]. snapshot) {
257
- /* The last and second to last versions can be snapshots. Rather than use
258
- * snapshots built by CI we connect these versions to projects that build
259
- * those those versions from the HEAD of the appropriate branch. */
260
- if (indexCompatVersions[-1 ]. bugfix == 0 ) {
261
- ext. projectSubstitutions[" org.elasticsearch.distribution.deb:elasticsearch:${ indexCompatVersions[-1]} " ] = ' :distribution:bwc-stable-snapshot'
262
- ext. projectSubstitutions[" org.elasticsearch.distribution.rpm:elasticsearch:${ indexCompatVersions[-1]} " ] = ' :distribution:bwc-stable-snapshot'
263
- ext. projectSubstitutions[" org.elasticsearch.distribution.zip:elasticsearch:${ indexCompatVersions[-1]} " ] = ' :distribution:bwc-stable-snapshot'
264
- if (indexCompatVersions. size() > 1 ) {
265
- ext. projectSubstitutions[" org.elasticsearch.distribution.deb:elasticsearch:${ indexCompatVersions[-2]} " ] = ' :distribution:bwc-release-snapshot'
266
- ext. projectSubstitutions[" org.elasticsearch.distribution.rpm:elasticsearch:${ indexCompatVersions[-2]} " ] = ' :distribution:bwc-release-snapshot'
267
- ext. projectSubstitutions[" org.elasticsearch.distribution.zip:elasticsearch:${ indexCompatVersions[-2]} " ] = ' :distribution:bwc-release-snapshot'
268
- }
269
- } else {
270
- ext. projectSubstitutions[" org.elasticsearch.distribution.deb:elasticsearch:${ indexCompatVersions[-1]} " ] = ' :distribution:bwc-release-snapshot'
271
- ext. projectSubstitutions[" org.elasticsearch.distribution.rpm:elasticsearch:${ indexCompatVersions[-1]} " ] = ' :distribution:bwc-release-snapshot'
272
- ext. projectSubstitutions[" org.elasticsearch.distribution.zip:elasticsearch:${ indexCompatVersions[-1]} " ] = ' :distribution:bwc-release-snapshot'
200
+
201
+ for (final Version version : versionCollection. versionsIndexCompatibleWithCurrent) {
202
+ if (version. branch != null ) {
203
+ final String snapshotProject = " :distribution:bwc-snapshot-${ version.branch} "
204
+ project(snapshotProject). ext. bwcVersion = version
205
+ ext. projectSubstitutions[" org.elasticsearch.distribution.deb:elasticsearch:${ version} " ] = snapshotProject
206
+ ext. projectSubstitutions[" org.elasticsearch.distribution.rpm:elasticsearch:${ version} " ] = snapshotProject
207
+ ext. projectSubstitutions[" org.elasticsearch.distribution.zip:elasticsearch:${ version} " ] = snapshotProject
273
208
}
274
- } else if (indexCompatVersions[-2 ]. snapshot) {
275
- /* This is a terrible hack for the bump to 6.0.1 which will be fixed by #27397 */
276
- ext. projectSubstitutions[" org.elasticsearch.distribution.deb:elasticsearch:${ indexCompatVersions[-2]} " ] = ' :distribution:bwc-release-snapshot'
277
- ext. projectSubstitutions[" org.elasticsearch.distribution.rpm:elasticsearch:${ indexCompatVersions[-2]} " ] = ' :distribution:bwc-release-snapshot'
278
- ext. projectSubstitutions[" org.elasticsearch.distribution.zip:elasticsearch:${ indexCompatVersions[-2]} " ] = ' :distribution:bwc-release-snapshot'
279
209
}
210
+
280
211
project. afterEvaluate {
281
212
configurations. all {
282
213
resolutionStrategy. dependencySubstitution { DependencySubstitutions subs ->
0 commit comments