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.
|
|
|
|
*/
|
|
|
|
|
2017-01-17 16:38:32 -05:00
|
|
|
import java.nio.file.Path
|
2017-03-29 15:11:38 -04:00
|
|
|
import java.util.regex.Matcher
|
2016-04-15 11:13:12 -04:00
|
|
|
import org.eclipse.jgit.lib.Repository
|
|
|
|
import org.eclipse.jgit.lib.RepositoryBuilder
|
2015-10-31 02:39:35 -04:00
|
|
|
import org.gradle.plugins.ide.eclipse.model.SourceFolder
|
2016-04-28 10:02:11 -04:00
|
|
|
import org.apache.tools.ant.taskdefs.condition.Os
|
2017-08-25 01:46:30 -04:00
|
|
|
import org.elasticsearch.gradle.BuildPlugin
|
2017-03-29 15:11:38 -04:00
|
|
|
import org.elasticsearch.gradle.VersionProperties
|
2017-05-18 04:14:24 -04:00
|
|
|
import org.elasticsearch.gradle.Version
|
2015-10-29 14:40:19 -04:00
|
|
|
|
|
|
|
// common maven publishing configuration
|
|
|
|
subprojects {
|
2016-03-17 15:21:31 -04:00
|
|
|
group = 'org.elasticsearch'
|
2017-03-29 15:11:38 -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
|
|
|
}
|
|
|
|
|
2017-01-17 16:38:32 -05:00
|
|
|
Path rootPath = rootDir.toPath()
|
2016-11-24 03:03:43 -05:00
|
|
|
// setup pom license info, but only for artifacts that are part of elasticsearch
|
2017-01-17 16:38:32 -05:00
|
|
|
configure(subprojects.findAll { it.projectDir.toPath().startsWith(rootPath) }) {
|
2016-03-17 15:21:31 -04:00
|
|
|
|
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')
|
|
|
|
license.appendNode('name', 'The Apache Software License, Version 2.0')
|
|
|
|
license.appendNode('url', 'http://www.apache.org/licenses/LICENSE-2.0.txt')
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-08-25 01:46:30 -04:00
|
|
|
plugins.withType(BuildPlugin).whenPluginAdded {
|
|
|
|
project.licenseFile = project.rootProject.file('LICENSE.txt')
|
|
|
|
project.noticeFile = project.rootProject.file('NOTICE.txt')
|
|
|
|
}
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
|
2017-05-26 18:36:32 -04:00
|
|
|
/* Introspect all versions of ES that may be tested agains for backwards
|
|
|
|
* 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. */
|
2017-05-18 04:14:24 -04:00
|
|
|
Version currentVersion = Version.fromString(VersionProperties.elasticsearch.minus('-SNAPSHOT'))
|
|
|
|
int prevMajor = currentVersion.major - 1
|
2017-03-29 15:11:38 -04:00
|
|
|
File versionFile = file('core/src/main/java/org/elasticsearch/Version.java')
|
|
|
|
List<String> versionLines = versionFile.readLines('UTF-8')
|
2017-05-18 04:14:24 -04:00
|
|
|
List<Version> versions = []
|
2017-05-17 15:58:37 -04:00
|
|
|
// keep track of the previous major version's last minor, so we know where wire compat begins
|
|
|
|
int prevMinorIndex = -1 // index in the versions list of the last minor from the prev major
|
|
|
|
int lastPrevMinor = -1 // the minor version number from the prev major we most recently seen
|
2017-11-16 13:38:54 -05:00
|
|
|
int prevBugfixIndex = -1 // index in the versions list of the last bugfix release from the prev major
|
2017-03-29 15:11:38 -04:00
|
|
|
for (String line : versionLines) {
|
2017-05-26 18:36:32 -04:00
|
|
|
/* Note that this skips alphas and betas which is fine because they aren't
|
|
|
|
* compatible with anything. */
|
2017-08-01 15:47:48 -04:00
|
|
|
Matcher match = line =~ /\W+public static final Version V_(\d+)_(\d+)_(\d+)(_beta\d+|_rc\d+)? .*/
|
2017-03-29 15:11:38 -04:00
|
|
|
if (match.matches()) {
|
2017-05-17 15:58:37 -04:00
|
|
|
int major = Integer.parseInt(match.group(1))
|
|
|
|
int minor = Integer.parseInt(match.group(2))
|
|
|
|
int bugfix = Integer.parseInt(match.group(3))
|
2017-08-10 14:30:00 -04:00
|
|
|
String suffix = (match.group(4) ?: '').replace('_', '-')
|
|
|
|
Version foundVersion = new Version(major, minor, bugfix, suffix, false)
|
2017-08-01 15:47:48 -04:00
|
|
|
if (currentVersion != foundVersion
|
2017-08-10 14:30:00 -04:00
|
|
|
&& (major == prevMajor || major == currentVersion.major)) {
|
|
|
|
if (versions.isEmpty() || versions.last() != foundVersion) {
|
|
|
|
versions.add(foundVersion)
|
|
|
|
} else {
|
|
|
|
// Replace the earlier betas with later ones
|
|
|
|
Version last = versions.set(versions.size() - 1, foundVersion)
|
|
|
|
if (last.suffix == '') {
|
|
|
|
throw new InvalidUserDataException("Found two equal versions but"
|
|
|
|
+ " the first one [$last] wasn't a beta.")
|
|
|
|
}
|
|
|
|
}
|
2017-08-01 15:47:48 -04:00
|
|
|
if (major == prevMajor && minor > lastPrevMinor) {
|
|
|
|
prevMinorIndex = versions.size() - 1
|
|
|
|
lastPrevMinor = minor
|
|
|
|
}
|
2017-05-17 15:58:37 -04:00
|
|
|
}
|
2017-11-16 13:38:54 -05:00
|
|
|
if (major == prevMajor) {
|
|
|
|
prevBugfixIndex = versions.size() - 1
|
|
|
|
}
|
2017-03-29 15:11:38 -04:00
|
|
|
}
|
|
|
|
}
|
2017-05-18 04:14:24 -04:00
|
|
|
if (versions.toSorted { it.id } != versions) {
|
2017-05-18 09:33:13 -04:00
|
|
|
println "Versions: ${versions}"
|
2017-05-18 04:14:24 -04:00
|
|
|
throw new GradleException("Versions.java contains out of order version constants")
|
2017-05-17 15:58:37 -04:00
|
|
|
}
|
2017-11-16 13:38:54 -05:00
|
|
|
if (prevBugfixIndex != -1) {
|
|
|
|
versions[prevBugfixIndex] = new Version(versions[prevBugfixIndex].major, versions[prevBugfixIndex].minor,
|
|
|
|
versions[prevBugfixIndex].bugfix, versions[prevBugfixIndex].suffix, true)
|
|
|
|
}
|
2017-05-18 04:14:24 -04:00
|
|
|
if (currentVersion.bugfix == 0) {
|
2017-05-17 15:58:37 -04:00
|
|
|
// If on a release branch, after the initial release of that branch, the bugfix version will
|
|
|
|
// be bumped, and will be != 0. On master and N.x branches, we want to test against the
|
|
|
|
// unreleased version of closest branch. So for those cases, the version includes -SNAPSHOT,
|
2017-05-24 11:55:32 -04:00
|
|
|
// and the bwc distribution will checkout and build that version.
|
2017-05-18 04:14:24 -04:00
|
|
|
Version last = versions[-1]
|
2017-08-10 14:30:00 -04:00
|
|
|
versions[-1] = new Version(last.major, last.minor, last.bugfix, last.suffix, true)
|
2017-05-26 18:36:32 -04:00
|
|
|
if (last.bugfix == 0) {
|
|
|
|
versions[-2] = new Version(
|
2017-08-10 14:30:00 -04:00
|
|
|
versions[-2].major, versions[-2].minor, versions[-2].bugfix, versions[-2].suffix, true)
|
2017-05-26 18:36:32 -04:00
|
|
|
}
|
2017-05-17 15:58:37 -04:00
|
|
|
}
|
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...
|
2015-11-05 01:28:57 -05:00
|
|
|
isEclipse = System.getProperty("eclipse.launcher") != null || gradle.startParameter.taskNames.contains('eclipse') || 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-03-29 15:11:38 -04:00
|
|
|
// for backcompat testing
|
2017-05-17 15:58:37 -04:00
|
|
|
indexCompatVersions = versions
|
|
|
|
wireCompatVersions = versions.subList(prevMinorIndex, versions.size())
|
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")
|
|
|
|
}
|
2017-05-26 18:36:32 -04:00
|
|
|
// Read the list from maven central
|
|
|
|
Node xml
|
|
|
|
new URL('https://repo1.maven.org/maven2/org/elasticsearch/elasticsearch/maven-metadata.xml').openStream().withStream { s ->
|
|
|
|
xml = new XmlParser().parse(s)
|
|
|
|
}
|
2017-06-01 13:29:51 -04:00
|
|
|
Set<Version> knownVersions = new TreeSet<>(xml.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
|
|
|
// Limit the known versions to those that should be index compatible, and are not future versions
|
|
|
|
knownVersions = knownVersions.findAll { it.major >= prevMajor && it.before(VersionProperties.elasticsearch) }
|
2017-05-26 18:36:32 -04:00
|
|
|
|
|
|
|
/* Limit the listed versions to those that have been marked as released.
|
|
|
|
* Versions not marked as released don't get the same testing and we want
|
|
|
|
* to make sure that we flip all unreleased versions to released as soon
|
|
|
|
* as possible after release. */
|
2017-06-01 13:29:51 -04:00
|
|
|
Set<Version> actualVersions = new TreeSet<>(indexCompatVersions.findAll { false == it.snapshot })
|
2017-05-26 18:36:32 -04:00
|
|
|
|
|
|
|
// Finally, compare!
|
2017-06-01 13:29:51 -04:00
|
|
|
if (knownVersions.equals(actualVersions) == false) {
|
|
|
|
throw new GradleException("out-of-date released versions\nActual :" + actualVersions + "\nExpected:" + knownVersions +
|
|
|
|
"\nUpdate Version.java. Note that Version.CURRENT doesn't count because it is not released.")
|
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.
|
|
|
|
*/
|
|
|
|
allprojects {
|
2017-11-07 04:14:58 -05:00
|
|
|
ext.bwc_tests_enabled = true
|
2017-06-15 01:01:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
task verifyBwcTestsEnabled {
|
|
|
|
doLast {
|
|
|
|
if (project.bwc_tests_enabled == false) {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-10-29 14:40:19 -04:00
|
|
|
subprojects {
|
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
|
|
|
|
register as thought they were external to resolve internally. We register
|
|
|
|
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',
|
|
|
|
"org.elasticsearch:elasticsearch:${version}": ':core',
|
2017-11-18 22:42:57 -05:00
|
|
|
"org.elasticsearch:elasticsearch-cli:${version}": ':core:cli',
|
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',
|
2015-12-17 19:57:39 -05:00
|
|
|
"org.elasticsearch.test:framework:${version}": ':test:framework',
|
2015-12-03 17:52:51 -05:00
|
|
|
"org.elasticsearch.distribution.integ-test-zip:elasticsearch:${version}": ':distribution:integ-test-zip',
|
2015-11-20 14:58:50 -05:00
|
|
|
"org.elasticsearch.distribution.zip:elasticsearch:${version}": ':distribution:zip',
|
2015-11-25 19:21:38 -05:00
|
|
|
"org.elasticsearch.distribution.tar:elasticsearch:${version}": ':distribution:tar',
|
|
|
|
"org.elasticsearch.distribution.rpm:elasticsearch:${version}": ':distribution:rpm',
|
|
|
|
"org.elasticsearch.distribution.deb:elasticsearch:${version}": ':distribution:deb',
|
2016-02-16 18:32:21 -05:00
|
|
|
"org.elasticsearch.test:logger-usage:${version}": ':test:logger-usage',
|
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',
|
2015-11-22 04:12:17 -05:00
|
|
|
]
|
2017-05-29 10:22:32 -04:00
|
|
|
if (indexCompatVersions[-1].snapshot) {
|
|
|
|
/* The last and second to last versions can be snapshots. Rather than use
|
|
|
|
* snapshots built by CI we connect these versions to projects that build
|
|
|
|
* those those versions from the HEAD of the appropriate branch. */
|
|
|
|
if (indexCompatVersions[-1].bugfix == 0) {
|
|
|
|
ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-stable-snapshot'
|
|
|
|
ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-stable-snapshot'
|
|
|
|
ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-stable-snapshot'
|
2017-08-01 15:47:48 -04:00
|
|
|
if (indexCompatVersions.size() > 1) {
|
|
|
|
ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot'
|
|
|
|
ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot'
|
|
|
|
ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot'
|
|
|
|
}
|
2017-05-29 10:22:32 -04:00
|
|
|
} else {
|
|
|
|
ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-release-snapshot'
|
|
|
|
ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-release-snapshot'
|
|
|
|
ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-release-snapshot'
|
|
|
|
}
|
2017-11-16 13:38:54 -05:00
|
|
|
} else if (indexCompatVersions[-2].snapshot) {
|
|
|
|
/* This is a terrible hack for the bump to 6.0.1 which will be fixed by #27397 */
|
|
|
|
ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot'
|
|
|
|
ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot'
|
|
|
|
ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot'
|
2017-05-18 04:14:24 -04:00
|
|
|
}
|
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
|
|
|
|
// other packages (e.g org.elasticsearch.client) will point to core rather than
|
|
|
|
// their own artifacts.
|
|
|
|
if (project.plugins.hasPlugin(BuildPlugin)) {
|
|
|
|
String artifactsHost = VersionProperties.elasticsearch.endsWith("-SNAPSHOT") ? "https://snapshots.elastic.co" : "https://artifacts.elastic.co"
|
|
|
|
Closure sortClosure = { a, b -> b.group <=> a.group }
|
|
|
|
Closure depJavadocClosure = { dep ->
|
|
|
|
if (dep.group != null && dep.group.startsWith('org.elasticsearch')) {
|
|
|
|
String substitution = project.ext.projectSubstitutions.get("${dep.group}:${dep.name}:${dep.version}")
|
|
|
|
if (substitution != null) {
|
|
|
|
project.javadoc.dependsOn substitution + ':javadoc'
|
|
|
|
String artifactPath = dep.group.replaceAll('\\.', '/') + '/' + dep.name.replaceAll('\\.', '/') + '/' + dep.version
|
|
|
|
project.javadoc.options.linksOffline artifactsHost + "/javadoc/" + artifactPath, "${project.project(substitution).buildDir}/docs/javadoc/"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
project.configurations.compile.dependencies.findAll().toSorted(sortClosure).each(depJavadocClosure)
|
|
|
|
project.configurations.provided.dependencies.findAll().toSorted(sortClosure).each(depJavadocClosure)
|
|
|
|
}
|
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') {
|
2015-12-17 19:57:39 -05:00
|
|
|
// :test:framework:test cannot run before and after :core:test
|
2015-11-22 04:12:17 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
configurations.all {
|
|
|
|
dependencies.all { Dependency dep ->
|
|
|
|
Project upstreamProject = null
|
|
|
|
if (dep instanceof ProjectDependency) {
|
|
|
|
upstreamProject = dep.dependencyProject
|
|
|
|
} else {
|
|
|
|
// gradle doesn't apply substitutions until resolve time, so they won't
|
|
|
|
// show up as a ProjectDependency above
|
|
|
|
String substitution = projectSubstitutions.get("${dep.group}:${dep.name}:${dep.version}")
|
|
|
|
if (substitution != null) {
|
|
|
|
upstreamProject = findProject(substitution)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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) {
|
|
|
|
throw new GradleException('You must run gradle idea from the root of elasticsearch before importing into IntelliJ')
|
|
|
|
}
|
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
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
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'
|
|
|
|
}
|
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)
|
2015-10-29 14:40:19 -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
|
|
|
|
|
|
|
|
@org.gradle.api.internal.tasks.options.Option(
|
|
|
|
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
|
|
|
|
|
|
|
/* Remove assemble on all qa projects because we don't need to publish
|
|
|
|
* artifacts for them. */
|
|
|
|
gradle.projectsEvaluated {
|
|
|
|
subprojects {
|
|
|
|
if (project.path.startsWith(':qa')) {
|
|
|
|
Task assemble = project.tasks.findByName('assemble')
|
|
|
|
if (assemble) {
|
|
|
|
project.tasks.remove(assemble)
|
2017-06-16 17:16:03 -04:00
|
|
|
project.build.dependsOn.remove('assemble')
|
2017-06-16 11:46:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|