2015-10-30 02:40:19 +08:00
|
|
|
/*
|
2021-02-03 05:41:39 +08:00
|
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
|
|
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
|
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
|
|
* Side Public License, v 1.
|
2015-10-30 02:40:19 +08:00
|
|
|
*/
|
2018-08-31 21:01:54 +08:00
|
|
|
|
2020-02-11 05:49:44 +08:00
|
|
|
import com.avast.gradle.dockercompose.tasks.ComposePull
|
2021-07-01 01:43:15 +08:00
|
|
|
import com.fasterxml.jackson.databind.JsonNode
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper
|
2018-07-18 02:20:41 +08:00
|
|
|
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
|
2020-03-20 06:56:04 +08:00
|
|
|
import de.thetaphi.forbiddenapis.gradle.ForbiddenApisPlugin
|
2021-04-26 20:53:55 +08:00
|
|
|
import org.elasticsearch.gradle.internal.BuildPlugin
|
2019-10-08 19:39:58 +08:00
|
|
|
import org.elasticsearch.gradle.Version
|
2021-05-06 20:02:35 +08:00
|
|
|
import org.elasticsearch.gradle.VersionProperties
|
2021-07-01 01:43:15 +08:00
|
|
|
import org.elasticsearch.gradle.internal.BwcVersions
|
2021-04-26 20:53:55 +08:00
|
|
|
import org.elasticsearch.gradle.internal.info.BuildParams
|
2018-08-22 08:03:28 +08:00
|
|
|
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
|
2020-03-20 06:56:04 +08:00
|
|
|
import org.gradle.plugins.ide.eclipse.model.AccessRule
|
2019-10-08 19:39:58 +08:00
|
|
|
import org.gradle.util.DistributionLocator
|
|
|
|
import org.gradle.util.GradleVersion
|
2021-09-09 16:42:08 +08:00
|
|
|
import org.elasticsearch.gradle.util.GradleUtils
|
|
|
|
|
2020-03-24 04:44:12 +08:00
|
|
|
import static org.elasticsearch.gradle.util.GradleUtils.maybeConfigure
|
2020-10-22 00:25:22 +08:00
|
|
|
import org.gradle.plugins.ide.eclipse.model.ProjectDependency
|
2021-05-06 20:02:35 +08:00
|
|
|
import org.elasticsearch.gradle.internal.InternalPluginBuildPlugin
|
2021-06-28 17:15:24 +08:00
|
|
|
import org.elasticsearch.gradle.internal.ResolveAllDependencies
|
2021-07-01 17:43:51 +08:00
|
|
|
import java.nio.file.Files
|
2021-08-11 06:02:53 +08:00
|
|
|
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING
|
2019-08-08 05:53:40 +08:00
|
|
|
|
2018-05-22 12:21:16 +08:00
|
|
|
plugins {
|
2019-11-13 18:14:04 +08:00
|
|
|
id 'lifecycle-base'
|
2020-02-22 00:11:50 +08:00
|
|
|
id 'elasticsearch.docker-support'
|
2019-11-13 18:14:04 +08:00
|
|
|
id 'elasticsearch.global-build-info'
|
2021-04-29 15:33:28 +08:00
|
|
|
id 'elasticsearch.build-scan'
|
|
|
|
id 'elasticsearch.build-complete'
|
|
|
|
id 'elasticsearch.jdk-download'
|
|
|
|
id 'elasticsearch.internal-distribution-download'
|
|
|
|
id 'elasticsearch.runtime-jdk-provision'
|
|
|
|
id 'elasticsearch.ide'
|
|
|
|
id 'elasticsearch.forbidden-dependencies'
|
|
|
|
id 'elasticsearch.local-distribution'
|
|
|
|
id 'elasticsearch.fips'
|
2021-05-06 20:02:35 +08:00
|
|
|
id 'elasticsearch.internal-testclusters'
|
2021-04-29 15:33:28 +08:00
|
|
|
id 'elasticsearch.run'
|
2021-07-28 19:09:58 +08:00
|
|
|
id 'elasticsearch.release-tools'
|
2021-10-08 00:00:21 +08:00
|
|
|
id 'elasticsearch.versions'
|
2018-05-22 12:21:16 +08:00
|
|
|
}
|
2019-07-17 00:34:00 +08:00
|
|
|
|
2021-02-16 21:36:17 +08:00
|
|
|
/**
|
|
|
|
* This is a convenient method for declaring test artifact dependencies provided by the internal
|
|
|
|
* test artifact plugin. It replaces basically the longer dependency notation with explicit capability
|
|
|
|
* declaration like this:
|
|
|
|
*
|
|
|
|
* testImplementation(project(xpackModule('repositories-metering-api'))) {
|
|
|
|
* capabilities {
|
|
|
|
* requireCapability("org.elasticsearch.gradle:repositories-metering-api-test-artifacts")
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* */
|
2021-02-17 19:08:13 +08:00
|
|
|
ext.testArtifact = { p, String name = "test" ->
|
2021-02-16 21:36:17 +08:00
|
|
|
def projectDependency = p.dependencies.create(p)
|
|
|
|
projectDependency.capabilities {
|
2021-02-17 19:08:13 +08:00
|
|
|
requireCapabilities("org.elasticsearch.gradle:${projectDependency.name}-${name}-artifacts")
|
2021-02-16 21:36:17 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-05-20 02:01:49 +08:00
|
|
|
tasks.register("updateCIBwcVersions") {
|
2019-11-13 18:14:04 +08:00
|
|
|
doLast {
|
|
|
|
File yml = file(".ci/bwcVersions")
|
|
|
|
yml.text = ""
|
|
|
|
yml << "BWC_VERSION:\n"
|
2020-05-14 05:26:39 +08:00
|
|
|
BuildParams.bwcVersions.indexCompatible.each {
|
2019-11-13 18:14:04 +08:00
|
|
|
yml << " - \"$it\"\n"
|
2019-07-17 22:34:35 +08:00
|
|
|
}
|
2019-11-13 18:14:04 +08:00
|
|
|
}
|
2019-07-17 22:34:35 +08:00
|
|
|
}
|
|
|
|
|
2020-05-20 02:01:49 +08:00
|
|
|
tasks.register("verifyVersions") {
|
2017-05-27 06:36:32 +08:00
|
|
|
doLast {
|
2017-06-02 01:29:51 +08:00
|
|
|
if (gradle.startParameter.isOffline()) {
|
|
|
|
throw new GradleException("Must run in online mode to verify versions")
|
|
|
|
}
|
2019-11-13 18:14:04 +08:00
|
|
|
// Read the list from maven central.
|
2020-02-28 00:07:35 +08:00
|
|
|
// Fetch the metadata and parse the xml into Version instances because it's more straight forward here
|
2018-11-01 23:43:57 +08:00
|
|
|
// rather than bwcVersion ( VersionCollection ).
|
2017-05-27 06:36:32 +08:00
|
|
|
new URL('https://repo1.maven.org/maven2/org/elasticsearch/elasticsearch/maven-metadata.xml').openStream().withStream { s ->
|
2020-05-07 18:08:17 +08:00
|
|
|
BuildParams.bwcVersions.compareToAuthoritative(
|
2019-11-13 18:14:04 +08:00
|
|
|
new XmlParser().parse(s)
|
|
|
|
.versioning.versions.version
|
|
|
|
.collect { it.text() }.findAll { it ==~ /\d+\.\d+\.\d+/ }
|
|
|
|
.collect { Version.fromString(it) }
|
2018-11-01 23:43:57 +08:00
|
|
|
)
|
2017-05-27 06:36:32 +08:00
|
|
|
}
|
2019-07-17 22:34:35 +08:00
|
|
|
String ciYml = file(".ci/bwcVersions").text
|
2020-05-07 18:08:17 +08:00
|
|
|
BuildParams.bwcVersions.indexCompatible.each {
|
2019-11-13 18:14:04 +08:00
|
|
|
if (ciYml.contains("\"$it\"\n") == false) {
|
|
|
|
throw new Exception(".ci/bwcVersions is outdated, run `./gradlew updateCIBwcVersions` and check in the results");
|
|
|
|
}
|
2019-07-17 22:34:35 +08:00
|
|
|
}
|
2021-07-01 01:43:15 +08:00
|
|
|
|
|
|
|
// Make sure backport bot config file is up to date
|
|
|
|
JsonNode backportConfig = new ObjectMapper().readTree(file(".backportrc.json"))
|
2021-10-27 08:07:29 +08:00
|
|
|
BuildParams.bwcVersions.forPreviousUnreleased { unreleasedVersion ->
|
2021-07-01 01:43:15 +08:00
|
|
|
boolean valid = backportConfig.get("targetBranchChoices").elements().any { branchChoice ->
|
|
|
|
if (branchChoice.isObject()) {
|
|
|
|
return branchChoice.get("name").textValue() == unreleasedVersion.branch
|
|
|
|
} else {
|
|
|
|
return branchChoice.textValue() == unreleasedVersion.branch
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (valid == false) {
|
|
|
|
throw new GradleException("No branch choice exists for development branch ${unreleasedVersion.branch} in .backportrc.json.")
|
|
|
|
}
|
|
|
|
}
|
2021-10-28 01:34:39 +08:00
|
|
|
String versionMapping = backportConfig.get("branchLabelMapping").fields().find { it.value.textValue() == 'master' }.key
|
|
|
|
String expectedMapping = "^v${versions.elasticsearch.replaceAll('-SNAPSHOT', '')}\$"
|
|
|
|
if (versionMapping != expectedMapping) {
|
|
|
|
throw new GradleException("Backport label mapping for branch 'master' is '${versionMapping}' but should be " +
|
|
|
|
"'${expectedMapping}'. Update .backportrc.json.")
|
|
|
|
}
|
2017-05-27 06:36:32 +08:00
|
|
|
}
|
|
|
|
}
|
2017-06-02 01:29:51 +08:00
|
|
|
|
2017-06-15 13:01:49 +08:00
|
|
|
/*
|
|
|
|
* When adding backcompat behavior that spans major versions, temporarily
|
|
|
|
* disabling the backcompat tests is necessary. This flag controls
|
|
|
|
* the enabled state of every bwc task. It should be set back to true
|
|
|
|
* after the backport of the backcompat code is complete.
|
|
|
|
*/
|
2019-02-14 23:19:28 +08:00
|
|
|
|
2021-11-26 03:48:12 +08:00
|
|
|
boolean bwc_tests_enabled = true
|
2021-03-11 18:13:46 +08:00
|
|
|
// place a PR link here when committing bwc changes:
|
2021-11-26 03:48:12 +08:00
|
|
|
String bwc_tests_disabled_issue = ""
|
2020-12-24 03:00:49 +08:00
|
|
|
/*
|
|
|
|
* FIPS 140-2 behavior was fixed in 7.11.0. Before that there is no way to run elasticsearch in a
|
|
|
|
* JVM that is properly configured to be in fips mode with BCFIPS. For now we need to disable
|
|
|
|
* all bwc testing in fips mode.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ( BuildParams.inFipsJvm ) {
|
2021-10-20 03:22:32 +08:00
|
|
|
bwc_tests_enabled = false
|
|
|
|
bwc_tests_disabled_issue = "https://github.com/elastic/elasticsearch/issues/66772"
|
2020-12-24 03:00:49 +08:00
|
|
|
}
|
2018-02-10 03:26:22 +08:00
|
|
|
if (bwc_tests_enabled == false) {
|
|
|
|
if (bwc_tests_disabled_issue.isEmpty()) {
|
|
|
|
throw new GradleException("bwc_tests_disabled_issue must be set when bwc_tests_enabled == false")
|
|
|
|
}
|
|
|
|
println "========================= WARNING ========================="
|
|
|
|
println " Backwards compatibility tests are disabled!"
|
|
|
|
println "See ${bwc_tests_disabled_issue}"
|
|
|
|
println "==========================================================="
|
|
|
|
}
|
2019-02-14 23:19:28 +08:00
|
|
|
if (project.gradle.startParameter.taskNames.find { it.startsWith("checkPart") } != null) {
|
|
|
|
// Disable BWC tests for checkPart* tasks as it's expected that this will run un it's own check
|
|
|
|
bwc_tests_enabled = false
|
|
|
|
}
|
|
|
|
|
2021-09-23 03:01:26 +08:00
|
|
|
subprojects {
|
2021-10-07 19:01:24 +08:00
|
|
|
apply plugin: 'elasticsearch.base'
|
2021-09-23 03:01:26 +08:00
|
|
|
}
|
2017-06-15 13:01:49 +08:00
|
|
|
|
2021-09-23 03:01:26 +08:00
|
|
|
allprojects {
|
2021-06-28 17:15:24 +08:00
|
|
|
// We disable this plugin for now till we shaked out the issues we see
|
|
|
|
// e.g. see https://github.com/elastic/elasticsearch/issues/72169
|
|
|
|
// apply plugin:'elasticsearch.internal-test-rerun'
|
|
|
|
|
|
|
|
plugins.withType(InternalPluginBuildPlugin).whenPluginAdded {
|
|
|
|
project.dependencies {
|
|
|
|
compileOnly project(":server")
|
|
|
|
testImplementation project(":test:framework")
|
2017-06-15 13:01:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-28 17:15:24 +08:00
|
|
|
// injecting groovy property variables into all projects
|
|
|
|
project.ext {
|
|
|
|
// for ide hacks...
|
2021-08-09 15:39:30 +08:00
|
|
|
isEclipse = providers.systemProperty("eclipse.launcher").forUseAtConfigurationTime().isPresent() || // Detects gradle launched from Eclipse's IDE
|
|
|
|
providers.systemProperty("eclipse.application").forUseAtConfigurationTime().isPresent() || // Detects gradle launched from the Eclipse compiler server
|
2021-06-28 17:15:24 +08:00
|
|
|
gradle.startParameter.taskNames.contains('eclipse') || // Detects gradle launched from the command line to do eclipse stuff
|
|
|
|
gradle.startParameter.taskNames.contains('cleanEclipse')
|
|
|
|
}
|
|
|
|
|
|
|
|
ext.bwc_tests_enabled = bwc_tests_enabled
|
2017-05-27 06:36:32 +08:00
|
|
|
|
2017-09-12 06:43:34 +08:00
|
|
|
// ignore missing javadocs
|
2019-08-08 05:53:40 +08:00
|
|
|
tasks.withType(Javadoc).configureEach { Javadoc javadoc ->
|
2017-09-12 06:43:34 +08:00
|
|
|
// the -quiet here is because of a bug in gradle, in that adding a string option
|
|
|
|
// by itself is not added to the options. By adding quiet, both this option and
|
|
|
|
// the "value" -quiet is added, separated by a space. This is ok since the javadoc
|
|
|
|
// command already adds -quiet, so we are just duplicating it
|
|
|
|
// see https://discuss.gradle.org/t/add-custom-javadoc-option-that-does-not-take-an-argument/5959
|
2019-11-13 18:14:04 +08:00
|
|
|
javadoc.options.encoding = 'UTF8'
|
2017-09-12 06:43:34 +08:00
|
|
|
javadoc.options.addStringOption('Xdoclint:all,-missing', '-quiet')
|
2015-10-30 02:40:19 +08:00
|
|
|
}
|
|
|
|
|
2021-06-28 17:15:24 +08:00
|
|
|
// eclipse configuration
|
|
|
|
apply plugin: 'elasticsearch.eclipse'
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allow accessing com/sun/net/httpserver in projects that have
|
|
|
|
* configured forbidden apis to allow it.
|
|
|
|
*/
|
|
|
|
plugins.withType(ForbiddenApisPlugin) {
|
|
|
|
eclipse.classpath.file.whenMerged { classpath ->
|
|
|
|
if (false == forbiddenApisTest.bundledSignatures.contains('jdk-non-portable')) {
|
|
|
|
classpath.entries
|
|
|
|
.findAll { it.kind == "con" && it.toString().contains("org.eclipse.jdt.launching.JRE_CONTAINER") }
|
|
|
|
.each {
|
|
|
|
it.accessRules.add(new AccessRule("accessible", "com/sun/net/httpserver/*"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-06-30 06:04:08 +08:00
|
|
|
|
2021-06-28 17:15:24 +08:00
|
|
|
tasks.register('resolveAllDependencies', ResolveAllDependencies) {
|
|
|
|
configs = project.configurations
|
|
|
|
if (project.path.contains("fixture")) {
|
|
|
|
dependsOn tasks.withType(ComposePull)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def checkPart1 = tasks.register('checkPart1')
|
|
|
|
def checkPart2 = tasks.register('checkPart2')
|
|
|
|
plugins.withId('lifecycle-base') {
|
|
|
|
if (project.path.startsWith(":x-pack:")) {
|
|
|
|
checkPart2.configure { dependsOn 'check' }
|
|
|
|
} else {
|
|
|
|
checkPart1.configure { dependsOn 'check' }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
project.ext.disableTasks = { String... tasknames ->
|
|
|
|
for (String taskname : tasknames) {
|
|
|
|
project.tasks.named(taskname).configure { enabled = false }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove assemble/dependenciesInfo on all qa projects because we don't
|
|
|
|
* need to publish artifacts for them.
|
|
|
|
*/
|
|
|
|
if (project.name.equals('qa') || project.path.contains(':qa:')) {
|
|
|
|
maybeConfigure(project.tasks, 'assemble') {
|
|
|
|
it.enabled = false
|
|
|
|
}
|
|
|
|
maybeConfigure(project.tasks, 'dependenciesInfo') {
|
|
|
|
it.enabled = false
|
|
|
|
}
|
|
|
|
maybeConfigure(project.tasks, 'dependenciesGraph') {
|
|
|
|
it.enabled = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-24 13:32:13 +08:00
|
|
|
project.afterEvaluate {
|
2021-06-28 17:15:24 +08:00
|
|
|
// Ensure similar tasks in dependent projects run first. The projectsEvaluated here is
|
|
|
|
// important because, while dependencies.all will pickup future dependencies,
|
|
|
|
// it is not necessarily true that the task exists in both projects at the time
|
|
|
|
// the dependency is added.
|
|
|
|
if (project.path == ':test:framework') {
|
|
|
|
// :test:framework:test cannot run before and after :server:test
|
|
|
|
return
|
|
|
|
}
|
|
|
|
tasks.matching { it.name.equals('integTest')}.configureEach {integTestTask ->
|
|
|
|
integTestTask.mustRunAfter tasks.matching { it.name.equals("test") }
|
|
|
|
}
|
|
|
|
|
|
|
|
configurations.matching { it.canBeResolved }.all { Configuration configuration ->
|
|
|
|
dependencies.matching { it instanceof ProjectDependency }.all { ProjectDependency dep ->
|
|
|
|
Project upstreamProject = dep.dependencyProject
|
|
|
|
if (project.path != upstreamProject?.path) {
|
|
|
|
for (String taskName : ['test', 'integTest']) {
|
|
|
|
project.tasks.matching { it.name == taskName }.configureEach {task ->
|
|
|
|
task.shouldRunAfter(upstreamProject.tasks.matching { upStreamTask -> upStreamTask.name == taskName })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-12 06:43:34 +08:00
|
|
|
// Handle javadoc dependencies across projects. Order matters: the linksOffline for
|
|
|
|
// org.elasticsearch:elasticsearch must be the last one or all the links for the
|
2018-01-12 02:30:43 +08:00
|
|
|
// other packages (e.g org.elasticsearch.client) will point to server rather than
|
2017-09-12 06:43:34 +08:00
|
|
|
// their own artifacts.
|
2018-08-22 08:03:28 +08:00
|
|
|
if (project.plugins.hasPlugin(BuildPlugin) || project.plugins.hasPlugin(PluginBuildPlugin)) {
|
2018-11-02 11:27:40 +08:00
|
|
|
String artifactsHost = VersionProperties.elasticsearch.endsWith("-SNAPSHOT") ? "https://snapshots.elastic.co" : "https://artifacts.elastic.co"
|
2017-09-12 06:43:34 +08:00
|
|
|
Closure sortClosure = { a, b -> b.group <=> a.group }
|
2018-07-18 02:20:41 +08:00
|
|
|
Closure depJavadocClosure = { shadowed, dep ->
|
2019-06-04 07:18:45 +08:00
|
|
|
if ((dep instanceof ProjectDependency) == false) {
|
2018-07-18 02:20:41 +08:00
|
|
|
return
|
|
|
|
}
|
2019-06-04 07:18:45 +08:00
|
|
|
Project upstreamProject = dep.dependencyProject
|
2018-07-18 02:20:41 +08:00
|
|
|
if (upstreamProject == null) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (shadowed) {
|
|
|
|
/*
|
|
|
|
* Include the source of shadowed upstream projects so we don't
|
|
|
|
* have to publish their javadoc.
|
|
|
|
*/
|
|
|
|
project.evaluationDependsOn(upstreamProject.path)
|
|
|
|
project.javadoc.source += upstreamProject.javadoc.source
|
|
|
|
/*
|
|
|
|
* Instead we need the upstream project's javadoc classpath so
|
|
|
|
* we don't barf on the classes that it references.
|
|
|
|
*/
|
|
|
|
project.javadoc.classpath += upstreamProject.javadoc.classpath
|
|
|
|
} else {
|
|
|
|
// Link to non-shadowed dependant projects
|
|
|
|
project.javadoc.dependsOn "${upstreamProject.path}:javadoc"
|
2020-07-07 16:46:52 +08:00
|
|
|
String externalLinkName = upstreamProject.archivesBaseName
|
|
|
|
String artifactPath = dep.group.replaceAll('\\.', '/') + '/' + externalLinkName.replaceAll('\\.', '/') + '/' + dep.version
|
2018-07-18 02:20:41 +08:00
|
|
|
project.javadoc.options.linksOffline artifactsHost + "/javadoc/" + artifactPath, "${upstreamProject.buildDir}/docs/javadoc/"
|
2017-09-12 06:43:34 +08:00
|
|
|
}
|
|
|
|
}
|
2018-07-18 02:20:41 +08:00
|
|
|
boolean hasShadow = project.plugins.hasPlugin(ShadowPlugin)
|
2021-04-13 15:15:08 +08:00
|
|
|
project.configurations.compileClasspath.dependencies
|
2021-06-28 17:15:24 +08:00
|
|
|
.findAll()
|
|
|
|
.toSorted(sortClosure)
|
|
|
|
.each({ c -> depJavadocClosure(hasShadow, c) })
|
2018-07-18 02:20:41 +08:00
|
|
|
project.configurations.compileOnly.dependencies
|
2021-06-28 17:15:24 +08:00
|
|
|
.findAll()
|
|
|
|
.toSorted(sortClosure)
|
|
|
|
.each({ c -> depJavadocClosure(false, c) })
|
2018-07-18 02:20:41 +08:00
|
|
|
if (hasShadow) {
|
2019-10-28 23:58:21 +08:00
|
|
|
// include any dependencies for shadow JAR projects that are *not* bundled in the shadow JAR
|
|
|
|
project.configurations.shadow.dependencies
|
2021-06-28 17:15:24 +08:00
|
|
|
.findAll()
|
|
|
|
.toSorted(sortClosure)
|
|
|
|
.each({ c -> depJavadocClosure(false, c) })
|
2018-07-18 02:20:41 +08:00
|
|
|
}
|
2017-09-12 06:43:34 +08:00
|
|
|
}
|
2015-11-22 17:12:17 +08:00
|
|
|
}
|
2021-06-28 17:15:24 +08:00
|
|
|
|
2021-10-14 16:38:06 +08:00
|
|
|
apply plugin: 'elasticsearch.formatting'
|
2015-11-22 17:12:17 +08:00
|
|
|
}
|
|
|
|
|
2020-11-26 17:30:06 +08:00
|
|
|
|
2021-06-28 17:15:24 +08:00
|
|
|
tasks.register("verifyBwcTestsEnabled") {
|
|
|
|
doLast {
|
|
|
|
if (bwc_tests_enabled == false) {
|
|
|
|
throw new GradleException('Bwc tests are disabled. They must be re-enabled after completing backcompat behavior backporting.')
|
2015-10-30 02:40:19 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-28 17:15:24 +08:00
|
|
|
tasks.register("branchConsistency") {
|
|
|
|
description 'Ensures this branch is internally consistent. For example, that versions constants match released versions.'
|
|
|
|
group 'Verification'
|
|
|
|
dependsOn ":verifyVersions", ":verifyBwcTestsEnabled"
|
2015-10-30 02:40:19 +08:00
|
|
|
}
|
|
|
|
|
2020-11-12 19:04:15 +08:00
|
|
|
tasks.named("wrapper").configure {
|
2019-11-13 18:14:04 +08:00
|
|
|
distributionType = 'ALL'
|
|
|
|
doLast {
|
|
|
|
final DistributionLocator locator = new DistributionLocator()
|
|
|
|
final GradleVersion version = GradleVersion.version(wrapper.gradleVersion)
|
|
|
|
final URI distributionUri = locator.getDistributionFor(version, wrapper.distributionType.name().toLowerCase(Locale.ENGLISH))
|
|
|
|
final URI sha256Uri = new URI(distributionUri.toString() + ".sha256")
|
|
|
|
final String sha256Sum = new String(sha256Uri.toURL().bytes)
|
|
|
|
wrapper.getPropertiesFile() << "distributionSha256Sum=${sha256Sum}\n"
|
|
|
|
println "Added checksum to wrapper properties"
|
2021-07-01 17:43:51 +08:00
|
|
|
// copy wrapper properties file to build-tools-internal to allow seamless idea integration
|
|
|
|
def file = new File("build-tools-internal/gradle/wrapper/gradle-wrapper.properties")
|
|
|
|
Files.copy(wrapper.getPropertiesFile().toPath(), file.toPath(), REPLACE_EXISTING)
|
2019-11-13 18:14:04 +08:00
|
|
|
// Update build-tools to reflect the Gradle upgrade
|
|
|
|
// TODO: we can remove this once we have tests to make sure older versions work.
|
2021-06-17 16:59:22 +08:00
|
|
|
project.file('build-tools-internal/src/main/resources/minimumGradleVersion').text = gradleVersion
|
2019-11-13 18:14:04 +08:00
|
|
|
println "Updated minimum Gradle Version"
|
|
|
|
}
|
2018-01-05 05:36:13 +08:00
|
|
|
}
|
|
|
|
|
2017-06-16 23:46:34 +08:00
|
|
|
gradle.projectsEvaluated {
|
2018-07-19 14:46:58 +08:00
|
|
|
// Having the same group and name for distinct projects causes Gradle to consider them equal when resolving
|
|
|
|
// dependencies leading to hard to debug failures. Run a check across all project to prevent this from happening.
|
|
|
|
// see: https://github.com/gradle/gradle/issues/847
|
|
|
|
Map coordsToProject = [:]
|
|
|
|
project.allprojects.forEach { p ->
|
|
|
|
String coords = "${p.group}:${p.name}"
|
|
|
|
if (false == coordsToProject.putIfAbsent(coords, p)) {
|
|
|
|
throw new GradleException(
|
2019-11-13 18:14:04 +08:00
|
|
|
"Detected that two projects: ${p.path} and ${coordsToProject[coords].path} " +
|
|
|
|
"have the same name and group: ${coords}. " +
|
|
|
|
"This doesn't currently work correctly in Gradle, see: " +
|
|
|
|
"https://github.com/gradle/gradle/issues/847"
|
2018-07-19 14:46:58 +08:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2017-06-16 23:46:34 +08:00
|
|
|
}
|
2018-06-28 13:13:21 +08:00
|
|
|
|
2021-07-28 19:09:58 +08:00
|
|
|
tasks.named("precommit") {
|
2021-06-01 17:19:30 +08:00
|
|
|
dependsOn gradle.includedBuild('build-tools').task(':precommit')
|
|
|
|
dependsOn gradle.includedBuild('build-tools-internal').task(':precommit')
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.named("checkPart1").configure {
|
|
|
|
dependsOn gradle.includedBuild('build-tools').task(':check')
|
|
|
|
dependsOn gradle.includedBuild('build-tools-internal').task(':check')
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.named("assemble").configure {
|
|
|
|
dependsOn gradle.includedBuild('build-tools').task(':assemble')
|
|
|
|
}
|
|
|
|
|
2021-06-08 21:26:21 +08:00
|
|
|
tasks.named("cleanEclipse").configure {
|
|
|
|
dependsOn gradle.includedBuild('build-conventions').task(':cleanEclipse')
|
|
|
|
dependsOn gradle.includedBuild('build-tools').task(':cleanEclipse')
|
|
|
|
dependsOn gradle.includedBuild('build-tools-internal').task(':cleanEclipse')
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.named("eclipse").configure {
|
|
|
|
dependsOn gradle.includedBuild('build-conventions').task(':eclipse')
|
|
|
|
dependsOn gradle.includedBuild('build-tools').task(':eclipse')
|
|
|
|
dependsOn gradle.includedBuild('build-tools-internal').task(':eclipse')
|
2021-06-30 06:04:08 +08:00
|
|
|
}
|
2021-09-09 16:42:08 +08:00
|
|
|
|
|
|
|
tasks.register("buildReleaseArtifacts").configure {
|
|
|
|
group = 'build'
|
|
|
|
description = 'Builds all artifacts required for release manager'
|
|
|
|
|
2021-10-16 02:36:14 +08:00
|
|
|
dependsOn allprojects.findAll {
|
|
|
|
it.path.startsWith(':distribution:docker') == false
|
|
|
|
&& it.path.startsWith(':ml-cpp') == false
|
|
|
|
&& it.path.startsWith(':distribution:bwc') == false
|
|
|
|
}
|
2021-09-09 16:42:08 +08:00
|
|
|
.collect { GradleUtils.findByName(it.tasks, 'assemble') }
|
|
|
|
.findAll { it != null }
|
|
|
|
}
|
2021-10-14 16:38:06 +08:00
|
|
|
|
2021-11-12 07:17:10 +08:00
|
|
|
tasks.register("spotlessApply").configure {
|
2021-10-14 16:38:06 +08:00
|
|
|
dependsOn gradle.includedBuild('build-tools').task(':spotlessApply')
|
|
|
|
dependsOn gradle.includedBuild('build-tools').task(':reaper:spotlessApply')
|
|
|
|
dependsOn gradle.includedBuild('build-tools-internal').task(':spotlessApply')
|
|
|
|
}
|