2015-11-10 15:34:22 +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-11-10 15:34:22 +08:00
|
|
|
*/
|
2017-11-15 21:50:13 +08:00
|
|
|
|
2021-12-15 16:27:16 +08:00
|
|
|
import org.apache.tools.ant.filters.ReplaceTokens
|
|
|
|
import org.elasticsearch.gradle.internal.conventions.info.GitInfo
|
|
|
|
|
2018-06-28 20:14:34 +08:00
|
|
|
plugins {
|
|
|
|
id 'java-gradle-plugin'
|
2021-06-01 17:19:30 +08:00
|
|
|
id 'groovy-gradle-plugin'
|
2018-06-28 20:14:34 +08:00
|
|
|
id 'groovy'
|
2021-06-23 17:44:49 +08:00
|
|
|
id 'elasticsearch.build-tools'
|
2021-06-08 21:26:21 +08:00
|
|
|
id 'elasticsearch.eclipse'
|
2021-10-08 00:00:21 +08:00
|
|
|
id 'elasticsearch.versions'
|
2021-10-14 16:38:06 +08:00
|
|
|
id 'elasticsearch.formatting'
|
2018-06-28 20:14:34 +08:00
|
|
|
}
|
2015-10-30 02:40:19 +08:00
|
|
|
|
|
|
|
group = 'org.elasticsearch.gradle'
|
2016-05-07 13:22:38 +08:00
|
|
|
|
2018-11-02 11:27:40 +08:00
|
|
|
// we update the version property to reflect if we are building a snapshot or a release build
|
|
|
|
// we write this back out below to load it in the Build.java which will be shown in rest main action
|
|
|
|
// to indicate this being a snapshot build or a release build.
|
2021-10-08 00:00:21 +08:00
|
|
|
version = versions.getProperty("elasticsearch")
|
2019-05-25 04:46:59 +08:00
|
|
|
|
2021-02-17 17:04:13 +08:00
|
|
|
gradlePlugin {
|
|
|
|
// We already configure publication and we don't need or want the one that comes
|
|
|
|
// with the java-gradle-plugin
|
|
|
|
automatedPublishing = false
|
2021-05-06 20:02:35 +08:00
|
|
|
plugins {
|
|
|
|
build {
|
|
|
|
id = 'elasticsearch.build'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.BuildPlugin'
|
|
|
|
}
|
2022-03-15 18:37:47 +08:00
|
|
|
distro {
|
|
|
|
id = 'elasticsearch.distro'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.distribution.ElasticsearchDistributionPlugin'
|
|
|
|
}
|
2021-05-06 20:02:35 +08:00
|
|
|
distroTest {
|
|
|
|
id = 'elasticsearch.distro-test'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.test.DistroTestPlugin'
|
|
|
|
}
|
|
|
|
dockerSupport {
|
|
|
|
id = 'elasticsearch.docker-support'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.docker.DockerSupportPlugin'
|
|
|
|
}
|
|
|
|
docsTest {
|
|
|
|
id = 'elasticsearch.docs-test'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.doc.DocsTestPlugin'
|
|
|
|
}
|
|
|
|
globalBuildInfo {
|
|
|
|
id = 'elasticsearch.global-build-info'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.info.GlobalBuildInfoPlugin'
|
|
|
|
}
|
|
|
|
internalAvailablePorts {
|
|
|
|
id = 'elasticsearch.internal-available-ports'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.InternalAvailableTcpPortProviderPlugin'
|
|
|
|
}
|
|
|
|
internalClusterTest {
|
|
|
|
id = 'elasticsearch.internal-cluster-test'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.test.InternalClusterTestPlugin'
|
|
|
|
}
|
|
|
|
internalDistributionArchiveCheck {
|
|
|
|
id = 'elasticsearch.internal-distribution-archive-check'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.InternalDistributionArchiveCheckPlugin'
|
|
|
|
}
|
|
|
|
internalDistributionArchiveSetup {
|
|
|
|
id = 'elasticsearch.internal-distribution-archive-setup'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.InternalDistributionArchiveSetupPlugin'
|
|
|
|
}
|
|
|
|
internalDistributionBwcSetup {
|
|
|
|
id = 'elasticsearch.internal-distribution-bwc-setup'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.InternalDistributionBwcSetupPlugin'
|
|
|
|
}
|
|
|
|
internalDistributionDownload {
|
|
|
|
id = 'elasticsearch.internal-distribution-download'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.InternalDistributionDownloadPlugin'
|
|
|
|
}
|
|
|
|
internalPlugin {
|
|
|
|
id = 'elasticsearch.internal-es-plugin'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.InternalPluginBuildPlugin'
|
|
|
|
}
|
2022-03-15 02:27:24 +08:00
|
|
|
internalBasePlugin {
|
|
|
|
id = 'elasticsearch.base-internal-es-plugin'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.BaseInternalPluginBuildPlugin'
|
|
|
|
}
|
2021-05-06 20:02:35 +08:00
|
|
|
internalTestArtifact {
|
|
|
|
id = 'elasticsearch.internal-test-artifact'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.InternalTestArtifactPlugin'
|
|
|
|
}
|
|
|
|
internalTestArtifactBase {
|
|
|
|
id = 'elasticsearch.internal-test-artifact-base'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.InternalTestArtifactBasePlugin'
|
|
|
|
}
|
|
|
|
internalTestClusters {
|
|
|
|
id = 'elasticsearch.internal-testclusters'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.InternalTestClustersPlugin'
|
|
|
|
}
|
|
|
|
internalTestRerun {
|
|
|
|
id = 'elasticsearch.internal-test-rerun'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.test.rerun.TestRerunPlugin'
|
|
|
|
}
|
|
|
|
java {
|
|
|
|
id = 'elasticsearch.java'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.ElasticsearchJavaPlugin'
|
|
|
|
}
|
2021-09-14 02:10:22 +08:00
|
|
|
internalJavaRestTest {
|
|
|
|
id = 'elasticsearch.internal-java-rest-test'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.test.rest.InternalJavaRestTestPlugin'
|
2021-05-06 20:02:35 +08:00
|
|
|
}
|
|
|
|
jdkDownload {
|
|
|
|
id = 'elasticsearch.jdk-download'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.JdkDownloadPlugin'
|
|
|
|
}
|
2021-07-28 19:09:58 +08:00
|
|
|
releaseTools {
|
|
|
|
id = 'elasticsearch.release-tools'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.release.ReleaseToolsPlugin'
|
|
|
|
}
|
2021-05-06 20:02:35 +08:00
|
|
|
repositories {
|
|
|
|
id = 'elasticsearch.repositories'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.RepositoriesSetupPlugin'
|
|
|
|
}
|
|
|
|
restResources {
|
|
|
|
id = 'elasticsearch.rest-resources'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.test.rest.RestResourcesPlugin'
|
|
|
|
}
|
|
|
|
restTest {
|
|
|
|
id = 'elasticsearch.rest-test'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.test.RestTestPlugin'
|
|
|
|
}
|
|
|
|
standaloneRestTest {
|
|
|
|
id = 'elasticsearch.standalone-rest-test'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.test.StandaloneRestTestPlugin'
|
|
|
|
}
|
|
|
|
standaloneTest {
|
|
|
|
id = 'elasticsearch.standalone-test'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.test.StandaloneTestPlugin'
|
|
|
|
}
|
|
|
|
testFixtures {
|
|
|
|
id = 'elasticsearch.test.fixtures'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.testfixtures.TestFixturesPlugin'
|
|
|
|
}
|
|
|
|
testBase {
|
|
|
|
id = 'elasticsearch.test-base'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.ElasticsearchTestBasePlugin'
|
|
|
|
}
|
|
|
|
testWithDependencies {
|
|
|
|
id = 'elasticsearch.test-with-dependencies'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.test.TestWithDependenciesPlugin'
|
|
|
|
}
|
|
|
|
testWithSsl {
|
|
|
|
id = 'elasticsearch.test-with-ssl'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.test.TestWithSslPlugin'
|
|
|
|
}
|
|
|
|
validateRestSpec {
|
|
|
|
id = 'elasticsearch.validate-rest-spec'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.precommit.ValidateRestSpecPlugin'
|
|
|
|
}
|
|
|
|
yamlRestCompatTest {
|
|
|
|
id = 'elasticsearch.yaml-rest-compat-test'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.rest.compat.YamlRestCompatTestPlugin'
|
|
|
|
}
|
|
|
|
yamlRestTest {
|
2021-08-31 14:45:52 +08:00
|
|
|
id = 'elasticsearch.internal-yaml-rest-test'
|
|
|
|
implementationClass = 'org.elasticsearch.gradle.internal.test.rest.InternalYamlRestTestPlugin'
|
2021-05-06 20:02:35 +08:00
|
|
|
}
|
|
|
|
}
|
2021-02-17 17:04:13 +08:00
|
|
|
}
|
2016-05-07 13:22:38 +08:00
|
|
|
|
2018-10-25 15:03:23 +08:00
|
|
|
/*****************************************************************************
|
|
|
|
* Java version *
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2021-10-15 02:09:25 +08:00
|
|
|
def minCompilerJava = versions.get("minimumCompilerJava")
|
2021-06-08 23:26:58 +08:00
|
|
|
targetCompatibility = minCompilerJava
|
|
|
|
sourceCompatibility = minCompilerJava
|
2019-06-14 01:24:28 +08:00
|
|
|
|
2021-06-24 23:46:09 +08:00
|
|
|
if (JavaVersion.current() < JavaVersion.toVersion(minCompilerJava)) {
|
|
|
|
throw new GradleException("Java ${minCompilerJava} is required to build Elasticsearch but current Java is version ${JavaVersion.current()}.")
|
|
|
|
}
|
|
|
|
|
2019-06-14 01:24:28 +08:00
|
|
|
sourceSets {
|
2020-05-27 23:10:07 +08:00
|
|
|
integTest {
|
|
|
|
compileClasspath += sourceSets["main"].output + configurations["testRuntimeClasspath"]
|
|
|
|
runtimeClasspath += output + compileClasspath
|
|
|
|
}
|
2019-06-14 01:24:28 +08:00
|
|
|
}
|
|
|
|
|
2020-06-24 15:40:18 +08:00
|
|
|
tasks.withType(JavaCompile).configureEach {
|
|
|
|
options.encoding = 'UTF-8'
|
2019-06-14 01:24:28 +08:00
|
|
|
}
|
2018-10-25 15:03:23 +08:00
|
|
|
|
2021-06-01 17:19:30 +08:00
|
|
|
tasks.named('licenseHeaders').configure {
|
|
|
|
// ignore gradle generated binary script plugins
|
|
|
|
excludes << "Elasticsearch*Plugin.java"
|
|
|
|
}
|
2016-05-07 13:22:38 +08:00
|
|
|
/*****************************************************************************
|
|
|
|
* Dependencies used by the entire build *
|
|
|
|
*****************************************************************************/
|
2015-11-10 15:34:22 +08:00
|
|
|
|
2015-10-30 02:40:19 +08:00
|
|
|
repositories {
|
2021-02-25 15:36:08 +08:00
|
|
|
mavenCentral()
|
|
|
|
gradlePluginPortal()
|
2015-10-30 02:40:19 +08:00
|
|
|
}
|
|
|
|
|
2021-05-05 16:13:45 +08:00
|
|
|
configurations {
|
|
|
|
integTestRuntimeOnly.extendsFrom(testRuntimeOnly)
|
|
|
|
}
|
2015-10-30 02:40:19 +08:00
|
|
|
dependencies {
|
2022-01-27 16:57:47 +08:00
|
|
|
components.all(JacksonAlignmentRule)
|
|
|
|
// Forcefully downgrade the jackson platform as used in production
|
|
|
|
api enforcedPlatform("com.fasterxml.jackson:jackson-bom:${versions.getProperty('jackson')}")
|
2020-06-30 15:37:09 +08:00
|
|
|
api localGroovy()
|
|
|
|
api gradleApi()
|
|
|
|
|
2021-06-01 17:19:30 +08:00
|
|
|
api "org.elasticsearch:build-conventions:$version"
|
2021-06-24 23:55:21 +08:00
|
|
|
api "org.elasticsearch.gradle:build-tools:$version"
|
2021-06-01 17:19:30 +08:00
|
|
|
|
2022-01-24 20:16:38 +08:00
|
|
|
// same version as http client transitive dep
|
|
|
|
api 'commons-codec:commons-codec:1.11'
|
2020-06-30 15:37:09 +08:00
|
|
|
api 'org.apache.commons:commons-compress:1.19'
|
2020-08-27 20:21:41 +08:00
|
|
|
api 'org.apache.ant:ant:1.10.8'
|
2022-01-24 20:16:38 +08:00
|
|
|
api 'com.netflix.nebula:gradle-info-plugin:11.1.0'
|
2020-06-30 15:37:09 +08:00
|
|
|
api 'org.apache.rat:apache-rat:0.11'
|
2021-11-11 15:20:09 +08:00
|
|
|
api "net.java.dev.jna:jna:${versions.getProperty('jna')}"
|
2022-01-24 20:16:38 +08:00
|
|
|
api 'gradle.plugin.com.github.johnrengelman:shadow:7.1.2'
|
2021-04-29 15:33:28 +08:00
|
|
|
// for our ide tweaking
|
2022-01-24 20:16:38 +08:00
|
|
|
api 'gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:1.1.1'
|
2021-01-12 00:23:56 +08:00
|
|
|
// When upgrading forbidden apis, ensure dependency version is bumped in ThirdPartyPrecommitPlugin as well
|
2021-12-07 02:58:56 +08:00
|
|
|
api 'de.thetaphi:forbiddenapis:3.2'
|
2022-01-24 20:16:38 +08:00
|
|
|
api 'com.avast.gradle:gradle-docker-compose-plugin:0.14.13'
|
2020-06-30 15:37:09 +08:00
|
|
|
api 'org.apache.maven:maven-model:3.6.2'
|
2022-01-27 16:57:47 +08:00
|
|
|
// needs to match the jackson minor version in use
|
|
|
|
api 'com.networknt:json-schema-validator:1.0.49'
|
2021-10-08 00:00:21 +08:00
|
|
|
api "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${versions.getProperty('jackson')}"
|
2021-12-07 02:58:56 +08:00
|
|
|
api 'org.ow2.asm:asm:9.2'
|
|
|
|
api 'org.ow2.asm:asm-tree:9.2'
|
2021-10-08 00:00:21 +08:00
|
|
|
api "org.apache.httpcomponents:httpclient:${versions.getProperty('httpclient')}"
|
|
|
|
api "org.apache.httpcomponents:httpcore:${versions.getProperty('httpcore')}"
|
|
|
|
compileOnly "com.puppycrawl.tools:checkstyle:${versions.getProperty('checkstyle')}"
|
2021-06-24 23:55:21 +08:00
|
|
|
runtimeOnly "org.elasticsearch.gradle:reaper:$version"
|
2021-10-08 00:00:21 +08:00
|
|
|
testImplementation "com.puppycrawl.tools:checkstyle:${versions.getProperty('checkstyle')}"
|
2020-06-12 19:34:53 +08:00
|
|
|
testImplementation 'com.github.tomakehurst:wiremock-jre8-standalone:2.23.2'
|
|
|
|
testImplementation 'org.mockito:mockito-core:1.9.5'
|
2021-10-08 00:00:21 +08:00
|
|
|
testImplementation "org.hamcrest:hamcrest:${versions.getProperty('hamcrest')}"
|
2021-04-17 01:16:42 +08:00
|
|
|
|
2021-06-24 23:55:21 +08:00
|
|
|
testImplementation testFixtures("org.elasticsearch.gradle:build-tools:$version")
|
2021-06-01 17:19:30 +08:00
|
|
|
|
2021-10-14 23:18:10 +08:00
|
|
|
testImplementation(platform("org.junit:junit-bom:${versions.getProperty('junit5')}"))
|
|
|
|
testImplementation("org.junit.jupiter:junit-jupiter") {
|
|
|
|
because 'allows to write and run Jupiter tests'
|
|
|
|
}
|
2021-10-08 00:00:21 +08:00
|
|
|
integTestImplementation(platform("org.junit:junit-bom:${versions.getProperty('junit5')}"))
|
2021-04-17 01:16:42 +08:00
|
|
|
integTestImplementation("org.junit.jupiter:junit-jupiter") {
|
|
|
|
because 'allows to write and run Jupiter tests'
|
|
|
|
}
|
2021-06-01 17:19:30 +08:00
|
|
|
integTestImplementation("net.bytebuddy:byte-buddy:1.11.0") {
|
|
|
|
because 'Generating dynamic mocks of internal libraries like JdkJarHell'
|
|
|
|
}
|
2021-05-05 16:13:45 +08:00
|
|
|
testRuntimeOnly("org.junit.vintage:junit-vintage-engine") {
|
2021-04-17 01:16:42 +08:00
|
|
|
because 'allows JUnit 3 and JUnit 4 tests to run'
|
|
|
|
}
|
2021-10-14 23:18:10 +08:00
|
|
|
testRuntimeOnly("org.junit.platform:junit-platform-launcher") {
|
2021-04-17 01:16:42 +08:00
|
|
|
because 'allows tests to run from IDEs that bundle older version of launcher'
|
|
|
|
}
|
|
|
|
|
2021-12-07 02:58:56 +08:00
|
|
|
testImplementation platform("org.spockframework:spock-bom:2.0-groovy-3.0")
|
2021-05-05 16:13:45 +08:00
|
|
|
testImplementation("org.spockframework:spock-core") {
|
|
|
|
exclude module: "groovy"
|
|
|
|
}
|
2021-12-07 02:58:56 +08:00
|
|
|
integTestImplementation platform("org.spockframework:spock-bom:2.0-groovy-3.0")
|
2021-04-17 01:16:42 +08:00
|
|
|
integTestImplementation("org.spockframework:spock-core") {
|
2020-06-24 15:40:18 +08:00
|
|
|
exclude module: "groovy"
|
2020-06-18 16:53:11 +08:00
|
|
|
}
|
2021-05-05 16:13:45 +08:00
|
|
|
// required as we rely on junit4 rules
|
2021-12-07 02:58:56 +08:00
|
|
|
integTestImplementation("org.spockframework:spock-junit4") {
|
|
|
|
exclude module: "groovy"
|
|
|
|
}
|
2021-10-14 23:18:10 +08:00
|
|
|
testImplementation "org.spockframework:spock-junit4"
|
2021-02-04 16:11:15 +08:00
|
|
|
integTestImplementation "org.xmlunit:xmlunit-core:2.8.2"
|
2017-01-19 16:56:54 +08:00
|
|
|
}
|
2016-05-07 13:22:38 +08:00
|
|
|
|
2021-10-14 23:18:10 +08:00
|
|
|
tasks.named('test').configure {
|
|
|
|
useJUnitPlatform()
|
|
|
|
}
|
2021-06-01 17:19:30 +08:00
|
|
|
tasks.register("integTest", Test) {
|
|
|
|
inputs.dir(file("src/testKit")).withPropertyName("testkit dir").withPathSensitivity(PathSensitivity.RELATIVE)
|
|
|
|
systemProperty 'test.version_under_test', version
|
|
|
|
testClassesDirs = sourceSets.integTest.output.classesDirs
|
|
|
|
classpath = sourceSets.integTest.runtimeClasspath
|
|
|
|
useJUnitPlatform()
|
2015-11-10 23:30:11 +08:00
|
|
|
}
|
2015-12-04 11:53:50 +08:00
|
|
|
|
2021-06-05 05:33:46 +08:00
|
|
|
tasks.named("check").configure { dependsOn("integTest") }
|
2021-12-15 16:27:16 +08:00
|
|
|
|
|
|
|
tasks.register("bootstrapPerformanceTests", Copy) {
|
|
|
|
from('performance')
|
|
|
|
into('build/performanceTests')
|
|
|
|
def root = file('..')
|
|
|
|
filter(ReplaceTokens, tokens: [testGitCommit:GitInfo.gitInfo(root).revision])
|
2022-01-24 22:28:51 +08:00
|
|
|
}
|
2022-01-27 16:57:47 +08:00
|
|
|
|
|
|
|
abstract class JacksonAlignmentRule implements ComponentMetadataRule {
|
|
|
|
void execute(ComponentMetadataContext ctx) {
|
|
|
|
ctx.details.with {d ->
|
|
|
|
if (d.id.group.startsWith("com.fasterxml.jackson")) {
|
|
|
|
// declare that Jackson modules all belong to the Jackson virtual platform
|
|
|
|
belongsTo("com.fasterxml.jackson:jackson-bom:${d.id.version}")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-03-15 02:27:24 +08:00
|
|
|
}
|