Skip to content

Commit

Permalink
Adds a :distribution:bwc-stable project
Browse files Browse the repository at this point in the history
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 elastic#24798
  • Loading branch information
nik9000 committed May 24, 2017
1 parent a64937d commit 648a932
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
22 changes: 17 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
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
7 changes: 5 additions & 2 deletions distribution/bwc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
5 changes: 5 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ List projects = [
'benchmarks',
'distribution:integ-test-zip',
'distribution:bwc',
'distribution:bwc-stable',
'distribution:zip',
'distribution:tar',
'distribution:deb',
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit 648a932

Please sign in to comment.