Skip to content

Commit

Permalink
Rework bwc snapshot projects to build up to two bwc versions (elastic…
Browse files Browse the repository at this point in the history
…#24870)

Removes the `distribution:bwc` project in favor of
`distribution:bwc-release-snapshot` and
`distribution:bwc-stable-snapshot`.
`distribution:bwc-release-snapshot` builds a snapshot of the
latest release branch (5.4 now) if needed for backwards
compatibility. `distribution:bwc-stable-snapshot` builds a
snapshot of the latest stable branch (5.x now) if needed for
backwards compatibility.
  • Loading branch information
nik9000 authored May 29, 2017
1 parent dfdf496 commit bc4df47
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 11 deletions.
22 changes: 16 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion distribution/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down
27 changes: 24 additions & 3 deletions distribution/bwc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
10 changes: 9 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit bc4df47

Please sign in to comment.