2015-11-10 02:34:22 -05: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.
|
|
|
|
*/
|
2017-11-15 08:50:13 -05:00
|
|
|
|
2019-11-22 13:59:46 -05:00
|
|
|
import org.gradle.internal.jvm.Jvm
|
2019-09-30 03:23:04 -04:00
|
|
|
import org.gradle.util.GradleVersion
|
2019-03-13 13:11:50 -04:00
|
|
|
|
2018-06-28 08:14:34 -04:00
|
|
|
plugins {
|
|
|
|
id 'java-gradle-plugin'
|
|
|
|
id 'groovy'
|
2020-05-28 08:41:42 -04:00
|
|
|
id 'java-test-fixtures'
|
2018-06-28 08:14:34 -04:00
|
|
|
}
|
2015-10-29 14:40:19 -04:00
|
|
|
|
|
|
|
group = 'org.elasticsearch.gradle'
|
2016-05-07 01:22:38 -04:00
|
|
|
|
2020-05-28 08:41:42 -04:00
|
|
|
String minimumGradleVersion = file('src/main/resources/minimumGradleVersion').text.trim()
|
|
|
|
if (GradleVersion.current() < GradleVersion.version(minimumGradleVersion)) {
|
|
|
|
throw new GradleException("Gradle ${minimumGradleVersion}+ is required to build elasticsearch")
|
|
|
|
}
|
|
|
|
|
2016-05-07 01:22:38 -04:00
|
|
|
if (project == rootProject) {
|
|
|
|
// change the build dir used during build init, so that doing a clean
|
|
|
|
// won't wipe out the buildscript jar
|
|
|
|
buildDir = 'build-bootstrap'
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Propagating version.properties to the rest of the build *
|
|
|
|
*****************************************************************************/
|
2015-10-29 14:40:19 -04:00
|
|
|
|
2018-11-01 23:27:40 -04: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.
|
2019-05-24 16:46:59 -04:00
|
|
|
Properties props = VersionPropertiesLoader.loadBuildSrcVersion(project.file('version.properties'))
|
2018-11-01 23:27:40 -04:00
|
|
|
version = props.getProperty("elasticsearch")
|
2019-05-24 16:46:59 -04:00
|
|
|
|
2020-05-25 03:37:33 -04:00
|
|
|
def generateVersionProperties = tasks.register("generateVersionProperties", WriteProperties) {
|
2019-05-24 16:46:59 -04:00
|
|
|
outputFile = "${buildDir}/version.properties"
|
|
|
|
comment = 'Generated version properties'
|
|
|
|
properties(props)
|
|
|
|
}
|
|
|
|
|
2018-11-01 23:27:40 -04:00
|
|
|
processResources {
|
2019-05-24 16:46:59 -04:00
|
|
|
from(generateVersionProperties)
|
2016-05-07 01:22:38 -04:00
|
|
|
}
|
|
|
|
|
2018-10-25 03:03:23 -04:00
|
|
|
/*****************************************************************************
|
|
|
|
* Java version *
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2018-11-06 07:43:48 -05:00
|
|
|
if (JavaVersion.current() < JavaVersion.VERSION_11) {
|
|
|
|
throw new GradleException('At least Java 11 is required to build elasticsearch gradle tools')
|
2018-11-01 23:27:40 -04:00
|
|
|
}
|
2018-10-25 03:03:23 -04:00
|
|
|
|
2019-07-18 14:15:56 -04:00
|
|
|
sourceSets {
|
2020-05-28 08:41:42 -04:00
|
|
|
integTest {
|
|
|
|
compileClasspath += sourceSets["main"].output + configurations["testRuntimeClasspath"]
|
|
|
|
runtimeClasspath += output + compileClasspath
|
|
|
|
}
|
2019-07-18 14:15:56 -04:00
|
|
|
}
|
|
|
|
|
2020-07-01 09:12:59 -04:00
|
|
|
tasks.withType(JavaCompile).configureEach {
|
|
|
|
options.encoding = 'UTF-8'
|
2019-07-18 14:15:56 -04:00
|
|
|
}
|
2018-10-25 03:03:23 -04:00
|
|
|
|
2016-05-07 01:22:38 -04:00
|
|
|
/*****************************************************************************
|
|
|
|
* Dependencies used by the entire build *
|
|
|
|
*****************************************************************************/
|
2015-11-10 02:34:22 -05:00
|
|
|
|
2015-10-29 14:40:19 -04:00
|
|
|
repositories {
|
2015-10-29 16:59:10 -04:00
|
|
|
jcenter()
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2019-07-18 14:15:56 -04:00
|
|
|
|
2020-06-30 09:57:41 -04:00
|
|
|
api localGroovy()
|
|
|
|
|
|
|
|
api 'commons-codec:commons-codec:1.12'
|
|
|
|
api 'org.apache.commons:commons-compress:1.19'
|
2020-08-17 11:54:08 -04:00
|
|
|
|
2020-06-30 09:57:41 -04:00
|
|
|
api 'com.netflix.nebula:gradle-extra-configurations-plugin:3.0.3'
|
|
|
|
api 'com.netflix.nebula:nebula-publishing-plugin:4.4.4'
|
|
|
|
api 'com.netflix.nebula:gradle-info-plugin:7.1.3'
|
|
|
|
api 'org.apache.rat:apache-rat:0.11'
|
|
|
|
api "org.elasticsearch:jna:5.5.0"
|
2020-07-29 13:45:11 -04:00
|
|
|
api 'com.github.jengelman.gradle.plugins:shadow:6.0.0'
|
2020-06-30 09:57:41 -04:00
|
|
|
api 'de.thetaphi:forbiddenapis:3.0'
|
2020-07-01 19:08:46 -04:00
|
|
|
api 'com.avast.gradle:gradle-docker-compose-plugin:0.12.1'
|
2020-06-30 09:57:41 -04:00
|
|
|
api 'org.apache.maven:maven-model:3.6.2'
|
|
|
|
api 'com.networknt:json-schema-validator:1.0.36'
|
|
|
|
|
2020-03-27 11:04:38 -04:00
|
|
|
compileOnly "com.puppycrawl.tools:checkstyle:${props.getProperty('checkstyle')}"
|
2020-06-14 16:30:44 -04:00
|
|
|
testImplementation "com.puppycrawl.tools:checkstyle:${props.getProperty('checkstyle')}"
|
2020-05-28 08:41:42 -04:00
|
|
|
testFixturesApi "junit:junit:${props.getProperty('junit')}"
|
|
|
|
testFixturesApi "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${props.getProperty('randomizedrunner')}"
|
|
|
|
testFixturesApi gradleApi()
|
|
|
|
testFixturesApi gradleTestKit()
|
2020-06-14 16:30:44 -04:00
|
|
|
testImplementation 'com.github.tomakehurst:wiremock-jre8-standalone:2.23.2'
|
|
|
|
testImplementation 'org.mockito:mockito-core:1.9.5'
|
2020-06-23 03:14:12 -04:00
|
|
|
integTestImplementation('org.spockframework:spock-core:1.3-groovy-2.5') {
|
2020-07-01 09:12:59 -04:00
|
|
|
exclude module: "groovy"
|
2020-06-23 03:14:12 -04:00
|
|
|
}
|
2017-01-19 03:56:54 -05:00
|
|
|
}
|
2016-05-07 01:22:38 -04:00
|
|
|
|
|
|
|
/*****************************************************************************
|
2016-05-09 13:17:47 -04:00
|
|
|
* Bootstrap repositories *
|
2016-05-07 01:22:38 -04:00
|
|
|
*****************************************************************************/
|
|
|
|
// this will only happen when buildSrc is built on its own during build init
|
|
|
|
if (project == rootProject) {
|
|
|
|
repositories {
|
2017-02-15 00:31:56 -05:00
|
|
|
if (System.getProperty("repos.mavenLocal") != null) {
|
|
|
|
mavenLocal()
|
|
|
|
}
|
2016-02-20 14:53:47 -05:00
|
|
|
}
|
2019-08-08 15:38:30 -04:00
|
|
|
dependencies {
|
|
|
|
// add this so the runtime classpath so Gradle will properly track it as a build runtime classpath input
|
|
|
|
runtimeOnly project('reaper')
|
|
|
|
}
|
2018-12-05 07:20:01 -05:00
|
|
|
// only run tests as build-tools
|
|
|
|
test.enabled = false
|
2015-11-10 10:30:11 -05:00
|
|
|
}
|
2015-12-03 22:53:50 -05:00
|
|
|
|
2016-05-07 01:22:38 -04:00
|
|
|
/*****************************************************************************
|
|
|
|
* Normal project checks *
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
// this happens when included as a normal project in the build, which we do
|
|
|
|
// to enforce precommit checks like forbidden apis, as well as setup publishing
|
|
|
|
if (project != rootProject) {
|
|
|
|
apply plugin: 'elasticsearch.build'
|
2020-05-14 21:56:59 -04:00
|
|
|
apply plugin: 'elasticsearch.publish'
|
2016-05-07 01:22:38 -04:00
|
|
|
|
2019-08-02 21:58:04 -04:00
|
|
|
allprojects {
|
2019-08-15 21:39:11 -04:00
|
|
|
targetCompatibility = 10
|
|
|
|
sourceCompatibility = 10
|
2019-08-02 21:58:04 -04:00
|
|
|
}
|
2018-12-04 03:16:51 -05:00
|
|
|
|
2016-05-07 01:22:38 -04:00
|
|
|
// groovydoc succeeds, but has some weird internal exception...
|
|
|
|
groovydoc.enabled = false
|
|
|
|
|
|
|
|
// build-tools is not ready for primetime with these...
|
2020-06-18 02:15:50 -04:00
|
|
|
tasks.named("dependencyLicenses").configure { it.enabled = false }
|
2017-12-26 04:51:47 -05:00
|
|
|
dependenciesInfo.enabled = false
|
2020-07-01 09:12:59 -04:00
|
|
|
disableTasks('forbiddenApisMain', 'forbiddenApisTest', 'forbiddenApisIntegTest', 'forbiddenApisTestFixtures')
|
2016-05-07 01:22:38 -04:00
|
|
|
jarHell.enabled = false
|
|
|
|
thirdPartyAudit.enabled = false
|
2020-06-02 03:28:58 -04:00
|
|
|
if (org.elasticsearch.gradle.info.BuildParams.inFipsJvm) {
|
|
|
|
// We don't support running gradle with a JVM that is in FIPS 140 mode, so we don't test it.
|
|
|
|
// WaitForHttpResourceTests tests would fail as they use JKS/PKCS12 keystores
|
2020-01-27 04:14:52 -05:00
|
|
|
test.enabled = false
|
2020-06-02 03:28:58 -04:00
|
|
|
testingConventions.enabled = false
|
2020-01-27 04:14:52 -05:00
|
|
|
}
|
2016-05-07 01:22:38 -04:00
|
|
|
|
2020-06-02 09:33:53 -04:00
|
|
|
configurations.register("distribution")
|
|
|
|
configurations.register("reaper")
|
2019-01-21 02:33:11 -05:00
|
|
|
|
|
|
|
dependencies {
|
2019-08-10 00:09:16 -04:00
|
|
|
reaper project('reaper')
|
2019-01-29 14:18:30 -05:00
|
|
|
distribution project(':distribution:archives:windows-zip')
|
|
|
|
distribution project(':distribution:archives:oss-windows-zip')
|
|
|
|
distribution project(':distribution:archives:darwin-tar')
|
|
|
|
distribution project(':distribution:archives:oss-darwin-tar')
|
2020-03-22 11:58:11 -04:00
|
|
|
distribution project(':distribution:archives:linux-aarch64-tar')
|
2019-01-29 14:18:30 -05:00
|
|
|
distribution project(':distribution:archives:linux-tar')
|
|
|
|
distribution project(':distribution:archives:oss-linux-tar')
|
2020-03-22 11:58:11 -04:00
|
|
|
distribution project(':distribution:archives:oss-linux-aarch64-tar')
|
2020-07-01 04:41:01 -04:00
|
|
|
|
|
|
|
integTestRuntimeOnly(project(":libs:elasticsearch-core"))
|
2019-01-21 02:33:11 -05:00
|
|
|
}
|
2019-11-14 06:01:23 -05:00
|
|
|
|
2019-06-04 16:50:23 -04:00
|
|
|
// for external projects we want to remove the marker file indicating we are running the Elasticsearch project
|
|
|
|
processResources {
|
2019-11-14 06:01:23 -05:00
|
|
|
exclude 'buildSrc.marker'
|
|
|
|
into('META-INF') {
|
|
|
|
from configurations.reaper
|
|
|
|
}
|
2019-06-04 16:50:23 -04:00
|
|
|
}
|
2019-01-21 02:33:11 -05:00
|
|
|
|
Fix caching of build-tools project tests (#52848)
We embed the :reaper project jar in the build-tools jar so we can spawn
a reaper process at build runtime. Due to this, the jar technically
isn't part of the test runtime classpath, but for input snapshotting
purposes, we should be treating it as such. Instead, because it lives
in META-INF, Gradle treats it as a normal file, which in practice means
its hash changes on every build (timestamps, etc).
This commit changes our input snapshotting strategy such that instead
we explicitly add the jar as an input to any test tasks using Gradle's
runtime classpath normalization strategy (ignore timestamps, jar entry
order, etc) and ignore the file in META-INF. This ensures that we can
properly cache test results for build-tools, why still ensuring that
changes to the :reaper project trigger reexecution of tests.
2020-02-26 16:55:49 -05:00
|
|
|
// Track reaper jar as a test input using runtime classpath normalization strategy
|
|
|
|
tasks.withType(Test).configureEach {
|
|
|
|
inputs.files(configurations.reaper).withNormalizer(ClasspathNormalizer)
|
|
|
|
}
|
|
|
|
|
|
|
|
normalization {
|
|
|
|
runtimeClasspath {
|
|
|
|
// We already include the reaper jar as part of our runtime classpath. Ignore the copy in META-INF.
|
|
|
|
ignore('META-INF/reaper.jar')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-07 01:22:38 -04:00
|
|
|
forbiddenPatterns {
|
|
|
|
exclude '**/*.wav'
|
2019-04-04 06:44:03 -04:00
|
|
|
exclude '**/*.p12'
|
2020-06-04 08:53:23 -04:00
|
|
|
exclude '**/*.jks'
|
|
|
|
exclude '**/*.crt'
|
2016-05-07 01:22:38 -04:00
|
|
|
// the file that actually defines nocommit
|
2018-12-11 07:15:44 -05:00
|
|
|
exclude '**/ForbiddenPatternsTask.java'
|
2020-01-27 04:14:52 -05:00
|
|
|
exclude '**/*.bcfks'
|
2016-05-07 01:22:38 -04:00
|
|
|
}
|
2016-06-03 12:48:45 -04:00
|
|
|
|
2019-01-08 06:39:03 -05:00
|
|
|
testingConventions {
|
|
|
|
naming.clear()
|
|
|
|
naming {
|
|
|
|
Tests {
|
|
|
|
baseClass 'org.elasticsearch.gradle.test.GradleUnitTestCase'
|
|
|
|
}
|
|
|
|
IT {
|
|
|
|
baseClass 'org.elasticsearch.gradle.test.GradleIntegrationTestCase'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-25 03:37:33 -04:00
|
|
|
tasks.register("integTest", Test) {
|
2019-09-30 03:23:04 -04:00
|
|
|
inputs.dir(file("src/testKit")).withPropertyName("testkit dir").withPathSensitivity(PathSensitivity.RELATIVE)
|
|
|
|
systemProperty 'test.version_under_test', version
|
2019-11-01 14:33:11 -04:00
|
|
|
onlyIf { org.elasticsearch.gradle.info.BuildParams.inFipsJvm == false }
|
|
|
|
maxParallelForks = System.getProperty('tests.jvms', org.elasticsearch.gradle.info.BuildParams.defaultParallel.toString()) as Integer
|
2020-05-28 08:41:42 -04:00
|
|
|
testClassesDirs = sourceSets.integTest.output.classesDirs
|
|
|
|
classpath = sourceSets.integTest.runtimeClasspath
|
2019-09-30 03:23:04 -04:00
|
|
|
}
|
2020-05-25 03:37:33 -04:00
|
|
|
check.dependsOn("integTest")
|
2019-09-30 03:23:04 -04:00
|
|
|
|
2019-11-22 13:59:46 -05:00
|
|
|
// for now we hardcode the tests for our build to use the gradle jvm.
|
|
|
|
tasks.withType(Test).configureEach {
|
|
|
|
it.executable = Jvm.current().getJavaExecutable()
|
|
|
|
}
|
|
|
|
|
2018-07-26 13:19:05 -04:00
|
|
|
/*
|
2019-11-22 13:59:46 -05:00
|
|
|
* We already configure publication and we don't need or want this one that
|
2018-07-26 13:19:05 -04:00
|
|
|
* comes from the java-gradle-plugin.
|
|
|
|
*/
|
|
|
|
afterEvaluate {
|
|
|
|
generatePomFileForPluginMavenPublication.enabled = false
|
|
|
|
}
|
2020-05-28 08:41:42 -04:00
|
|
|
|
|
|
|
publishing.publications.named("nebula").configure {
|
|
|
|
suppressPomMetadataWarningsFor("testFixturesApiElements")
|
|
|
|
suppressPomMetadataWarningsFor("testFixturesRuntimeElements")
|
|
|
|
}
|
2015-12-03 22:53:50 -05:00
|
|
|
}
|
2018-11-01 23:27:40 -04:00
|
|
|
|
|
|
|
// Define this here because we need it early.
|
|
|
|
class VersionPropertiesLoader {
|
|
|
|
static Properties loadBuildSrcVersion(File input) throws IOException {
|
|
|
|
Properties props = new Properties();
|
|
|
|
InputStream is = new FileInputStream(input)
|
|
|
|
try {
|
|
|
|
props.load(is)
|
|
|
|
} finally {
|
|
|
|
is.close()
|
|
|
|
}
|
|
|
|
loadBuildSrcVersion(props, System.getProperties())
|
|
|
|
return props
|
|
|
|
}
|
|
|
|
|
|
|
|
protected static void loadBuildSrcVersion(Properties loadedProps, Properties systemProperties) {
|
|
|
|
String elasticsearch = loadedProps.getProperty("elasticsearch")
|
|
|
|
if (elasticsearch == null) {
|
|
|
|
throw new IllegalStateException("Elasticsearch version is missing from properties.")
|
|
|
|
}
|
|
|
|
if (elasticsearch.matches("[0-9]+\\.[0-9]+\\.[0-9]+") == false) {
|
|
|
|
throw new IllegalStateException(
|
2019-11-14 06:01:23 -05:00
|
|
|
"Expected elasticsearch version to be numbers only of the form X.Y.Z but it was: " +
|
|
|
|
elasticsearch
|
2018-11-01 23:27:40 -04:00
|
|
|
)
|
|
|
|
}
|
2018-11-12 07:43:42 -05:00
|
|
|
String qualifier = systemProperties.getProperty("build.version_qualifier", "");
|
2018-11-01 23:27:40 -04:00
|
|
|
if (qualifier.isEmpty() == false) {
|
|
|
|
if (qualifier.matches("(alpha|beta|rc)\\d+") == false) {
|
|
|
|
throw new IllegalStateException("Invalid qualifier: " + qualifier)
|
|
|
|
}
|
|
|
|
elasticsearch += "-" + qualifier
|
|
|
|
}
|
2020-01-27 16:48:40 -05:00
|
|
|
final String buildSnapshotSystemProperty = systemProperties.getProperty("build.snapshot", "true");
|
|
|
|
switch (buildSnapshotSystemProperty) {
|
|
|
|
case "true":
|
|
|
|
elasticsearch += "-SNAPSHOT"
|
|
|
|
break;
|
|
|
|
case "false":
|
|
|
|
// do nothing
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
throw new IllegalArgumentException(
|
|
|
|
"build.snapshot was set to [" + buildSnapshotSystemProperty + "] but can only be unset or [true|false]");
|
2018-11-01 23:27:40 -04:00
|
|
|
}
|
|
|
|
loadedProps.put("elasticsearch", elasticsearch)
|
|
|
|
}
|
2018-11-14 04:11:46 -05:00
|
|
|
}
|