From 648a932a509f868a22bb2630a3edd1fc4f84a2c0 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Wed, 24 May 2017 15:08:33 -0400 Subject: [PATCH 1/3] Adds a `:distribution:bwc-stable` project Adds the `:distribution:bwc-stable` project which builds the previous stable branch when `:distribution:bwc` is building an unreleased branch. When `:distribution:bwc` builds a released branch then `:distribution:bwc-stable` is an empty build, not used or depended on by anything. Relates to #24798 --- build.gradle | 22 +++++++++++++++++----- distribution/build.gradle | 2 +- distribution/bwc/build.gradle | 7 +++++-- settings.gradle | 5 +++++ 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index 20467d842f535..ba9d09d4b551f 100644 --- a/build.gradle +++ b/build.gradle @@ -99,7 +99,11 @@ if (currentVersion.bugfix == 0) { // and the bwc distribution will checkout and build that version. Version last = versions[-1] versions[-1] = new Version(last.major, last.minor, last.bugfix, - true, last.unreleased) + true, last.unreleased) + if (last.bugfix == 0) { + versions[-2] = new Version( + versions[-2].major, versions[-2].minor, versions[-2].bugfix, true, last.unreleased) + } } // injecting groovy property variables into all projects @@ -171,12 +175,20 @@ subprojects { "org.elasticsearch.plugin:aggs-matrix-stats-client:${version}": ':modules:aggs-matrix-stats', "org.elasticsearch.plugin:percolator-client:${version}": ':modules:percolator', ] - if (wireCompatVersions[-1].snapshot) { + if (indexCompatVersions[-1].snapshot) { // if the most previous version is a snapshot, we need to connect that version to the // bwc project which will checkout and build that snapshot version - ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${wireCompatVersions[-1]}"] = ':distribution:bwc' - ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${wireCompatVersions[-1]}"] = ':distribution:bwc' - ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${wireCompatVersions[-1]}"] = ':distribution:bwc' + ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc' + ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc' + ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc' + if (indexCompatVersions[-2].snapshot) { + /* if the version before the previous version is a snapshot, we need to + * connect that version to the bwc project which will checkout and build + * that snapshot version */ + ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-stable' + ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-stable' + ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-stable' + } } project.afterEvaluate { configurations.all { diff --git a/distribution/build.gradle b/distribution/build.gradle index 253af219843c0..b33ec60ee8302 100644 --- a/distribution/build.gradle +++ b/distribution/build.gradle @@ -41,7 +41,7 @@ buildscript { } Collection distributions = project.subprojects.findAll { - it.path.contains(':tools') == false && it.name != 'bwc' } + it.path.contains(':tools') == false && it.path.contains(':bwc') == false } /***************************************************************************** * Notice file * diff --git a/distribution/bwc/build.gradle b/distribution/bwc/build.gradle index e31d0949bdf96..b047101537141 100644 --- a/distribution/bwc/build.gradle +++ b/distribution/bwc/build.gradle @@ -27,13 +27,16 @@ import org.elasticsearch.gradle.LoggedExec * without relying on snapshots. */ -String bwcVersion = wireCompatVersions[-1] +int bwcVersionIndex = project.name == 'bwc' ? -1 : -2 +String bwcVersion = indexCompatVersions[bwcVersionIndex] if (bwcVersion.endsWith('-SNAPSHOT')) { apply plugin: 'distribution' def (String major, String minor, String bugfix) = bwcVersion.split('\\.') - String bwcBranch = bugfix == '0-SNAPSHOT' ? "${major}.x" : "${major}.${minor}" + String bwcBranch = bwcVersionIndex == -1 && bugfix == '0-SNAPSHOT' ? + "${major}.x" : "${major}.${minor}" File checkoutDir = file("${buildDir}/bwc/checkout-${bwcBranch}") + task createClone(type: LoggedExec) { onlyIf { checkoutDir.exists() == false } commandLine = ['git', 'clone', rootDir, checkoutDir] diff --git a/settings.gradle b/settings.gradle index e9046f0a3de75..fd251f4d74cf4 100644 --- a/settings.gradle +++ b/settings.gradle @@ -16,6 +16,7 @@ List projects = [ 'benchmarks', 'distribution:integ-test-zip', 'distribution:bwc', + 'distribution:bwc-stable', 'distribution:zip', 'distribution:tar', 'distribution:deb', @@ -104,6 +105,10 @@ for (String example : examplePlugins) { project(":example-plugins:${example}").projectDir = new File(rootProject.projectDir, "plugins/examples/${example}") } +/* bwc and bwc-unreleased share the same build directory and build file, but + * apply to different backwards compatibility branches. */ +project(':distribution:bwc-stable').projectDir = project(':distribution:bwc').projectDir + if (isEclipse) { project(":core").projectDir = new File(rootProject.projectDir, 'core/src/main') project(":core").buildFileName = 'eclipse-build.gradle' From dc666dfe1820af03a203a5d045ce708d415dc957 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Fri, 26 May 2017 11:53:20 -0400 Subject: [PATCH 2/3] Switch bwc build names Now we have `bwc-release` and `bwc-stable`. `bwc-release` is used to build release branches - 5.4 in master, 5.5 eventually, etc. `bwc-stable` is used for building unstable branches - `5.x` in master, `6.x` eventually. These names line up with the way folks talk about the names of Lucene's branches. Those names make sense so we may as well use them for our own branches. --- build.gradle | 26 ++++++++++++++------------ distribution/bwc/build.gradle | 26 +++++++++++++++++++++----- settings.gradle | 5 +++-- 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/build.gradle b/build.gradle index ba9d09d4b551f..ba5126047e5a5 100644 --- a/build.gradle +++ b/build.gradle @@ -176,18 +176,20 @@ subprojects { "org.elasticsearch.plugin:percolator-client:${version}": ':modules:percolator', ] if (indexCompatVersions[-1].snapshot) { - // if the most previous version is a snapshot, we need to connect that version to the - // bwc project which will checkout and build that snapshot version - ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc' - ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc' - ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc' - if (indexCompatVersions[-2].snapshot) { - /* if the version before the previous version is a snapshot, we need to - * connect that version to the bwc project which will checkout and build - * that snapshot version */ - ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-stable' - ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-stable' - ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-stable' + /* 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 those versions from the HEAD of the appropriate branch. */ + if (indexCompatVersions[-1].bugfix == 0) { + ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-stable' + ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-stable' + ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-stable' + ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release' + ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release' + ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release' + } else { + ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-release' + ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-release' + ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-release' } } project.afterEvaluate { diff --git a/distribution/bwc/build.gradle b/distribution/bwc/build.gradle index b047101537141..bad3b2aae5a11 100644 --- a/distribution/bwc/build.gradle +++ b/distribution/bwc/build.gradle @@ -26,15 +26,31 @@ import org.elasticsearch.gradle.LoggedExec * tests to test against the next unreleased version, closest to this version, * without relying on snapshots. */ +String bwcVersion +boolean enabled = true +if (project.name == 'bwc-stable') { + /* bwc-stable is only used if the last version is on a stable branch instead + * of a bugfix branch */ + enabled = indexCompatVersions[-1].bugfix == 0 + bwcVersion = indexCompatVersions[-1] +} else if (project.name == 'bwc-release') { + 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 stable branch. */ + bwcVersion = indexCompatVersions[-2] + } else { + // The last version is on a release branch so it is handled by this project + bwcVersion = indexCompatVersions[-1] + } +} -int bwcVersionIndex = project.name == 'bwc' ? -1 : -2 -String bwcVersion = indexCompatVersions[bwcVersionIndex] -if (bwcVersion.endsWith('-SNAPSHOT')) { +if (enabled) { apply plugin: 'distribution' def (String major, String minor, String bugfix) = bwcVersion.split('\\.') - String bwcBranch = bwcVersionIndex == -1 && bugfix == '0-SNAPSHOT' ? - "${major}.x" : "${major}.${minor}" + String bwcBranch = + project.name == 'bwc-stable' ? "${major}.x" : "${major}.${minor}" File checkoutDir = file("${buildDir}/bwc/checkout-${bwcBranch}") task createClone(type: LoggedExec) { diff --git a/settings.gradle b/settings.gradle index fd251f4d74cf4..4debeff3cd282 100644 --- a/settings.gradle +++ b/settings.gradle @@ -15,7 +15,7 @@ List projects = [ 'client:benchmark', 'benchmarks', 'distribution:integ-test-zip', - 'distribution:bwc', + 'distribution:bwc-release', 'distribution:bwc-stable', 'distribution:zip', 'distribution:tar', @@ -107,7 +107,8 @@ for (String example : examplePlugins) { /* bwc and bwc-unreleased share the same build directory and build file, but * apply to different backwards compatibility branches. */ -project(':distribution:bwc-stable').projectDir = project(':distribution:bwc').projectDir +project(':distribution:bwc-release').projectDir = new File(rootProject.projectDir, 'distribution/bwc') +project(':distribution:bwc-stable').projectDir = new File(rootProject.projectDir, 'distribution/bwc') if (isEclipse) { project(":core").projectDir = new File(rootProject.projectDir, 'core/src/main') From 07d5bf0cb13f5a80b70aefa898716cfdd1b864bc Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Mon, 29 May 2017 09:38:23 -0400 Subject: [PATCH 3/3] Rename builds --- build.gradle | 18 +++++++++--------- distribution/bwc/build.gradle | 8 +++++--- settings.gradle | 10 ++++++---- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/build.gradle b/build.gradle index ca231d9f1b002..7f95e69538f7e 100644 --- a/build.gradle +++ b/build.gradle @@ -223,16 +223,16 @@ subprojects { * snapshots built by CI we connect these versions to projects that build * those those versions from the HEAD of the appropriate branch. */ if (indexCompatVersions[-1].bugfix == 0) { - ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-stable' - ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-stable' - ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-stable' - ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release' - ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release' - ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release' + ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-stable-snapshot' + ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-stable-snapshot' + ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-stable-snapshot' + ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot' + ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot' + ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot' } else { - ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-release' - ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-release' - ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-release' + ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-release-snapshot' + ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-release-snapshot' + ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-release-snapshot' } } project.afterEvaluate { diff --git a/distribution/bwc/build.gradle b/distribution/bwc/build.gradle index bad3b2aae5a11..bdd8905e2a7e8 100644 --- a/distribution/bwc/build.gradle +++ b/distribution/bwc/build.gradle @@ -28,12 +28,12 @@ import org.elasticsearch.gradle.LoggedExec */ String bwcVersion boolean enabled = true -if (project.name == 'bwc-stable') { +if (project.name == 'bwc-stable-snapshot') { /* bwc-stable is only used if the last version is on a stable branch instead * of a bugfix branch */ enabled = indexCompatVersions[-1].bugfix == 0 bwcVersion = indexCompatVersions[-1] -} else if (project.name == 'bwc-release') { +} else if (project.name == 'bwc-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 @@ -43,6 +43,8 @@ if (project.name == 'bwc-stable') { // The last version is on a release branch so it is handled by this project bwcVersion = indexCompatVersions[-1] } +} else { + throw new InvalidUserDataException("Unsupport project name ${project.name}") } if (enabled) { @@ -50,7 +52,7 @@ if (enabled) { def (String major, String minor, String bugfix) = bwcVersion.split('\\.') String bwcBranch = - project.name == 'bwc-stable' ? "${major}.x" : "${major}.${minor}" + project.name == 'bwc-stable-snapshot' ? "${major}.x" : "${major}.${minor}" File checkoutDir = file("${buildDir}/bwc/checkout-${bwcBranch}") task createClone(type: LoggedExec) { diff --git a/settings.gradle b/settings.gradle index daba1f5048040..152f892f774cb 100644 --- a/settings.gradle +++ b/settings.gradle @@ -15,8 +15,8 @@ List projects = [ 'client:benchmark', 'benchmarks', 'distribution:integ-test-zip', - 'distribution:bwc-release', - 'distribution:bwc-stable', + 'distribution:bwc-release-snapshot', + 'distribution:bwc-stable-snapshot', 'distribution:zip', 'distribution:tar', 'distribution:deb', @@ -109,8 +109,10 @@ for (String example : examplePlugins) { /* bwc and bwc-unreleased share the same build directory and build file, but * apply to different backwards compatibility branches. */ -project(':distribution:bwc-release').projectDir = new File(rootProject.projectDir, 'distribution/bwc') -project(':distribution:bwc-stable').projectDir = new File(rootProject.projectDir, 'distribution/bwc') +project(':distribution:bwc-release-snapshot').projectDir = + new File(rootProject.projectDir, 'distribution/bwc') +project(':distribution:bwc-stable-snapshot').projectDir = + new File(rootProject.projectDir, 'distribution/bwc') if (isEclipse) { project(":core").projectDir = new File(rootProject.projectDir, 'core/src/main')