diff --git a/build.gradle b/build.gradle index 7d6b760a19c..7f95e69538f 100644 --- a/build.gradle +++ b/build.gradle @@ -218,12 +218,22 @@ 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 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' + if (indexCompatVersions[-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 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-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-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 { configurations.all { diff --git a/distribution/build.gradle b/distribution/build.gradle index 253af219843..b33ec60ee83 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 e31d0949bdf..bdd8905e2a7 100644 --- a/distribution/bwc/build.gradle +++ b/distribution/bwc/build.gradle @@ -26,14 +26,35 @@ 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-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-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 stable branch. */ + bwcVersion = indexCompatVersions[-2] + } else { + // 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}") +} -String bwcVersion = wireCompatVersions[-1] -if (bwcVersion.endsWith('-SNAPSHOT')) { +if (enabled) { apply plugin: 'distribution' def (String major, String minor, String bugfix) = bwcVersion.split('\\.') - String bwcBranch = bugfix == '0-SNAPSHOT' ? "${major}.x" : "${major}.${minor}" + String bwcBranch = + project.name == 'bwc-stable-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 9fc33b59f32..152f892f774 100644 --- a/settings.gradle +++ b/settings.gradle @@ -15,7 +15,8 @@ List projects = [ 'client:benchmark', 'benchmarks', 'distribution:integ-test-zip', - 'distribution:bwc', + 'distribution:bwc-release-snapshot', + 'distribution:bwc-stable-snapshot', 'distribution:zip', 'distribution:tar', 'distribution:deb', @@ -106,6 +107,13 @@ 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-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') project(":core").buildFileName = 'eclipse-build.gradle'