Consolidate version numbering semantics (elastic/x-pack-elasticsearch#3078)
Fixes to the build system, particularly around BWC testing, and to make future version bumps less painful. Original commit: elastic/x-pack-elasticsearch@a1d456f30a
This commit is contained in:
parent
a9b3cd747f
commit
3e8b3491d5
18
build.gradle
18
build.gradle
|
@ -1,6 +1,8 @@
|
|||
import org.elasticsearch.gradle.BuildPlugin
|
||||
import org.elasticsearch.gradle.Version
|
||||
import org.elasticsearch.gradle.VersionProperties
|
||||
import org.elasticsearch.gradle.precommit.LicenseHeadersTask
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException
|
||||
|
||||
if (project.projectDir.name != 'x-pack-elasticsearch') {
|
||||
throw new GradleException('You must checkout x-pack-elasticsearch in the following directory: <path to Elasticsearch checkout>/../elasticsearch-extra/x-pack-elasticsearch')
|
||||
|
@ -52,17 +54,11 @@ subprojects {
|
|||
ext.projectSubstitutions += [ "org.elasticsearch.plugin:x-pack-api:${version}": ':x-pack-elasticsearch:plugin']
|
||||
ext.projectSubstitutions += [ "org.elasticsearch:x-pack-client-api-objects:${version}": ':x-pack-elasticsearch:client:client-api-objects']
|
||||
|
||||
if (wireCompatVersions[-1].snapshot) {
|
||||
/* The last and second to last versions can be snapshots. Rather than use
|
||||
* snapshots built by CI we connect these versions to projects that build
|
||||
* those versions from the HEAD of the appropriate branch. */
|
||||
if (indexCompatVersions[-1].bugfix == 0) {
|
||||
ext.projectSubstitutions += [
|
||||
"org.elasticsearch.plugin:x-pack:${indexCompatVersions[-1]}": ':x-pack-elasticsearch:plugin:bwc:stable-snapshot',
|
||||
"org.elasticsearch.plugin:x-pack:${indexCompatVersions[-2]}": ':x-pack-elasticsearch:plugin:bwc:release-snapshot']
|
||||
} else {
|
||||
ext.projectSubstitutions += [
|
||||
"org.elasticsearch.plugin:x-pack:${indexCompatVersions[-1]}": ':x-pack-elasticsearch:plugin:bwc:release-snapshot']
|
||||
for (final Version version : versionCollection.versionsIndexCompatibleWithCurrent) {
|
||||
if (version.branch != null) {
|
||||
final String snapshotProject = ":x-pack-elasticsearch:plugin:bwc-snapshot-dummy-projects:bwc-snapshot-${version.branch}"
|
||||
project(snapshotProject).ext.bwcVersion = version
|
||||
ext.projectSubstitutions["org.elasticsearch.plugin:x-pack:${version}"] = snapshotProject
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import org.elasticsearch.gradle.Version
|
||||
|
||||
import java.util.regex.Matcher
|
||||
import org.elasticsearch.gradle.LoggedExec
|
||||
|
||||
|
@ -9,41 +11,20 @@ import org.elasticsearch.gradle.LoggedExec
|
|||
*/
|
||||
|
||||
subprojects {
|
||||
String bwcVersion
|
||||
boolean enabled = true
|
||||
if (project.name == 'stable-snapshot') {
|
||||
/* bwc-stable is only used if the last version is on a stable branch instead
|
||||
* of a release branch */
|
||||
enabled = indexCompatVersions[-1].bugfix == 0
|
||||
bwcVersion = indexCompatVersions[-1]
|
||||
} else if (project.name == 'release-snapshot') {
|
||||
if (indexCompatVersions[-1].bugfix == 0) {
|
||||
/* The last version is on a stable branch so it is handled by the bwc-stable
|
||||
* project. This project will instead handle the version before that which
|
||||
* *should* be on a release branch. */
|
||||
bwcVersion = indexCompatVersions[-2]
|
||||
} else {
|
||||
// The last version is on a release branch so it is handled by this project
|
||||
bwcVersion = indexCompatVersions[-1]
|
||||
}
|
||||
} else {
|
||||
final Matcher match = project.name =~ /bwc-snapshot-(\d+\.(\d+|x))/
|
||||
if (!match.matches()) {
|
||||
throw new InvalidUserDataException("Unsupport project name ${project.name}")
|
||||
}
|
||||
if (enabled) {
|
||||
String bwcBranch = match.group(1)
|
||||
|
||||
if (project.hasProperty('bwcVersion')) {
|
||||
Version bwcVersion = project.ext.bwcVersion
|
||||
|
||||
apply plugin: 'distribution'
|
||||
// Not published so no need to assemble
|
||||
tasks.remove(assemble)
|
||||
build.dependsOn.remove('assemble')
|
||||
|
||||
def (String major, String minor, String bugfix) = bwcVersion.split('\\.')
|
||||
def (String currentMajor, String currentMinor, String currentBugfix) = version.split('\\.')
|
||||
String bwcBranch
|
||||
if (project.name == 'stable-snapshot' && major != currentMajor) {
|
||||
bwcBranch = "${major}.x"
|
||||
} else {
|
||||
bwcBranch = "${major}.${minor}"
|
||||
}
|
||||
|
||||
File esCheckoutDir = file("${buildDir}/bwc/checkout-es-${bwcBranch}")
|
||||
File xpackCheckoutDir = file("${esCheckoutDir}-extra/x-pack-elasticsearch")
|
||||
|
|
@ -118,7 +118,7 @@ subprojects {
|
|||
into outputDir
|
||||
}
|
||||
|
||||
for (Version version : indexCompatVersions) {
|
||||
for (Version version : versionCollection.versionsIndexCompatibleWithCurrent) {
|
||||
String baseName = "v${version}"
|
||||
|
||||
Task oldClusterTest = tasks.create(name: "${baseName}#oldClusterTest", type: RestIntegTestTask) {
|
||||
|
@ -227,7 +227,11 @@ subprojects {
|
|||
// basic integ tests includes testing bwc against the most recent version
|
||||
task integTest {
|
||||
if (project.bwc_tests_enabled) {
|
||||
dependsOn = ["v${wireCompatVersions[-1]}#bwcTest"]
|
||||
if (project.bwc_tests_enabled) {
|
||||
for (final def version : versionCollection.basicIntegrationTestVersions) {
|
||||
dependsOn "v${version}#bwcTest"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ subprojects {
|
|||
into outputDir
|
||||
}
|
||||
|
||||
for (Version version : wireCompatVersions) {
|
||||
for (Version version : versionCollection.versionsWireCompatibleWithCurrent) {
|
||||
String baseName = "v${version}"
|
||||
|
||||
Task oldClusterTest = tasks.create(name: "${baseName}#oldClusterTest", type: RestIntegTestTask) {
|
||||
|
@ -256,7 +256,11 @@ subprojects {
|
|||
// basic integ tests includes testing bwc against the most recent version
|
||||
task integTest {
|
||||
if (project.bwc_tests_enabled) {
|
||||
dependsOn = ["v${wireCompatVersions[-1]}#bwcTest"]
|
||||
if (project.bwc_tests_enabled) {
|
||||
for (final def version : versionCollection.basicIntegrationTestVersions) {
|
||||
dependsOn "v${version}#bwcTest"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
check.dependsOn(integTest)
|
||||
|
|
Loading…
Reference in New Issue