2021-04-09 15:28:18 -04:00
|
|
|
/*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
* The OpenSearch Contributors require contributions made to
|
|
|
|
* this file be licensed under the Apache-2.0 license or a
|
|
|
|
* compatible open source license.
|
|
|
|
*
|
|
|
|
* Modifications Copyright OpenSearch Contributors. See
|
|
|
|
* GitHub history for details.
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
2020-02-10 16:49:44 -05:00
|
|
|
import com.avast.gradle.dockercompose.tasks.ComposePull
|
2018-07-17 14:20:41 -04:00
|
|
|
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
|
2020-03-20 12:12:05 -04:00
|
|
|
import de.thetaphi.forbiddenapis.gradle.ForbiddenApisPlugin
|
2018-08-31 09:01:54 -04:00
|
|
|
import org.apache.tools.ant.taskdefs.condition.Os
|
2021-03-18 19:14:19 -04:00
|
|
|
import org.opensearch.gradle.BuildPlugin
|
|
|
|
import org.opensearch.gradle.Version
|
|
|
|
import org.opensearch.gradle.VersionProperties
|
|
|
|
import org.opensearch.gradle.info.BuildParams
|
|
|
|
import org.opensearch.gradle.plugin.PluginBuildPlugin
|
2020-03-20 12:12:05 -04:00
|
|
|
import org.gradle.plugins.ide.eclipse.model.AccessRule
|
2021-12-03 15:53:28 -05:00
|
|
|
import org.gradle.plugins.ide.eclipse.model.EclipseJdt
|
2017-11-21 03:26:45 -05:00
|
|
|
import org.gradle.plugins.ide.eclipse.model.SourceFolder
|
2019-10-08 07:39:58 -04:00
|
|
|
import org.gradle.util.DistributionLocator
|
|
|
|
import org.gradle.util.GradleVersion
|
2021-03-18 19:14:19 -04:00
|
|
|
import static org.opensearch.gradle.util.GradleUtils.maybeConfigure
|
2019-08-08 13:50:09 -04:00
|
|
|
|
2018-05-22 00:21:16 -04:00
|
|
|
plugins {
|
2019-11-14 06:01:23 -05:00
|
|
|
id 'lifecycle-base'
|
2021-03-18 19:14:19 -04:00
|
|
|
id 'opensearch.docker-support'
|
|
|
|
id 'opensearch.global-build-info'
|
2022-02-17 01:08:40 -05:00
|
|
|
id "com.diffplug.spotless" version "6.2.0" apply false
|
2018-05-22 00:21:16 -04:00
|
|
|
}
|
2019-07-16 12:34:00 -04:00
|
|
|
|
2019-10-18 01:14:46 -04:00
|
|
|
apply from: 'gradle/build-complete.gradle'
|
2019-11-18 03:27:28 -05:00
|
|
|
apply from: 'gradle/runtime-jdk-provision.gradle'
|
2020-03-19 14:43:33 -04:00
|
|
|
apply from: 'gradle/ide.gradle'
|
2020-04-08 02:20:17 -04:00
|
|
|
apply from: 'gradle/forbidden-dependencies.gradle'
|
2020-03-27 08:02:07 -04:00
|
|
|
apply from: 'gradle/formatting.gradle'
|
2020-05-12 06:49:58 -04:00
|
|
|
apply from: 'gradle/local-distribution.gradle'
|
2020-06-01 13:24:12 -04:00
|
|
|
apply from: 'gradle/fips.gradle'
|
2020-06-02 09:33:53 -04:00
|
|
|
apply from: 'gradle/run.gradle'
|
2021-05-18 16:21:41 -04:00
|
|
|
apply from: 'gradle/missing-javadoc.gradle'
|
2021-08-10 10:23:46 -04:00
|
|
|
apply from: 'gradle/code-coverage.gradle'
|
2018-05-22 00:21:16 -04:00
|
|
|
|
2015-10-29 14:40:19 -04:00
|
|
|
// common maven publishing configuration
|
2018-11-14 04:22:00 -05:00
|
|
|
allprojects {
|
2021-03-18 19:14:19 -04:00
|
|
|
group = 'org.opensearch'
|
|
|
|
version = VersionProperties.getOpenSearch()
|
|
|
|
description = "OpenSearch subproject ${project.path}"
|
2016-11-24 03:03:43 -05:00
|
|
|
}
|
|
|
|
|
2020-04-14 16:24:15 -04:00
|
|
|
configure(allprojects - project(':distribution:archives:integ-test-zip')) {
|
|
|
|
project.pluginManager.withPlugin('nebula.maven-base-publish') {
|
2021-03-18 19:14:19 -04:00
|
|
|
if (project.pluginManager.hasPlugin('opensearch.build') == false) {
|
2020-04-14 16:24:15 -04:00
|
|
|
throw new GradleException("Project ${path} publishes a pom but doesn't apply the build plugin.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
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()
|
2021-03-23 02:17:27 -04:00
|
|
|
node.appendNode('inceptionYear', '2021')
|
2016-05-05 20:53:01 -04:00
|
|
|
|
|
|
|
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')
|
2021-03-23 02:17:27 -04:00
|
|
|
developer.appendNode('name', 'OpenSearch')
|
|
|
|
developer.appendNode('url', 'https://github.com/opensearch-project/OpenSearch')
|
2016-05-05 20:53:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 02:41:39 -04:00
|
|
|
repositories {
|
|
|
|
maven {
|
2019-05-07 06:34:51 -04:00
|
|
|
name = 'test'
|
2018-08-17 02:41:39 -04:00
|
|
|
url = "${rootProject.buildDir}/local-test-repo"
|
|
|
|
}
|
2021-06-10 17:07:48 -04:00
|
|
|
maven {
|
|
|
|
name = 'Snapshots'
|
|
|
|
url = 'https://aws.oss.sonatype.org/content/repositories/snapshots'
|
|
|
|
credentials {
|
|
|
|
username "$System.env.SONATYPE_USERNAME"
|
|
|
|
password "$System.env.SONATYPE_PASSWORD"
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 02:41:39 -04:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2020-05-25 03:37:33 -04:00
|
|
|
tasks.register("updateCIBwcVersions") {
|
2019-11-14 06:01:23 -05:00
|
|
|
doLast {
|
|
|
|
File yml = file(".ci/bwcVersions")
|
|
|
|
yml.text = ""
|
|
|
|
yml << "BWC_VERSION:\n"
|
2020-05-13 14:27:40 -04:00
|
|
|
BuildParams.bwcVersions.indexCompatible.each {
|
2019-11-14 06:01:23 -05:00
|
|
|
yml << " - \"$it\"\n"
|
2019-07-17 10:34:35 -04:00
|
|
|
}
|
2019-11-14 06:01:23 -05:00
|
|
|
}
|
2019-07-17 10:34:35 -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
|
2019-11-14 06:01:23 -05:00
|
|
|
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')
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-25 03:37:33 -04:00
|
|
|
tasks.register("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")
|
|
|
|
}
|
2019-11-14 06:01:23 -05:00
|
|
|
// Read the list from maven central.
|
2020-02-27 11:07:35 -05:00
|
|
|
// Fetch the metadata and parse the xml into Version instances because it's more straight forward here
|
2018-11-01 11:43:57 -04:00
|
|
|
// rather than bwcVersion ( VersionCollection ).
|
2022-01-11 09:19:51 -05:00
|
|
|
new URL('https://repo1.maven.org/maven2/org/opensearch/opensearch/maven-metadata.xml').openStream().withStream { s ->
|
2020-05-11 03:39:13 -04:00
|
|
|
BuildParams.bwcVersions.compareToAuthoritative(
|
2019-11-14 06:01:23 -05:00
|
|
|
new XmlParser().parse(s)
|
|
|
|
.versioning.versions.version
|
|
|
|
.collect { it.text() }.findAll { it ==~ /\d+\.\d+\.\d+/ }
|
|
|
|
.collect { Version.fromString(it) }
|
2018-11-01 11:43:57 -04:00
|
|
|
)
|
2017-05-26 18:36:32 -04:00
|
|
|
}
|
2019-07-17 10:34:35 -04:00
|
|
|
String ciYml = file(".ci/bwcVersions").text
|
2020-05-11 03:39:13 -04:00
|
|
|
BuildParams.bwcVersions.indexCompatible.each {
|
2019-11-14 06:01:23 -05:00
|
|
|
if (ciYml.contains("\"$it\"\n") == false) {
|
|
|
|
throw new Exception(".ci/bwcVersions is outdated, run `./gradlew updateCIBwcVersions` and check in the results");
|
|
|
|
}
|
2019-07-17 10:34:35 -04:00
|
|
|
}
|
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
|
|
|
|
2021-11-05 09:50:56 -04:00
|
|
|
boolean bwc_tests_enabled = true
|
2021-08-25 23:33:59 -04:00
|
|
|
/* place an issue link here when committing bwc changes */
|
2021-11-05 09:50:56 -04:00
|
|
|
final String bwc_tests_disabled_issue = ""
|
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
|
|
|
}
|
|
|
|
|
2020-05-25 03:37:33 -04:00
|
|
|
tasks.register("verifyBwcTestsEnabled") {
|
2017-06-15 01:01:49 -04:00
|
|
|
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.')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-25 03:37:33 -04:00
|
|
|
tasks.register("branchConsistency") {
|
2017-06-01 13:29:51 -04:00
|
|
|
description 'Ensures this branch is internally consistent. For example, that versions constants match released versions.'
|
|
|
|
group 'Verification'
|
2020-05-25 03:37:33 -04:00
|
|
|
dependsOn ":verifyVersions", ":verifyBwcTestsEnabled"
|
2017-05-26 18:36:32 -04:00
|
|
|
}
|
|
|
|
|
2018-11-14 04:22:00 -05:00
|
|
|
allprojects {
|
2021-07-06 12:55:23 -04:00
|
|
|
// configure compiler options
|
|
|
|
tasks.withType(JavaCompile).configureEach { JavaCompile compile ->
|
|
|
|
compile.options.compilerArgs << '-Werror'
|
|
|
|
compile.options.compilerArgs << '-Xlint:auxiliaryclass'
|
|
|
|
compile.options.compilerArgs << '-Xlint:cast'
|
|
|
|
compile.options.compilerArgs << '-Xlint:classfile'
|
|
|
|
compile.options.compilerArgs << '-Xlint:dep-ann'
|
|
|
|
compile.options.compilerArgs << '-Xlint:divzero'
|
|
|
|
compile.options.compilerArgs << '-Xlint:empty'
|
|
|
|
compile.options.compilerArgs << '-Xlint:exports'
|
|
|
|
compile.options.compilerArgs << '-Xlint:fallthrough'
|
|
|
|
compile.options.compilerArgs << '-Xlint:finally'
|
|
|
|
compile.options.compilerArgs << '-Xlint:module'
|
|
|
|
compile.options.compilerArgs << '-Xlint:opens'
|
|
|
|
compile.options.compilerArgs << '-Xlint:overloads'
|
|
|
|
compile.options.compilerArgs << '-Xlint:overrides'
|
|
|
|
compile.options.compilerArgs << '-Xlint:processing'
|
|
|
|
compile.options.compilerArgs << '-Xlint:rawtypes'
|
|
|
|
compile.options.compilerArgs << '-Xlint:removal'
|
|
|
|
compile.options.compilerArgs << '-Xlint:requires-automatic'
|
|
|
|
compile.options.compilerArgs << '-Xlint:requires-transitive-automatic'
|
|
|
|
compile.options.compilerArgs << '-Xlint:static'
|
|
|
|
compile.options.compilerArgs << '-Xlint:unchecked'
|
|
|
|
compile.options.compilerArgs << '-Xlint:varargs'
|
|
|
|
compile.options.compilerArgs << '-Xlint:preview'
|
|
|
|
// TODO: disabled warnings: path, serial, options, deprecation, try
|
|
|
|
// -path because gradle will send in paths that don't always exist.
|
|
|
|
// -missing because we have tons of missing @returns and @param.
|
|
|
|
// -serial because we don't use java serialization.
|
|
|
|
compile.options.compilerArgs << '-Xdoclint:accessibility'
|
|
|
|
compile.options.compilerArgs << '-Xdoclint:html'
|
|
|
|
compile.options.compilerArgs << '-Xdoclint:reference'
|
|
|
|
compile.options.compilerArgs << '-Xdoclint:syntax'
|
|
|
|
}
|
|
|
|
|
2017-09-11 18:43:34 -04:00
|
|
|
// ignore missing javadocs
|
2019-08-08 13:50:09 -04:00
|
|
|
tasks.withType(Javadoc).configureEach { Javadoc javadoc ->
|
2017-09-11 18:43:34 -04:00
|
|
|
// 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
|
2019-11-14 06:01:23 -05:00
|
|
|
javadoc.options.encoding = 'UTF8'
|
2017-09-11 18:43:34 -04:00
|
|
|
javadoc.options.addStringOption('Xdoclint:all,-missing', '-quiet')
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
|
2022-02-02 10:13:54 -05:00
|
|
|
// support for reproducible builds
|
|
|
|
tasks.withType(AbstractArchiveTask).configureEach {
|
|
|
|
// ignore file timestamps
|
|
|
|
// be consistent in archive file order
|
|
|
|
preserveFileTimestamps = false
|
|
|
|
reproducibleFileOrder = true
|
|
|
|
}
|
|
|
|
|
2017-03-24 01:32:13 -04:00
|
|
|
project.afterEvaluate {
|
2017-09-11 18:43:34 -04:00
|
|
|
// Handle javadoc dependencies across projects. Order matters: the linksOffline for
|
2021-03-18 19:14:19 -04:00
|
|
|
// org.opensearch:opensearch must be the last one or all the links for the
|
|
|
|
// other packages (e.g org.opensearch.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)) {
|
2021-04-05 14:51:20 -04:00
|
|
|
String artifactsHost = VersionProperties.getOpenSearch().endsWith("-SNAPSHOT")
|
|
|
|
? "https://artifacts.opensearch.org/snapshots/"
|
|
|
|
: "https://artifacts.opensearch.org/releases/"
|
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 ->
|
2019-06-04 16:50:23 -04:00
|
|
|
if ((dep instanceof ProjectDependency) == false) {
|
2018-07-17 14:20:41 -04:00
|
|
|
return
|
|
|
|
}
|
2019-06-04 16:50:23 -04:00
|
|
|
Project upstreamProject = dep.dependencyProject
|
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"
|
2020-07-07 05:38:40 -04:00
|
|
|
String externalLinkName = upstreamProject.archivesBaseName
|
|
|
|
String artifactPath = dep.group.replaceAll('\\.', '/') + '/' + externalLinkName.replaceAll('\\.', '/') + '/' + dep.version
|
2018-07-17 14:20:41 -04:00
|
|
|
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)
|
2021-11-29 14:34:06 -05:00
|
|
|
project.configurations.implementation.dependencies
|
2019-11-14 06:01:23 -05:00
|
|
|
.findAll()
|
|
|
|
.toSorted(sortClosure)
|
|
|
|
.each({ c -> depJavadocClosure(hasShadow, c) })
|
2018-07-17 14:20:41 -04:00
|
|
|
project.configurations.compileOnly.dependencies
|
2019-11-14 06:01:23 -05:00
|
|
|
.findAll()
|
|
|
|
.toSorted(sortClosure)
|
|
|
|
.each({ c -> depJavadocClosure(false, c) })
|
2018-07-17 14:20:41 -04:00
|
|
|
if (hasShadow) {
|
2019-10-28 15:11:55 -04:00
|
|
|
// include any dependencies for shadow JAR projects that are *not* bundled in the shadow JAR
|
|
|
|
project.configurations.shadow.dependencies
|
2019-11-14 06:01:23 -05:00
|
|
|
.findAll()
|
|
|
|
.toSorted(sortClosure)
|
|
|
|
.each({ c -> depJavadocClosure(false, 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
|
|
|
|
}
|
2021-12-16 17:57:22 -05:00
|
|
|
|
|
|
|
project.tasks.withType(Test) { task ->
|
|
|
|
if (task != null) {
|
|
|
|
if (BuildParams.runtimeJavaVersion > JavaVersion.VERSION_17) {
|
|
|
|
task.jvmArgs += ["-Djava.security.manager=allow"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-30 13:29:42 -04:00
|
|
|
configurations.matching { it.canBeResolved }.all { Configuration configuration ->
|
2019-06-04 16:50:23 -04:00
|
|
|
dependencies.matching { it instanceof ProjectDependency }.all { ProjectDependency dep ->
|
|
|
|
Project upstreamProject = dep.dependencyProject
|
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) {
|
2019-04-08 10:05:12 -04:00
|
|
|
task.shouldRunAfter(upstreamTask)
|
2015-11-22 04:12:17 -05:00
|
|
|
}
|
|
|
|
}
|
2015-10-29 14:40:19 -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) {
|
2019-10-03 03:50:46 -04:00
|
|
|
eclipse.classpath.defaultOutputDir = file('build-eclipse')
|
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++;
|
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
|
|
|
}
|
|
|
|
}
|
2020-03-20 12:12:05 -04:00
|
|
|
/*
|
|
|
|
* Allow accessing com/sun/net/httpserver in projects that have
|
|
|
|
* configured forbidden apis to allow it.
|
|
|
|
*/
|
|
|
|
plugins.withType(ForbiddenApisPlugin) {
|
|
|
|
eclipse.classpath.file.whenMerged { classpath ->
|
|
|
|
if (false == forbiddenApisTest.bundledSignatures.contains('jdk-non-portable')) {
|
|
|
|
classpath.entries
|
|
|
|
.findAll { it.kind == "con" && it.toString().contains("org.eclipse.jdt.launching.JRE_CONTAINER") }
|
|
|
|
.each {
|
|
|
|
it.accessRules.add(new AccessRule("accessible", "com/sun/net/httpserver/*"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-05-03 03:48:49 -04:00
|
|
|
|
2019-10-03 03:50:46 -04:00
|
|
|
File licenseHeaderFile
|
2021-04-20 12:27:40 -04:00
|
|
|
licenseHeaderFile = new File(project.rootDir, 'buildSrc/src/main/resources/license-headers/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)
|
2019-08-08 13:50:09 -04:00
|
|
|
tasks.register('copyEclipseSettings', Copy) {
|
|
|
|
mustRunAfter 'wipeEclipseSettings'
|
2015-11-02 10:44:51 -05:00
|
|
|
// TODO: "package this up" for external builds
|
|
|
|
from new File(project.rootDir, 'buildSrc/src/main/resources/eclipse.settings')
|
|
|
|
into '.settings'
|
2019-11-14 06:01:23 -05: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
|
2019-08-08 13:50:09 -04:00
|
|
|
tasks.register('wipeEclipseSettings', Delete) {
|
2015-11-11 22:26:55 -05:00
|
|
|
delete '.settings'
|
|
|
|
}
|
2019-08-08 13:50:09 -04:00
|
|
|
tasks.named('cleanEclipse') { dependsOn 'wipeEclipseSettings' }
|
2015-10-30 23:00:05 -04:00
|
|
|
// otherwise the eclipse merging is *super confusing*
|
2019-08-08 13:50:09 -04:00
|
|
|
tasks.named('eclipse') { dependsOn 'cleanEclipse', 'copyEclipseSettings' }
|
2022-01-11 09:19:51 -05:00
|
|
|
|
2021-12-03 15:53:28 -05:00
|
|
|
afterEvaluate {
|
|
|
|
tasks.findByName("eclipseJdt")?.configure {
|
|
|
|
dependsOn 'copyEclipseSettings'
|
2022-01-11 09:19:51 -05:00
|
|
|
}
|
2021-12-03 15:53:28 -05:00
|
|
|
}
|
2015-10-29 14:40:19 -04:00
|
|
|
}
|
|
|
|
|
2018-06-29 15:17:19 -04:00
|
|
|
wrapper {
|
2019-11-14 06:01:23 -05:00
|
|
|
distributionType = 'ALL'
|
|
|
|
doLast {
|
|
|
|
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"
|
|
|
|
println "Added checksum to wrapper properties"
|
|
|
|
// 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-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:')) {
|
2019-08-08 13:50:09 -04:00
|
|
|
maybeConfigure(project.tasks, 'assemble') {
|
|
|
|
it.enabled = false
|
2017-06-16 11:46:34 -04:00
|
|
|
}
|
2019-08-08 13:50:09 -04:00
|
|
|
maybeConfigure(project.tasks, 'dependenciesInfo') {
|
|
|
|
it.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(
|
2019-11-14 06:01:23 -05:00
|
|
|
"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"
|
2018-07-19 02:46:58 -04:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2017-06-16 11:46:34 -04:00
|
|
|
}
|
2018-06-28 01:13:21 -04:00
|
|
|
|
2018-09-14 16:14:03 -04:00
|
|
|
allprojects {
|
2021-03-18 19:14:19 -04:00
|
|
|
tasks.register('resolveAllDependencies', org.opensearch.gradle.ResolveAllDependencies) {
|
2020-09-04 14:21:46 -04:00
|
|
|
configs = project.configurations
|
2020-02-10 16:49:44 -05:00
|
|
|
if (project.path.contains("fixture")) {
|
|
|
|
dependsOn tasks.withType(ComposePull)
|
|
|
|
}
|
2018-09-14 16:14:03 -04:00
|
|
|
}
|
2018-11-20 13:35:53 -05:00
|
|
|
|
2019-04-19 12:49:36 -04:00
|
|
|
// helper task to print direct dependencies of a single task
|
|
|
|
project.tasks.addRule("Pattern: <taskName>Dependencies") { String taskName ->
|
|
|
|
if (taskName.endsWith("Dependencies") == false) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (project.tasks.findByName(taskName) != null) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
String realTaskName = taskName.substring(0, taskName.length() - "Dependencies".length())
|
|
|
|
Task realTask = project.tasks.findByName(realTaskName)
|
|
|
|
if (realTask == null) {
|
|
|
|
return
|
|
|
|
}
|
2020-05-25 03:37:33 -04:00
|
|
|
project.tasks.register(taskName) {
|
2019-04-19 12:49:36 -04:00
|
|
|
doLast {
|
|
|
|
println("${realTask.path} dependencies:")
|
|
|
|
for (Task dep : realTask.getTaskDependencies().getDependencies(realTask)) {
|
|
|
|
println(" - ${dep.path}")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-08 13:50:09 -04:00
|
|
|
def checkPart1 = tasks.register('checkPart1')
|
|
|
|
def checkPart2 = tasks.register('checkPart2')
|
|
|
|
plugins.withId('lifecycle-base') {
|
2021-01-30 00:39:22 -05:00
|
|
|
checkPart1.configure { dependsOn 'check' }
|
2019-08-08 13:50:09 -04:00
|
|
|
}
|
2018-11-20 13:35:53 -05:00
|
|
|
}
|
2020-03-20 16:52:22 -04:00
|
|
|
|
2020-04-15 16:23:55 -04:00
|
|
|
subprojects {
|
|
|
|
project.ext.disableTasks = { String... tasknames ->
|
|
|
|
for (String taskname : tasknames) {
|
|
|
|
project.tasks.named(taskname).configure { onlyIf { false } }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|