diff --git a/build.gradle b/build.gradle index 150aebd742c..cc9e98be129 100644 --- a/build.gradle +++ b/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: /../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 } } } diff --git a/plugin/bwc/build.gradle b/plugin/bwc-snapshot-dummy-projects/build.gradle similarity index 84% rename from plugin/bwc/build.gradle rename to plugin/bwc-snapshot-dummy-projects/build.gradle index 883a3259510..c31174202ae 100644 --- a/plugin/bwc/build.gradle +++ b/plugin/bwc-snapshot-dummy-projects/build.gradle @@ -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") diff --git a/plugin/bwc/release-snapshot/build.gradle b/plugin/bwc/release-snapshot/build.gradle deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/plugin/bwc/stable-snapshot/build.gradle b/plugin/bwc/stable-snapshot/build.gradle deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/qa/full-cluster-restart/build.gradle b/qa/full-cluster-restart/build.gradle index 33f92af51da..9648a7b2590 100644 --- a/qa/full-cluster-restart/build.gradle +++ b/qa/full-cluster-restart/build.gradle @@ -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" + } + } } } diff --git a/qa/rolling-upgrade/build.gradle b/qa/rolling-upgrade/build.gradle index 8412f0e9584..ebac7e6e877 100644 --- a/qa/rolling-upgrade/build.gradle +++ b/qa/rolling-upgrade/build.gradle @@ -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)