2015-10-29 14:40:19 -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.
|
|
|
|
*/
|
2018-08-31 09:01:54 -04:00
|
|
|
|
2018-07-17 14:20:41 -04:00
|
|
|
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
|
2018-08-31 09:01:54 -04:00
|
|
|
import org.apache.tools.ant.taskdefs.condition.Os
|
2017-08-25 01:46:30 -04:00
|
|
|
import org.elasticsearch.gradle.BuildPlugin
|
2017-05-18 04:14:24 -04:00
|
|
|
import org.elasticsearch.gradle.Version
|
2019-03-07 06:54:20 -05:00
|
|
|
import org.elasticsearch.gradle.BwcVersions
|
2017-11-21 03:26:45 -05:00
|
|
|
import org.elasticsearch.gradle.VersionProperties
|
2018-08-21 20:03:28 -04:00
|
|
|
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
|
2019-01-07 03:21:25 -05:00
|
|
|
import org.gradle.util.GradleVersion
|
|
|
|
import org.gradle.util.DistributionLocator
|
2017-11-21 03:26:45 -05:00
|
|
|
import org.gradle.plugins.ide.eclipse.model.SourceFolder
|
2018-01-04 16:36:13 -05:00
|
|
|
|
2018-05-22 00:21:16 -04:00
|
|
|
plugins {
|
2019-04-02 23:16:54 -04:00
|
|
|
id 'com.gradle.build-scan' version '2.2.1'
|
2018-11-14 07:14:03 -05:00
|
|
|
id 'base'
|
2018-05-22 00:21:16 -04:00
|
|
|
}
|
|
|
|
if (properties.get("org.elasticsearch.acceptScanTOS", "false") == "true") {
|
|
|
|
buildScan {
|
|
|
|
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
|
|
|
|
termsOfServiceAgree = 'yes'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-29 14:40:19 -04:00
|
|
|
// common maven publishing configuration
|
2018-11-14 04:22:00 -05:00
|
|
|
allprojects {
|
2016-03-17 15:21:31 -04:00
|
|
|
group = 'org.elasticsearch'
|
2018-11-01 23:27:40 -04:00
|
|
|
version = VersionProperties.elasticsearch
|
2016-05-13 19:32:35 -04:00
|
|
|
description = "Elasticsearch subproject ${project.path}"
|
2016-11-24 03:03:43 -05:00
|
|
|
}
|
|
|
|
|
2019-03-07 10:48:49 -05:00
|
|
|
BuildPlugin.configureRepositories(project)
|
|
|
|
|
2018-06-14 16:22:00 -04:00
|
|
|
apply plugin: 'nebula.info-scm'
|
|
|
|
String licenseCommit
|
|
|
|
if (VersionProperties.elasticsearch.toString().endsWith('-SNAPSHOT')) {
|
|
|
|
licenseCommit = scminfo.change ?: "master" // leniency for non git builds
|
|
|
|
} else {
|
|
|
|
licenseCommit = "v${version}"
|
|
|
|
}
|
|
|
|
String elasticLicenseUrl = "https://raw.githubusercontent.com/elastic/elasticsearch/${licenseCommit}/licenses/ELASTIC-LICENSE.txt"
|
|
|
|
|
2018-04-10 16:58:49 -04:00
|
|
|
subprojects {
|
2018-06-14 16:22:00 -04:00
|
|
|
// Default to the apache license
|
2018-04-10 16:58:49 -04:00
|
|
|
project.ext.licenseName = 'The Apache Software License, Version 2.0'
|
|
|
|
project.ext.licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
2018-06-14 16:22:00 -04:00
|
|
|
|
|
|
|
// But stick the Elastic license url in project.ext so we can get it if we need to switch to it
|
|
|
|
project.ext.elasticLicenseUrl = elasticLicenseUrl
|
|
|
|
|
2016-05-05 20:53:01 -04:00
|
|
|
// we only use maven publish to add tasks for pom generation
|
|
|
|
plugins.withType(MavenPublishPlugin).whenPluginAdded {
|
|
|
|
publishing {
|
|
|
|
publications {
|
|
|
|
// add license information to generated poms
|
|
|
|
all {
|
|
|
|
pom.withXml { XmlProvider xml ->
|
|
|
|
Node node = xml.asNode()
|
|
|
|
node.appendNode('inceptionYear', '2009')
|
|
|
|
|
|
|
|
Node license = node.appendNode('licenses').appendNode('license')
|
2018-04-10 16:58:49 -04:00
|
|
|
license.appendNode('name', project.licenseName)
|
|
|
|
license.appendNode('url', project.licenseUrl)
|
2016-05-05 20:53:01 -04:00
|
|
|
license.appendNode('distribution', 'repo')
|
2016-05-13 16:57:08 -04:00
|
|
|
|
|
|
|
Node developer = node.appendNode('developers').appendNode('developer')
|
|
|
|
developer.appendNode('name', 'Elastic')
|
|
|
|
developer.appendNode('url', 'http://www.elastic.co')
|
2016-05-05 20:53:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 02:41:39 -04:00
|
|
|
repositories {
|
|
|
|
maven {
|
|
|
|
name = 'localTest'
|
|
|
|
url = "${rootProject.buildDir}/local-test-repo"
|
|
|
|
}
|
|
|
|
}
|
2016-05-05 20:53:01 -04:00
|
|
|
}
|
|
|
|
}
|
2018-08-17 02:41:39 -04:00
|
|
|
|
2017-08-25 01:46:30 -04:00
|
|
|
plugins.withType(BuildPlugin).whenPluginAdded {
|
2018-04-10 16:58:49 -04:00
|
|
|
project.licenseFile = project.rootProject.file('licenses/APACHE-LICENSE-2.0.txt')
|
2017-08-25 01:46:30 -04:00
|
|
|
project.noticeFile = project.rootProject.file('NOTICE.txt')
|
|
|
|
}
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
|
2017-11-21 03:26:45 -05:00
|
|
|
/* Introspect all versions of ES that may be tested against for backwards
|
2017-05-26 18:36:32 -04:00
|
|
|
* compatibility. It is *super* important that this logic is the same as the
|
2017-08-10 14:30:00 -04:00
|
|
|
* logic in VersionUtils.java, throwing out alphas because they don't have any
|
|
|
|
* backwards compatibility guarantees and only keeping the latest beta or rc
|
|
|
|
* in a branch if there are only betas and rcs in the branch so we have
|
|
|
|
* *something* to test against. */
|
2019-03-07 06:54:20 -05:00
|
|
|
BwcVersions versions = new BwcVersions(file('server/src/main/java/org/elasticsearch/Version.java').readLines('UTF-8'))
|
2017-03-29 15:11:38 -04:00
|
|
|
|
2017-08-28 17:10:06 -04:00
|
|
|
// build metadata from previous build, contains eg hashes for bwc builds
|
|
|
|
String buildMetadataValue = System.getenv('BUILD_METADATA')
|
|
|
|
if (buildMetadataValue == null) {
|
|
|
|
buildMetadataValue = ''
|
|
|
|
}
|
|
|
|
Map<String, String> buildMetadataMap = buildMetadataValue.tokenize(';').collectEntries {
|
|
|
|
def (String key, String value) = it.split('=')
|
|
|
|
return [key, value]
|
|
|
|
}
|
|
|
|
|
2017-03-29 15:11:38 -04:00
|
|
|
// injecting groovy property variables into all projects
|
2015-10-29 14:40:19 -04:00
|
|
|
allprojects {
|
|
|
|
project.ext {
|
2016-02-04 18:44:30 -05:00
|
|
|
// for ide hacks...
|
2018-07-06 12:48:00 -04:00
|
|
|
isEclipse = System.getProperty("eclipse.launcher") != null || // Detects gradle launched from Eclipse's IDE
|
|
|
|
System.getProperty("eclipse.application") != null || // Detects gradle launched from the Eclipse compiler server
|
|
|
|
gradle.startParameter.taskNames.contains('eclipse') || // Detects gradle launched from the command line to do eclipse stuff
|
|
|
|
gradle.startParameter.taskNames.contains('cleanEclipse')
|
2016-02-04 18:44:30 -05:00
|
|
|
isIdea = System.getProperty("idea.active") != null || gradle.startParameter.taskNames.contains('idea') || gradle.startParameter.taskNames.contains('cleanIdea')
|
2017-11-21 03:26:45 -05:00
|
|
|
|
|
|
|
// for BWC testing
|
2018-02-09 15:55:10 -05:00
|
|
|
bwcVersions = versions
|
2017-11-21 03:26:45 -05:00
|
|
|
|
2017-08-28 17:10:06 -04:00
|
|
|
buildMetadata = buildMetadataMap
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-01 13:29:51 -04:00
|
|
|
task verifyVersions {
|
2017-05-26 18:36:32 -04:00
|
|
|
doLast {
|
2017-06-01 13:29:51 -04:00
|
|
|
if (gradle.startParameter.isOffline()) {
|
|
|
|
throw new GradleException("Must run in online mode to verify versions")
|
|
|
|
}
|
2018-11-01 11:43:57 -04:00
|
|
|
// Read the list from maven central.
|
|
|
|
// Fetch the metadata an parse the xml into Version instances because it's more straight forward here
|
|
|
|
// rather than bwcVersion ( VersionCollection ).
|
2017-05-26 18:36:32 -04:00
|
|
|
new URL('https://repo1.maven.org/maven2/org/elasticsearch/elasticsearch/maven-metadata.xml').openStream().withStream { s ->
|
2018-11-01 11:43:57 -04:00
|
|
|
bwcVersions.compareToAuthoritative(
|
|
|
|
new XmlParser().parse(s)
|
|
|
|
.versioning.versions.version
|
|
|
|
.collect { it.text() }.findAll { it ==~ /\d+\.\d+\.\d+/ }
|
|
|
|
.collect { Version.fromString(it) }
|
|
|
|
)
|
2017-05-26 18:36:32 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-06-01 13:29:51 -04:00
|
|
|
|
2017-06-15 01:01:49 -04: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-03-15 17:16:25 -04:00
|
|
|
|
2019-03-19 18:27:49 -04:00
|
|
|
boolean bwc_tests_enabled = true
|
|
|
|
final String bwc_tests_disabled_issue = "" /* place a PR link here when committing bwc changes */
|
2018-02-09 14:26:22 -05: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 10:19:28 -05: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
|
|
|
|
}
|
|
|
|
|
2018-02-09 14:26:22 -05:00
|
|
|
subprojects {
|
|
|
|
ext.bwc_tests_enabled = bwc_tests_enabled
|
2017-06-15 01:01:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
task verifyBwcTestsEnabled {
|
|
|
|
doLast {
|
2018-02-09 14:26:22 -05:00
|
|
|
if (bwc_tests_enabled == false) {
|
2017-06-15 01:01:49 -04:00
|
|
|
throw new GradleException('Bwc tests are disabled. They must be re-enabled after completing backcompat behavior backporting.')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-01 13:29:51 -04:00
|
|
|
task branchConsistency {
|
|
|
|
description 'Ensures this branch is internally consistent. For example, that versions constants match released versions.'
|
|
|
|
group 'Verification'
|
2017-06-15 01:01:49 -04:00
|
|
|
dependsOn verifyVersions, verifyBwcTestsEnabled
|
2017-05-26 18:36:32 -04:00
|
|
|
}
|
|
|
|
|
2018-11-14 04:22:00 -05:00
|
|
|
allprojects {
|
2017-09-11 18:43:34 -04:00
|
|
|
// ignore missing javadocs
|
|
|
|
tasks.withType(Javadoc) { Javadoc javadoc ->
|
|
|
|
// 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
|
|
|
|
javadoc.options.encoding='UTF8'
|
|
|
|
javadoc.options.addStringOption('Xdoclint:all,-missing', '-quiet')
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
|
2015-11-25 19:21:38 -05:00
|
|
|
/* Sets up the dependencies that we build as part of this project but
|
2019-01-31 02:06:05 -05:00
|
|
|
register as though they were external to resolve internally. We register
|
2015-11-25 19:21:38 -05:00
|
|
|
them as external dependencies so the build plugin that we use can be used
|
|
|
|
to build elasticsearch plugins outside of the elasticsearch source tree. */
|
2015-11-22 04:12:17 -05:00
|
|
|
ext.projectSubstitutions = [
|
2016-06-03 12:48:45 -04:00
|
|
|
"org.elasticsearch.gradle:build-tools:${version}": ':build-tools',
|
2015-11-20 14:58:50 -05:00
|
|
|
"org.elasticsearch:rest-api-spec:${version}": ':rest-api-spec',
|
2018-01-11 13:30:43 -05:00
|
|
|
"org.elasticsearch:elasticsearch:${version}": ':server',
|
2018-07-19 02:46:58 -04:00
|
|
|
"org.elasticsearch:elasticsearch-cli:${version}": ':libs:elasticsearch-cli',
|
2018-06-07 16:50:21 -04:00
|
|
|
"org.elasticsearch:elasticsearch-core:${version}": ':libs:core',
|
2018-06-07 17:00:00 -04:00
|
|
|
"org.elasticsearch:elasticsearch-nio:${version}": ':libs:nio',
|
2018-04-02 17:58:31 -04:00
|
|
|
"org.elasticsearch:elasticsearch-x-content:${version}": ':libs:x-content',
|
2019-01-25 11:37:27 -05:00
|
|
|
"org.elasticsearch:elasticsearch-geo:${version}": ':libs:elasticsearch-geo',
|
2018-01-31 18:16:59 -05:00
|
|
|
"org.elasticsearch:elasticsearch-secure-sm:${version}": ':libs:secure-sm',
|
2019-01-31 02:06:05 -05:00
|
|
|
"org.elasticsearch:elasticsearch-ssl-config:${version}": ':libs:elasticsearch-ssl-config',
|
2017-07-13 03:44:25 -04:00
|
|
|
"org.elasticsearch.client:elasticsearch-rest-client:${version}": ':client:rest',
|
|
|
|
"org.elasticsearch.client:elasticsearch-rest-client-sniffer:${version}": ':client:sniffer',
|
|
|
|
"org.elasticsearch.client:elasticsearch-rest-high-level-client:${version}": ':client:rest-high-level',
|
2016-06-22 13:40:01 -04:00
|
|
|
"org.elasticsearch.client:test:${version}": ':client:test',
|
2016-07-26 11:54:46 -04:00
|
|
|
"org.elasticsearch.client:transport:${version}": ':client:transport',
|
2018-08-17 02:41:39 -04:00
|
|
|
"org.elasticsearch.plugin:elasticsearch-scripting-painless-spi:${version}": ':modules:lang-painless:spi',
|
2015-12-17 19:57:39 -05:00
|
|
|
"org.elasticsearch.test:framework:${version}": ':test:framework',
|
2016-02-16 18:32:21 -05:00
|
|
|
"org.elasticsearch.test:logger-usage:${version}": ':test:logger-usage',
|
2018-06-05 19:56:22 -04:00
|
|
|
"org.elasticsearch.xpack.test:feature-aware:${version}": ':x-pack:test:feature-aware',
|
2016-07-15 17:34:21 -04:00
|
|
|
// for transport client
|
2016-07-22 22:26:35 -04:00
|
|
|
"org.elasticsearch.plugin:transport-netty4-client:${version}": ':modules:transport-netty4',
|
2016-07-15 17:34:21 -04:00
|
|
|
"org.elasticsearch.plugin:reindex-client:${version}": ':modules:reindex',
|
|
|
|
"org.elasticsearch.plugin:lang-mustache-client:${version}": ':modules:lang-mustache',
|
2017-05-12 09:58:06 -04:00
|
|
|
"org.elasticsearch.plugin:parent-join-client:${version}": ':modules:parent-join',
|
2017-05-23 07:33:54 -04:00
|
|
|
"org.elasticsearch.plugin:aggs-matrix-stats-client:${version}": ':modules:aggs-matrix-stats',
|
2016-07-15 17:34:21 -04:00
|
|
|
"org.elasticsearch.plugin:percolator-client:${version}": ':modules:percolator',
|
2017-12-13 10:26:47 -05:00
|
|
|
"org.elasticsearch.plugin:rank-eval-client:${version}": ':modules:rank-eval',
|
2019-02-05 15:39:29 -05:00
|
|
|
// for security example plugins
|
|
|
|
"org.elasticsearch.plugin:x-pack-core:${version}": ':x-pack:plugin:core',
|
2019-03-04 01:37:43 -05:00
|
|
|
"org.elasticsearch.client:x-pack-transport:${version}": ':x-pack:transport-client'
|
2015-11-22 04:12:17 -05:00
|
|
|
]
|
2017-11-21 03:26:45 -05:00
|
|
|
|
2018-04-16 11:49:27 -04:00
|
|
|
/*
|
|
|
|
* Gradle only resolve project substitutions during dependency resolution but
|
|
|
|
* we sometimes want to do the resolution at other times. This creates a
|
|
|
|
* convenient method we can call to do it.
|
|
|
|
*/
|
|
|
|
ext.dependencyToProject = { Dependency dep ->
|
|
|
|
if (dep instanceof ProjectDependency) {
|
|
|
|
return dep.dependencyProject
|
|
|
|
} else {
|
|
|
|
String substitution = projectSubstitutions.get("${dep.group}:${dep.name}:${dep.version}")
|
|
|
|
if (substitution != null) {
|
|
|
|
return findProject(substitution)
|
|
|
|
}
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-24 01:32:13 -04:00
|
|
|
project.afterEvaluate {
|
|
|
|
configurations.all {
|
|
|
|
resolutionStrategy.dependencySubstitution { DependencySubstitutions subs ->
|
|
|
|
projectSubstitutions.each { k,v ->
|
|
|
|
subs.substitute(subs.module(k)).with(subs.project(v))
|
|
|
|
}
|
2015-11-22 04:12:17 -05:00
|
|
|
}
|
|
|
|
}
|
2017-09-11 18:43:34 -04: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-11 13:30:43 -05:00
|
|
|
// other packages (e.g org.elasticsearch.client) will point to server rather than
|
2017-09-11 18:43:34 -04:00
|
|
|
// their own artifacts.
|
2018-08-21 20:03:28 -04:00
|
|
|
if (project.plugins.hasPlugin(BuildPlugin) || project.plugins.hasPlugin(PluginBuildPlugin)) {
|
2018-11-01 23:27:40 -04:00
|
|
|
String artifactsHost = VersionProperties.elasticsearch.endsWith("-SNAPSHOT") ? "https://snapshots.elastic.co" : "https://artifacts.elastic.co"
|
2017-09-11 18:43:34 -04:00
|
|
|
Closure sortClosure = { a, b -> b.group <=> a.group }
|
2018-07-17 14:20:41 -04:00
|
|
|
Closure depJavadocClosure = { shadowed, dep ->
|
|
|
|
if (dep.group == null || false == dep.group.startsWith('org.elasticsearch')) {
|
|
|
|
return
|
|
|
|
}
|
2018-11-14 04:22:00 -05:00
|
|
|
Project upstreamProject = project.ext.dependencyToProject(dep)
|
2018-07-17 14:20:41 -04: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"
|
|
|
|
String artifactPath = dep.group.replaceAll('\\.', '/') + '/' + dep.name.replaceAll('\\.', '/') + '/' + dep.version
|
|
|
|
project.javadoc.options.linksOffline artifactsHost + "/javadoc/" + artifactPath, "${upstreamProject.buildDir}/docs/javadoc/"
|
2017-09-11 18:43:34 -04:00
|
|
|
}
|
|
|
|
}
|
2018-07-17 14:20:41 -04:00
|
|
|
boolean hasShadow = project.plugins.hasPlugin(ShadowPlugin)
|
|
|
|
project.configurations.compile.dependencies
|
|
|
|
.findAll()
|
|
|
|
.toSorted(sortClosure)
|
2018-08-21 20:03:28 -04:00
|
|
|
.each({ c -> depJavadocClosure(false, c) })
|
2018-07-17 14:20:41 -04:00
|
|
|
project.configurations.compileOnly.dependencies
|
|
|
|
.findAll()
|
|
|
|
.toSorted(sortClosure)
|
2018-08-21 20:03:28 -04:00
|
|
|
.each({ c -> depJavadocClosure(false, c) })
|
2018-07-17 14:20:41 -04:00
|
|
|
if (hasShadow) {
|
2018-08-21 20:03:28 -04:00
|
|
|
project.configurations.bundle.dependencies
|
2018-07-17 14:20:41 -04:00
|
|
|
.findAll()
|
|
|
|
.toSorted(sortClosure)
|
2018-08-21 20:03:28 -04:00
|
|
|
.each({ c -> depJavadocClosure(true, c) })
|
2018-07-17 14:20:41 -04:00
|
|
|
}
|
2017-09-11 18:43:34 -04:00
|
|
|
}
|
2015-11-22 04:12:17 -05: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.
|
|
|
|
gradle.projectsEvaluated {
|
|
|
|
allprojects {
|
2017-08-25 15:13:12 -04:00
|
|
|
if (project.path == ':test:framework') {
|
2018-01-11 13:30:43 -05:00
|
|
|
// :test:framework:test cannot run before and after :server:test
|
2015-11-22 04:12:17 -05:00
|
|
|
return
|
|
|
|
}
|
2018-06-28 01:13:21 -04:00
|
|
|
if (tasks.findByPath('test') != null && tasks.findByPath('integTest') != null) {
|
|
|
|
integTest.mustRunAfter test
|
|
|
|
}
|
2018-06-05 19:56:22 -04:00
|
|
|
configurations.all { Configuration configuration ->
|
|
|
|
/*
|
|
|
|
* The featureAwarePlugin configuration has a dependency on x-pack:plugin:core and x-pack:plugin:core has a dependency on the
|
|
|
|
* featureAwarePlugin configuration. The below task ordering logic would force :x-pack:plugin:core:test
|
|
|
|
* :x-pack:test:feature-aware:test to depend on each other circularly. We break that cycle here.
|
|
|
|
*/
|
|
|
|
if (configuration.name == "featureAwarePlugin") {
|
|
|
|
return
|
|
|
|
}
|
2015-11-22 04:12:17 -05:00
|
|
|
dependencies.all { Dependency dep ->
|
2018-04-16 11:49:27 -04:00
|
|
|
Project upstreamProject = dependencyToProject(dep)
|
2015-11-22 04:12:17 -05:00
|
|
|
if (upstreamProject != null) {
|
|
|
|
if (project.path == upstreamProject.path) {
|
|
|
|
// TODO: distribution integ tests depend on themselves (!), fix that
|
|
|
|
return
|
|
|
|
}
|
|
|
|
for (String taskName : ['test', 'integTest']) {
|
|
|
|
Task task = project.tasks.findByName(taskName)
|
|
|
|
Task upstreamTask = upstreamProject.tasks.findByName(taskName)
|
|
|
|
if (task != null && upstreamTask != null) {
|
|
|
|
task.mustRunAfter(upstreamTask)
|
|
|
|
}
|
|
|
|
}
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-31 00:32:16 -04:00
|
|
|
// intellij configuration
|
2015-10-29 14:40:19 -04:00
|
|
|
allprojects {
|
|
|
|
apply plugin: 'idea'
|
2015-12-15 11:32:21 -05:00
|
|
|
|
2016-02-04 18:44:30 -05:00
|
|
|
if (isIdea) {
|
|
|
|
project.buildDir = file('build-idea')
|
|
|
|
}
|
2015-12-15 11:32:21 -05:00
|
|
|
idea {
|
|
|
|
module {
|
|
|
|
inheritOutputDirs = false
|
2016-02-04 18:44:30 -05:00
|
|
|
outputDir = file('build-idea/classes/main')
|
|
|
|
testOutputDir = file('build-idea/classes/test')
|
2015-12-15 11:32:21 -05:00
|
|
|
|
2016-04-14 17:54:52 -04:00
|
|
|
// also ignore other possible build dirs
|
|
|
|
excludeDirs += file('build')
|
|
|
|
excludeDirs += file('build-eclipse')
|
|
|
|
|
2015-12-15 11:32:21 -05:00
|
|
|
iml {
|
|
|
|
// fix so that Gradle idea plugin properly generates support for resource folders
|
|
|
|
// see also https://issues.gradle.org/browse/GRADLE-2975
|
|
|
|
withXml {
|
|
|
|
it.asNode().component.content.sourceFolder.findAll { it.@url == 'file://$MODULE_DIR$/src/main/resources' }.each {
|
|
|
|
it.attributes().remove('isTestSource')
|
|
|
|
it.attributes().put('type', 'java-resource')
|
|
|
|
}
|
|
|
|
it.asNode().component.content.sourceFolder.findAll { it.@url == 'file://$MODULE_DIR$/src/test/resources' }.each {
|
|
|
|
it.attributes().remove('isTestSource')
|
|
|
|
it.attributes().put('type', 'java-test-resource')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-12-22 12:24:13 -05:00
|
|
|
|
|
|
|
task cleanIdeaBuildDir(type: Delete) {
|
|
|
|
delete 'build-idea'
|
|
|
|
}
|
|
|
|
cleanIdeaBuildDir.setGroup("ide")
|
|
|
|
cleanIdeaBuildDir.setDescription("Deletes the IDEA build directory.")
|
|
|
|
|
|
|
|
tasks.cleanIdea.dependsOn(cleanIdeaBuildDir)
|
2015-10-31 00:32:16 -04:00
|
|
|
}
|
|
|
|
|
2015-11-20 14:58:50 -05:00
|
|
|
idea {
|
|
|
|
project {
|
|
|
|
vcs = 'Git'
|
2015-10-31 00:32:16 -04:00
|
|
|
}
|
|
|
|
}
|
2015-11-22 19:07:39 -05:00
|
|
|
// Make sure gradle idea was run before running anything in intellij (including import).
|
|
|
|
File ideaMarker = new File(projectDir, '.local-idea-is-configured')
|
|
|
|
tasks.idea.doLast {
|
|
|
|
ideaMarker.setText('', 'UTF-8')
|
|
|
|
}
|
|
|
|
if (System.getProperty('idea.active') != null && ideaMarker.exists() == false) {
|
2019-01-07 07:06:06 -05:00
|
|
|
throw new GradleException('You must run `./gradlew idea` from the root of elasticsearch before importing into IntelliJ')
|
2015-11-22 19:07:39 -05:00
|
|
|
}
|
2015-10-31 00:32:16 -04:00
|
|
|
|
2015-10-31 02:39:35 -04:00
|
|
|
// eclipse configuration
|
2015-10-31 00:32:16 -04:00
|
|
|
allprojects {
|
2015-10-29 14:40:19 -04:00
|
|
|
apply plugin: 'eclipse'
|
2016-01-28 17:40:29 -05:00
|
|
|
// Name all the non-root projects after their path so that paths get grouped together when imported into eclipse.
|
|
|
|
if (path != ':') {
|
|
|
|
eclipse.project.name = path
|
2016-04-28 10:08:21 -04:00
|
|
|
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
2016-04-28 10:02:11 -04:00
|
|
|
eclipse.project.name = eclipse.project.name.replace(':', '_')
|
|
|
|
}
|
2016-01-28 17:40:29 -05:00
|
|
|
}
|
2015-10-29 14:40:19 -04:00
|
|
|
|
2015-10-31 02:39:35 -04:00
|
|
|
plugins.withType(JavaBasePlugin) {
|
2016-02-04 18:44:30 -05:00
|
|
|
File eclipseBuild = project.file('build-eclipse')
|
|
|
|
eclipse.classpath.defaultOutputDir = eclipseBuild
|
|
|
|
if (isEclipse) {
|
|
|
|
// set this so generated dirs will be relative to eclipse build
|
|
|
|
project.buildDir = eclipseBuild
|
2018-07-12 04:55:31 -04:00
|
|
|
// Work around https://docs.gradle.org/current/userguide/java_gradle_plugin.html confusing Eclipse by the metadata
|
|
|
|
// it adds to the classpath
|
|
|
|
project.file("$buildDir/pluginUnderTestMetadata").mkdirs()
|
2016-02-04 18:44:30 -05:00
|
|
|
}
|
2015-10-31 02:39:35 -04:00
|
|
|
eclipse.classpath.file.whenMerged { classpath ->
|
|
|
|
// give each source folder a unique corresponding output folder
|
|
|
|
int i = 0;
|
|
|
|
classpath.entries.findAll { it instanceof SourceFolder }.each { folder ->
|
|
|
|
i++;
|
|
|
|
// this is *NOT* a path or a file.
|
2016-02-04 18:44:30 -05:00
|
|
|
folder.output = "build-eclipse/" + i
|
2015-10-31 02:39:35 -04:00
|
|
|
}
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
}
|
2018-05-03 03:48:49 -04:00
|
|
|
|
|
|
|
File licenseHeaderFile;
|
2018-07-05 05:28:40 -04:00
|
|
|
String prefix = ':x-pack';
|
2018-07-06 12:48:00 -04:00
|
|
|
|
2018-07-05 05:28:40 -04:00
|
|
|
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
|
|
|
prefix = prefix.replace(':', '_')
|
|
|
|
}
|
|
|
|
if (eclipse.project.name.startsWith(prefix)) {
|
2018-05-03 03:48:49 -04:00
|
|
|
licenseHeaderFile = new File(project.rootDir, 'buildSrc/src/main/resources/license-headers/elastic-license-header.txt')
|
|
|
|
} else {
|
|
|
|
licenseHeaderFile = new File(project.rootDir, 'buildSrc/src/main/resources/license-headers/oss-license-header.txt')
|
|
|
|
}
|
2018-07-06 12:48:00 -04:00
|
|
|
|
2018-07-05 05:28:40 -04:00
|
|
|
String lineSeparator = Os.isFamily(Os.FAMILY_WINDOWS) ? '\\\\r\\\\n' : '\\\\n'
|
|
|
|
String licenseHeader = licenseHeaderFile.getText('UTF-8').replace(System.lineSeparator(), lineSeparator)
|
2015-11-02 10:44:51 -05:00
|
|
|
task copyEclipseSettings(type: Copy) {
|
|
|
|
// TODO: "package this up" for external builds
|
|
|
|
from new File(project.rootDir, 'buildSrc/src/main/resources/eclipse.settings')
|
|
|
|
into '.settings'
|
2018-05-03 03:48:49 -04:00
|
|
|
filter{ it.replaceAll('@@LICENSE_HEADER_TEXT@@', licenseHeader)}
|
2015-11-02 10:44:51 -05:00
|
|
|
}
|
2015-11-02 09:39:14 -05:00
|
|
|
// otherwise .settings is not nuked entirely
|
2016-05-31 17:20:21 -04:00
|
|
|
task wipeEclipseSettings(type: Delete) {
|
2015-11-11 22:26:55 -05:00
|
|
|
delete '.settings'
|
|
|
|
}
|
2016-05-31 17:20:21 -04:00
|
|
|
tasks.cleanEclipse.dependsOn(wipeEclipseSettings)
|
2015-10-30 23:00:05 -04:00
|
|
|
// otherwise the eclipse merging is *super confusing*
|
2015-11-11 22:26:55 -05:00
|
|
|
tasks.eclipse.dependsOn(cleanEclipse, copyEclipseSettings)
|
2018-08-31 09:01:54 -04:00
|
|
|
|
|
|
|
// work arround https://github.com/gradle/gradle/issues/6582
|
|
|
|
tasks.eclipseProject.mustRunAfter tasks.cleanEclipseProject
|
|
|
|
tasks.matching { it.name == 'eclipseClasspath' }.all {
|
|
|
|
it.mustRunAfter { tasks.cleanEclipseClasspath }
|
|
|
|
}
|
|
|
|
tasks.matching { it.name == 'eclipseJdt' }.all {
|
|
|
|
it.mustRunAfter { tasks.cleanEclipseJdt }
|
|
|
|
}
|
|
|
|
tasks.copyEclipseSettings.mustRunAfter tasks.wipeEclipseSettings
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
|
2018-07-24 11:53:04 -04:00
|
|
|
allprojects {
|
|
|
|
/*
|
|
|
|
* IntelliJ and Eclipse don't know about the shadow plugin so when we're
|
2018-08-21 20:03:28 -04:00
|
|
|
* in "IntelliJ mode" or "Eclipse mode" switch "bundle" dependencies into
|
|
|
|
* regular "compile" dependencies. This isn't needed for the project
|
2018-07-24 11:53:04 -04:00
|
|
|
* itself because the IDE configuration is done by SourceSets but it is
|
|
|
|
* *is* needed for projects that depends on the project doing the shadowing.
|
|
|
|
* Without this they won't properly depend on the shadowed project.
|
|
|
|
*/
|
|
|
|
if (isEclipse || isIdea) {
|
2018-08-21 20:03:28 -04:00
|
|
|
project.plugins.withType(ShadowPlugin).whenPluginAdded {
|
|
|
|
project.afterEvaluate {
|
|
|
|
project.configurations.compile.extendsFrom project.configurations.bundle
|
|
|
|
}
|
|
|
|
}
|
2018-07-24 11:53:04 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-17 18:37:26 -05:00
|
|
|
// we need to add the same --debug-jvm option as
|
|
|
|
// the real RunTask has, so we can pass it through
|
|
|
|
class Run extends DefaultTask {
|
|
|
|
boolean debug = false
|
|
|
|
|
2018-12-05 07:06:11 -05:00
|
|
|
@Option(
|
2015-11-17 18:37:26 -05:00
|
|
|
option = "debug-jvm",
|
|
|
|
description = "Enable debugging configuration, to allow attaching a debugger to elasticsearch."
|
|
|
|
)
|
|
|
|
public void setDebug(boolean enabled) {
|
|
|
|
project.project(':distribution').run.clusterConfig.debug = enabled
|
2015-11-25 19:21:38 -05:00
|
|
|
}
|
2015-11-17 18:37:26 -05:00
|
|
|
}
|
|
|
|
task run(type: Run) {
|
2015-11-16 19:02:44 -05:00
|
|
|
dependsOn ':distribution:run'
|
|
|
|
description = 'Runs elasticsearch in the foreground'
|
|
|
|
group = 'Verification'
|
2015-11-19 01:22:47 -05:00
|
|
|
impliesSubProjects = true
|
2015-11-16 19:02:44 -05:00
|
|
|
}
|
2017-06-16 11:46:34 -04:00
|
|
|
|
2018-06-29 15:17:19 -04:00
|
|
|
wrapper {
|
2018-07-25 02:21:03 -04:00
|
|
|
distributionType = 'ALL'
|
2018-06-29 15:17:19 -04:00
|
|
|
doLast {
|
2018-05-01 19:46:06 -04:00
|
|
|
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"
|
2018-06-29 15:17:19 -04:00
|
|
|
println "Added checksum to wrapper properties"
|
2018-07-25 02:21:03 -04:00
|
|
|
// Update build-tools to reflect the Gradle upgrade
|
|
|
|
// TODO: we can remove this once we have tests to make sure older versions work.
|
|
|
|
project(':build-tools').file('src/main/resources/minimumGradleVersion').text = gradleVersion
|
|
|
|
println "Updated minimum Gradle Version"
|
2018-05-01 19:46:06 -04:00
|
|
|
}
|
2018-01-04 16:36:13 -05:00
|
|
|
}
|
|
|
|
|
2017-06-16 11:46:34 -04:00
|
|
|
gradle.projectsEvaluated {
|
|
|
|
subprojects {
|
2018-11-05 16:16:00 -05:00
|
|
|
/*
|
|
|
|
* 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:')) {
|
2017-06-16 11:46:34 -04:00
|
|
|
Task assemble = project.tasks.findByName('assemble')
|
|
|
|
if (assemble) {
|
2018-09-04 00:32:14 -04:00
|
|
|
assemble.enabled = false
|
2017-06-16 11:46:34 -04:00
|
|
|
}
|
2018-06-09 07:28:41 -04:00
|
|
|
Task dependenciesInfo = project.tasks.findByName('dependenciesInfo')
|
|
|
|
if (dependenciesInfo) {
|
2018-09-04 00:32:14 -04:00
|
|
|
dependenciesInfo.enabled = false
|
2018-06-09 07:28:41 -04:00
|
|
|
}
|
2017-06-16 11:46:34 -04:00
|
|
|
}
|
|
|
|
}
|
2018-07-19 02:46:58 -04: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(
|
|
|
|
"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"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2017-06-16 11:46:34 -04:00
|
|
|
}
|
2018-06-28 01:13:21 -04:00
|
|
|
|
|
|
|
if (System.properties.get("build.compare") != null) {
|
|
|
|
apply plugin: 'compare-gradle-builds'
|
|
|
|
compareGradleBuilds {
|
|
|
|
ext.referenceProject = System.properties.get("build.compare")
|
|
|
|
doFirst {
|
|
|
|
if (file(referenceProject).exists() == false) {
|
|
|
|
throw new GradleException(
|
|
|
|
"Use git worktree to check out a version to compare against to ../elasticsearch_build_reference"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sourceBuild {
|
2018-07-17 07:41:31 -04:00
|
|
|
gradleVersion = gradle.getGradleVersion()
|
2018-06-28 01:13:21 -04:00
|
|
|
projectDir = referenceProject
|
|
|
|
tasks = ["clean", "assemble"]
|
|
|
|
arguments = ["-Dbuild.compare_friendly=true"]
|
|
|
|
}
|
|
|
|
targetBuild {
|
|
|
|
tasks = ["clean", "assemble"]
|
|
|
|
// use -Dorg.gradle.java.home= to alter jdk versions
|
|
|
|
arguments = ["-Dbuild.compare_friendly=true"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-09-14 16:14:03 -04:00
|
|
|
|
|
|
|
allprojects {
|
|
|
|
task resolveAllDependencies {
|
2019-02-18 07:10:10 -05:00
|
|
|
dependsOn tasks.matching { it.name == "pullFixture"}
|
|
|
|
doLast {
|
|
|
|
configurations.findAll { it.isCanBeResolved() }.each { it.resolve() }
|
|
|
|
}
|
2018-09-14 16:14:03 -04:00
|
|
|
}
|
|
|
|
}
|
2018-11-20 13:35:53 -05:00
|
|
|
|
|
|
|
allprojects {
|
|
|
|
task checkPart1
|
|
|
|
task checkPart2
|
|
|
|
tasks.matching { it.name == "check" }.all { check ->
|
|
|
|
if (check.path.startsWith(":x-pack:")) {
|
|
|
|
checkPart2.dependsOn check
|
|
|
|
} else {
|
|
|
|
checkPart1.dependsOn check
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|