2017-03-24 01:32:13 -04:00
|
|
|
/*
|
|
|
|
* Licensed to Elasticsearch under one or more contributor
|
|
|
|
* license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright
|
|
|
|
* ownership. Elasticsearch licenses this file to you under
|
|
|
|
* the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
* not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import java.util.regex.Matcher
|
|
|
|
import org.elasticsearch.gradle.LoggedExec
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is a dummy project which does a local worktree checkout of the previous
|
|
|
|
* major version's stable branch, and builds a snapshot. This allows backcompat
|
|
|
|
* tests in the next major version to test against the next unreleased minor
|
|
|
|
* version, without relying on snapshots.
|
|
|
|
*/
|
|
|
|
|
|
|
|
apply plugin: 'distribution'
|
|
|
|
|
2017-03-29 16:13:09 -04:00
|
|
|
File checkoutDir = file("${buildDir}/bwc/checkout-5.x")
|
2017-03-24 01:32:13 -04:00
|
|
|
task createClone(type: LoggedExec) {
|
2017-03-29 16:13:09 -04:00
|
|
|
onlyIf { checkoutDir.exists() == false }
|
2017-03-24 01:32:13 -04:00
|
|
|
commandLine = ['git', 'clone', rootDir, checkoutDir]
|
|
|
|
}
|
|
|
|
|
2017-03-29 16:42:47 -04:00
|
|
|
// we use regular Exec here to ensure we always get output, regardless of logging level
|
|
|
|
task findUpstream(type: Exec) {
|
2017-03-24 01:32:13 -04:00
|
|
|
dependsOn createClone
|
|
|
|
workingDir = checkoutDir
|
|
|
|
commandLine = ['git', 'remote', '-v']
|
2017-03-29 16:42:47 -04:00
|
|
|
ignoreExitValue = true
|
|
|
|
ByteArrayOutputStream output = new ByteArrayOutputStream()
|
|
|
|
standardOutput = output
|
2017-03-24 01:32:13 -04:00
|
|
|
doLast {
|
2017-03-29 16:42:47 -04:00
|
|
|
if (execResult.exitValue != 0) {
|
|
|
|
output.toString('UTF-8').eachLine { line -> logger.error(line) }
|
|
|
|
execResult.assertNormalExitValue()
|
|
|
|
}
|
2017-03-24 01:32:13 -04:00
|
|
|
project.ext.upstreamExists = false
|
|
|
|
output.toString('UTF-8').eachLine {
|
2017-03-24 05:22:59 -04:00
|
|
|
if (it.contains("upstream")) {
|
2017-03-24 01:32:13 -04:00
|
|
|
project.ext.upstreamExists = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
task addUpstream(type: LoggedExec) {
|
|
|
|
dependsOn findUpstream
|
|
|
|
onlyIf { project.ext.upstreamExists == false }
|
|
|
|
workingDir = checkoutDir
|
|
|
|
commandLine = ['git', 'remote', 'add', 'upstream', 'https://github.com/elastic/elasticsearch.git']
|
|
|
|
}
|
|
|
|
|
|
|
|
task fetchLatest(type: LoggedExec) {
|
|
|
|
dependsOn addUpstream
|
|
|
|
workingDir = checkoutDir
|
2017-03-24 05:31:10 -04:00
|
|
|
commandLine = ['git', 'fetch', 'upstream']
|
2017-03-24 01:32:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
task checkoutBwcBranch(type: LoggedExec) {
|
|
|
|
dependsOn fetchLatest
|
|
|
|
workingDir = checkoutDir
|
|
|
|
commandLine = ['git', 'checkout', 'upstream/5.x']
|
|
|
|
}
|
|
|
|
|
2017-03-29 15:11:38 -04:00
|
|
|
File bwcZip = file("${checkoutDir}/distribution/zip/build/distributions/elasticsearch-${bwcVersion}.zip")
|
2017-03-27 18:02:18 -04:00
|
|
|
task buildBwcVersion(type: GradleBuild) {
|
2017-03-24 01:32:13 -04:00
|
|
|
dependsOn checkoutBwcBranch
|
2017-03-27 18:02:18 -04:00
|
|
|
dir = checkoutDir
|
|
|
|
tasks = [':distribution:zip:assemble']
|
2017-03-24 01:32:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
artifacts {
|
|
|
|
'default' file: bwcZip, name: 'elasticsearch', type: 'zip', builtBy: buildBwcVersion
|
|
|
|
}
|
|
|
|
|