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.
|
|
|
|
*/
|
2018-08-30 03:20:38 -04:00
|
|
|
import org.gradle.util.GradleVersion
|
2017-11-15 08:50:13 -05:00
|
|
|
|
2018-06-28 08:14:34 -04:00
|
|
|
plugins {
|
|
|
|
id 'java-gradle-plugin'
|
|
|
|
id 'groovy'
|
|
|
|
}
|
2015-10-29 14:40:19 -04:00
|
|
|
|
|
|
|
group = 'org.elasticsearch.gradle'
|
2016-05-07 01:22:38 -04:00
|
|
|
|
2018-07-25 02:21:03 -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-06-18 13:27:48 -04:00
|
|
|
}
|
|
|
|
|
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.
|
2018-11-06 07:00:40 -05:00
|
|
|
File propsFile = project.file('version.properties')
|
|
|
|
Properties props = VersionPropertiesLoader.loadBuildSrcVersion(propsFile)
|
2018-11-01 23:27:40 -04:00
|
|
|
version = props.getProperty("elasticsearch")
|
|
|
|
processResources {
|
2018-11-06 07:00:40 -05:00
|
|
|
inputs.file(propsFile)
|
|
|
|
// We need to be explicit with the version because we add snapshot and qualifier to it based on properties
|
|
|
|
inputs.property("dynamic_elasticsearch_version", props.getProperty("elasticsearch"))
|
2016-05-07 01:22:38 -04:00
|
|
|
doLast {
|
2018-11-01 23:27:40 -04:00
|
|
|
Writer writer = file("$destinationDir/version.properties").newWriter()
|
2016-05-07 01:22:38 -04:00
|
|
|
try {
|
2018-11-01 23:27:40 -04:00
|
|
|
props.store(writer, "Generated version properties")
|
2016-05-07 01:22:38 -04:00
|
|
|
} finally {
|
2018-11-01 23:27:40 -04:00
|
|
|
writer.close()
|
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
|
|
|
// Gradle 4.10 does not support setting this to 11 yet
|
|
|
|
targetCompatibility = "10"
|
|
|
|
sourceCompatibility = "10"
|
|
|
|
|
|
|
|
// We have a few classes that need to be compiled for older java versions because these are used to run checks against
|
|
|
|
// those
|
|
|
|
sourceSets {
|
|
|
|
minimumRuntime {
|
|
|
|
// We only want Java here, but the Groovy doesn't configure javadoc correctly if we don't define this as groovy
|
|
|
|
groovy {
|
|
|
|
srcDirs = ['src/main/minimumRuntime']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
compileMinimumRuntimeGroovy {
|
|
|
|
// We can't use BuildPlugin here, so read from file
|
|
|
|
String minimumRuntimeVersion = file('src/main/resources/minimumRuntimeVersion').text.trim()
|
|
|
|
targetCompatibility = minimumRuntimeVersion
|
|
|
|
sourceCompatibility = minimumRuntimeVersion
|
|
|
|
}
|
|
|
|
dependencies {
|
2018-11-14 04:11:46 -05:00
|
|
|
if (project.ext.has("isEclipse") == false || project.ext.isEclipse == false) {
|
|
|
|
// eclipse is confused if this is set explicitly
|
|
|
|
compile sourceSets.minimumRuntime.output
|
|
|
|
}
|
2018-10-25 03:03:23 -04:00
|
|
|
minimumRuntimeCompile "junit:junit:${props.getProperty('junit')}"
|
|
|
|
minimumRuntimeCompile localGroovy()
|
2018-12-11 13:49:24 -05:00
|
|
|
minimumRuntimeCompile gradleApi()
|
2018-10-25 03:03:23 -04:00
|
|
|
}
|
|
|
|
jar {
|
|
|
|
from sourceSets.minimumRuntime.output
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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 {
|
|
|
|
compile localGroovy()
|
2015-11-10 02:34:22 -05:00
|
|
|
compile "com.carrotsearch.randomizedtesting:junit4-ant:${props.getProperty('randomizedrunner')}"
|
2018-06-28 08:14:34 -04:00
|
|
|
compile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${props.getProperty('randomizedrunner')}"
|
2018-10-25 03:03:23 -04:00
|
|
|
|
2015-10-29 14:40:19 -04:00
|
|
|
compile 'com.netflix.nebula:gradle-extra-configurations-plugin:3.0.3'
|
2016-05-05 20:53:01 -04:00
|
|
|
compile 'com.netflix.nebula:nebula-publishing-plugin:4.4.4'
|
2015-10-29 16:59:10 -04:00
|
|
|
compile 'com.netflix.nebula:gradle-info-plugin:3.0.3'
|
|
|
|
compile 'org.eclipse.jgit:org.eclipse.jgit:3.2.0.201312181205-r'
|
|
|
|
compile 'com.perforce:p4java:2012.3.551082' // THIS IS SUPPOSED TO BE OPTIONAL IN THE FUTURE....
|
2015-12-18 13:59:07 -05:00
|
|
|
compile 'org.apache.rat:apache-rat:0.11'
|
2018-01-11 11:31:10 -05:00
|
|
|
compile "org.elasticsearch:jna:4.5.1"
|
2018-07-17 14:20:41 -04:00
|
|
|
compile 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
|
2018-10-23 05:06:46 -04:00
|
|
|
compile 'de.thetaphi:forbiddenapis:2.6'
|
2018-12-12 05:00:47 -05:00
|
|
|
compile 'com.avast.gradle:gradle-docker-compose-plugin:0.8.12'
|
2018-06-28 08:14:34 -04:00
|
|
|
testCompile "junit:junit:${props.getProperty('junit')}"
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
|
2018-06-28 08:14:34 -04:00
|
|
|
|
2017-03-22 02:32:40 -04:00
|
|
|
// Gradle 2.14+ removed ProgressLogger(-Factory) classes from the public APIs
|
|
|
|
// Use logging dependency instead
|
2017-11-15 08:50:13 -05:00
|
|
|
// Gradle 4.3.1 stopped releasing the logging jars to jcenter, just use the last available one
|
|
|
|
GradleVersion logVersion = GradleVersion.current() > GradleVersion.version('4.3') ? GradleVersion.version('4.3') : GradleVersion.current()
|
2017-01-24 05:03:07 -05:00
|
|
|
|
2017-03-22 02:32:40 -04:00
|
|
|
dependencies {
|
2017-11-15 08:50:13 -05:00
|
|
|
compileOnly "org.gradle:gradle-logging:${logVersion.getVersion()}"
|
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
|
|
|
}
|
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'
|
|
|
|
apply plugin: 'nebula.maven-base-publish'
|
|
|
|
apply plugin: 'nebula.maven-scm'
|
|
|
|
|
2018-12-04 03:16:51 -05:00
|
|
|
// we need to apply these again to override the build plugin
|
|
|
|
targetCompatibility = "10"
|
|
|
|
sourceCompatibility = "10"
|
|
|
|
|
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...
|
|
|
|
dependencyLicenses.enabled = false
|
2017-12-26 04:51:47 -05:00
|
|
|
dependenciesInfo.enabled = false
|
2016-05-07 01:22:38 -04:00
|
|
|
forbiddenApisMain.enabled = false
|
2016-06-03 12:48:45 -04:00
|
|
|
forbiddenApisTest.enabled = false
|
2018-10-25 03:03:23 -04:00
|
|
|
forbiddenApisMinimumRuntime.enabled = false
|
2016-05-07 01:22:38 -04:00
|
|
|
jarHell.enabled = false
|
|
|
|
thirdPartyAudit.enabled = false
|
|
|
|
|
2019-01-21 02:33:11 -05:00
|
|
|
configurations {
|
|
|
|
distribution
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
distribution project(':distribution:archives:zip')
|
|
|
|
distribution project(':distribution:archives:oss-zip')
|
|
|
|
}
|
|
|
|
|
|
|
|
String localDownloads = "${rootProject.buildDir}/local-downloads"
|
|
|
|
task setupLocalDownloads(type:Copy) {
|
|
|
|
from configurations.distribution
|
|
|
|
into localDownloads
|
|
|
|
}
|
|
|
|
|
2018-12-19 01:25:20 -05:00
|
|
|
unitTest {
|
2018-12-06 02:14:50 -05:00
|
|
|
// The test task is configured to runtimeJava version, but build-tools doesn't support all of them, so test
|
2018-12-05 07:44:05 -05:00
|
|
|
// with compiler instead on the ones that are too old.
|
|
|
|
if (project.runtimeJavaVersion <= JavaVersion.VERSION_1_10) {
|
|
|
|
jvm = "${project.compilerJavaHome}/bin/java"
|
|
|
|
}
|
2018-12-05 07:20:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// This can't be an RandomizedTestingTask because we can't yet reference it
|
2018-07-12 04:41:07 -04:00
|
|
|
task integTest(type: Test) {
|
2018-08-17 02:41:39 -04:00
|
|
|
// integration test requires the local testing repo for example plugin builds
|
|
|
|
dependsOn project.rootProject.allprojects.collect {
|
|
|
|
it.tasks.matching { it.name == 'publishNebulaPublicationToLocalTestRepository'}
|
|
|
|
}
|
2019-01-21 02:33:11 -05:00
|
|
|
dependsOn setupLocalDownloads
|
2018-07-12 04:41:07 -04:00
|
|
|
exclude "**/*Tests.class"
|
|
|
|
testClassesDirs = sourceSets.test.output.classesDirs
|
|
|
|
classpath = sourceSets.test.runtimeClasspath
|
|
|
|
inputs.dir(file("src/testKit"))
|
2018-08-17 02:41:39 -04:00
|
|
|
// tell BuildExamplePluginsIT where to find the example plugins
|
|
|
|
systemProperty (
|
|
|
|
'test.build-tools.plugin.examples',
|
|
|
|
files(
|
|
|
|
project(':example-plugins').subprojects.collect { it.projectDir }
|
|
|
|
).asPath,
|
|
|
|
)
|
|
|
|
systemProperty 'test.local-test-repo-path', "${rootProject.buildDir}/local-test-repo"
|
2019-01-21 02:33:11 -05:00
|
|
|
systemProperty 'test.local-test-downloads-path', localDownloads
|
2018-11-14 07:14:03 -05:00
|
|
|
systemProperty 'test.version_under_test', version
|
2018-08-17 02:41:39 -04:00
|
|
|
systemProperty 'test.lucene-snapshot-revision', (versions.lucene =~ /\w+-snapshot-([a-z0-9]+)/)[0][1]
|
2018-07-12 04:41:07 -04:00
|
|
|
}
|
|
|
|
check.dependsOn(integTest)
|
|
|
|
|
2016-05-07 01:22:38 -04:00
|
|
|
// TODO: re-enable once randomizedtesting gradle code is published and removed from here
|
|
|
|
licenseHeaders.enabled = false
|
|
|
|
|
|
|
|
forbiddenPatterns {
|
|
|
|
exclude '**/*.wav'
|
|
|
|
// the file that actually defines nocommit
|
2018-12-11 07:15:44 -05:00
|
|
|
exclude '**/ForbiddenPatternsTask.java'
|
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'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-26 13:19:05 -04:00
|
|
|
/*
|
|
|
|
* We alread configure publication and we don't need or want this one that
|
|
|
|
* comes from the java-gradle-plugin.
|
|
|
|
*/
|
|
|
|
afterEvaluate {
|
|
|
|
generatePomFileForPluginMavenPublication.enabled = false
|
|
|
|
}
|
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(
|
|
|
|
"Expected elasticsearch version to be numbers only of the form X.Y.Z but it was: " +
|
|
|
|
elasticsearch
|
|
|
|
)
|
|
|
|
}
|
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
|
|
|
|
}
|
|
|
|
if ("true".equals(systemProperties.getProperty("build.snapshot", "true"))) {
|
|
|
|
elasticsearch += "-SNAPSHOT"
|
|
|
|
}
|
|
|
|
loadedProps.put("elasticsearch", elasticsearch)
|
|
|
|
}
|
2018-11-14 04:11:46 -05:00
|
|
|
}
|