"Fossies" - the Fresh Open Source Software Archive

Member "elasticsearch-6.8.23/build.gradle" (29 Dec 2021, 24578 Bytes) of package /linux/www/elasticsearch-6.8.23-src.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Java source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2  * Licensed to Elasticsearch under one or more contributor
    3  * license agreements. See the NOTICE file distributed with
    4  * this work for additional information regarding copyright
    5  * ownership. Elasticsearch licenses this file to you under
    6  * the Apache License, Version 2.0 (the "License"); you may
    7  * not use this file except in compliance with the License.
    8  * You may obtain a copy of the License at
    9  *
   10  *    http://www.apache.org/licenses/LICENSE-2.0
   11  *
   12  * Unless required by applicable law or agreed to in writing,
   13  * software distributed under the License is distributed on an
   14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   15  * KIND, either express or implied.  See the License for the
   16  * specific language governing permissions and limitations
   17  * under the License.
   18  */
   19 
   20 import com.avast.gradle.dockercompose.tasks.ComposePull
   21 import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
   22 import org.apache.tools.ant.taskdefs.condition.Os
   23 import org.elasticsearch.gradle.BuildPlugin
   24 import org.elasticsearch.gradle.Version
   25 import org.elasticsearch.gradle.VersionCollection
   26 import org.elasticsearch.gradle.VersionProperties
   27 import org.elasticsearch.gradle.plugin.PluginBuildPlugin
   28 import org.gradle.util.GradleVersion
   29 import org.gradle.util.DistributionLocator
   30 import org.gradle.plugins.ide.eclipse.model.SourceFolder
   31 
   32 plugins {
   33     id 'com.gradle.build-scan' version '3.5'
   34     id 'base'
   35 }
   36 
   37 apply plugin: 'nebula.info-scm'
   38 apply from: 'gradle/build-scan.gradle'
   39 apply from: 'gradle/build-complete.gradle'
   40 apply from: 'gradle/ide.gradle'
   41 
   42 // common maven publishing configuration
   43 allprojects {
   44   group = 'org.elasticsearch'
   45   version = VersionProperties.elasticsearch
   46   description = "Elasticsearch subproject ${project.path}"
   47 }
   48 
   49 BuildPlugin.configureRepositories(project)
   50 
   51 String licenseCommit
   52 if (VersionProperties.elasticsearch.toString().endsWith('-SNAPSHOT')) {
   53   licenseCommit = scminfo.change ?: "master" // leniency for non git builds
   54 } else {
   55   licenseCommit = "v${version}"
   56 }
   57 String elasticLicenseUrl = "https://raw.githubusercontent.com/elastic/elasticsearch/${licenseCommit}/licenses/ELASTIC-LICENSE.txt"
   58 
   59 subprojects {
   60   // Default to the apache license
   61   project.ext.licenseName = 'The Apache Software License, Version 2.0'
   62   project.ext.licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
   63 
   64   // But stick the Elastic license url in project.ext so we can get it if we need to switch to it
   65   project.ext.elasticLicenseUrl = elasticLicenseUrl
   66 
   67   // we only use maven publish to add tasks for pom generation
   68   plugins.withType(MavenPublishPlugin).whenPluginAdded {
   69     publishing {
   70       publications {
   71         // add license information to generated poms
   72         all {
   73           pom.withXml { XmlProvider xml ->
   74             Node node = xml.asNode()
   75             node.appendNode('inceptionYear', '2009')
   76 
   77             Node license = node.appendNode('licenses').appendNode('license')
   78             license.appendNode('name', project.licenseName)
   79             license.appendNode('url', project.licenseUrl)
   80             license.appendNode('distribution', 'repo')
   81 
   82             Node developer = node.appendNode('developers').appendNode('developer')
   83             developer.appendNode('name', 'Elastic')
   84             developer.appendNode('url', 'http://www.elastic.co')
   85           }
   86         }
   87       }
   88       repositories {
   89         maven {
   90           name = 'test'
   91           url = "${rootProject.buildDir}/local-test-repo"
   92         }
   93       }
   94     }
   95   }
   96 
   97   plugins.withType(BuildPlugin).whenPluginAdded {
   98     project.licenseFile = project.rootProject.file('licenses/APACHE-LICENSE-2.0.txt')
   99     project.noticeFile = project.rootProject.file('NOTICE.txt')
  100   }
  101 }
  102 
  103 /* Introspect all versions of ES that may be tested against for backwards
  104  * compatibility. It is *super* important that this logic is the same as the
  105  * logic in VersionUtils.java, throwing out alphas because they don't have any
  106  * backwards compatibility guarantees and only keeping the latest beta or rc
  107  * in a branch if there are only betas and rcs in the branch so we have
  108  * *something* to test against. */
  109 VersionCollection versions = new VersionCollection(file('server/src/main/java/org/elasticsearch/Version.java').readLines('UTF-8'))
  110 
  111 task updateCIBwcVersions() {
  112     doLast {
  113         File yml = file(".ci/bwcVersions")
  114         yml.text = ""
  115         yml << "BWC_VERSION:\n"
  116         versions.indexCompatible.each {
  117             yml << "  - \"$it\"\n"
  118         }
  119     }
  120 }
  121 
  122 // build metadata from previous build, contains eg hashes for bwc builds
  123 String buildMetadataValue = System.getenv('BUILD_METADATA')
  124 if (buildMetadataValue == null) {
  125   buildMetadataValue = ''
  126 }
  127 Map<String, String> buildMetadataMap = buildMetadataValue.tokenize(';').collectEntries {
  128   def (String key, String value) = it.split('=')
  129   return [key, value]
  130 }
  131 
  132 // injecting groovy property variables into all projects
  133 allprojects {
  134   project.ext {
  135     // for ide hacks...
  136     isEclipse = System.getProperty("eclipse.launcher") != null ||   // Detects gradle launched from Eclipse's IDE
  137       System.getProperty("eclipse.application") != null ||    // Detects gradle launched from the Eclipse compiler server
  138       gradle.startParameter.taskNames.contains('eclipse') ||  // Detects gradle launched from the command line to do eclipse stuff
  139       gradle.startParameter.taskNames.contains('cleanEclipse')
  140 
  141     // for BWC testing
  142     bwcVersions = versions
  143 
  144     buildMetadata = buildMetadataMap
  145   }
  146 }
  147 
  148 task verifyVersions {
  149   doLast {
  150     if (gradle.startParameter.isOffline()) {
  151       throw new GradleException("Must run in online mode to verify versions")
  152     }
  153     // Read the list from maven central.
  154     // Fetch the metadata an parse the xml into Version instances because it's more straight forward here
  155     // rather than bwcVersion ( VersionCollection ).
  156     new URL('https://repo1.maven.org/maven2/org/elasticsearch/elasticsearch/maven-metadata.xml').openStream().withStream { s ->
  157       bwcVersions.compareToAuthoritative(
  158               new XmlParser().parse(s)
  159                       .versioning.versions.version
  160                       .collect { it.text() }.findAll { it ==~ /\d+\.\d+\.\d+/ }
  161                       .collect { Version.fromString(it) }
  162       )
  163     }
  164     String ciYml = file(".ci/bwcVersions").text
  165     bwcVersions.indexCompatible.each {
  166         if (ciYml.contains("\"$it\"\n") == false) {
  167             throw new Exception(".ci/bwcVersions is outdated, run `./gradlew updateCIBwcVersions` and check in the results");
  168         }
  169     }
  170   }
  171 }
  172 
  173 /*
  174  * When adding backcompat behavior that spans major versions, temporarily
  175  * disabling the backcompat tests is necessary. This flag controls
  176  * the enabled state of every bwc task. It should be set back to true
  177  * after the backport of the backcompat code is complete.
  178  */
  179 boolean bwc_tests_enabled = true
  180 final String bwc_tests_disabled_issue = "" /* place a PR link here when committing bwc changes */
  181 if (bwc_tests_enabled == false) {
  182   if (bwc_tests_disabled_issue.isEmpty()) {
  183     throw new GradleException("bwc_tests_disabled_issue must be set when bwc_tests_enabled == false")
  184   }
  185   println "========================= WARNING ========================="
  186   println "         Backwards compatibility tests are disabled!"
  187   println "See ${bwc_tests_disabled_issue}"
  188   println "==========================================================="
  189 }
  190 if (project.gradle.startParameter.taskNames.find { it.startsWith("checkPart") } != null) {
  191   // Disable BWC tests for checkPart* tasks as it's expected that this will run un it's own check
  192   bwc_tests_enabled = false
  193 }
  194 
  195 subprojects {
  196   ext.bwc_tests_enabled = bwc_tests_enabled
  197   /*
  198    * Versions of Elasticsearch 5.1.1 through 5.3.0 inclusive did not start on versions of Linux with cgroups v2 enabled (kernel >= 4.5).
  199    * This property is provided to all projects that need to check conditionally if they should skip a BWC test task.
  200    */
  201   ext.cgroupsV2Enabled = Os.isFamily(Os.FAMILY_UNIX) && "mount".execute().text.readLines().any { it =~ /.*type cgroup2.*/ }
  202 }
  203 
  204 task verifyBwcTestsEnabled {
  205   doLast {
  206     if (bwc_tests_enabled == false) {
  207       throw new GradleException('Bwc tests are disabled. They must be re-enabled after completing backcompat behavior backporting.')
  208     }
  209   }
  210 }
  211 
  212 task branchConsistency {
  213   description 'Ensures this branch is internally consistent. For example, that versions constants match released versions.'
  214   group 'Verification'
  215   dependsOn verifyVersions, verifyBwcTestsEnabled
  216 }
  217 
  218 allprojects {
  219   // ignore missing javadocs
  220   tasks.withType(Javadoc) { Javadoc javadoc ->
  221     // the -quiet here is because of a bug in gradle, in that adding a string option
  222     // by itself is not added to the options. By adding quiet, both this option and
  223     // the "value" -quiet is added, separated by a space. This is ok since the javadoc
  224     // command already adds -quiet, so we are just duplicating it
  225     // see https://discuss.gradle.org/t/add-custom-javadoc-option-that-does-not-take-an-argument/5959
  226     javadoc.options.encoding='UTF8'
  227     javadoc.options.addStringOption('Xdoclint:all,-missing', '-quiet')
  228   }
  229 
  230   /* Sets up the dependencies that we build as part of this project but
  231     register as though they were external to resolve internally. We register
  232     them as external dependencies so the build plugin that we use can be used
  233     to build elasticsearch plugins outside of the elasticsearch source tree. */
  234   ext.projectSubstitutions = [
  235     "org.elasticsearch.gradle:build-tools:${version}": ':build-tools',
  236     "org.elasticsearch:rest-api-spec:${version}": ':rest-api-spec',
  237     "org.elasticsearch:elasticsearch:${version}": ':server',
  238     "org.elasticsearch:elasticsearch-cli:${version}": ':libs:cli',
  239     "org.elasticsearch:elasticsearch-core:${version}": ':libs:core',
  240     "org.elasticsearch:elasticsearch-x-content:${version}": ':libs:x-content',
  241     "org.elasticsearch:elasticsearch-secure-sm:${version}": ':libs:secure-sm',
  242     "org.elasticsearch:elasticsearch-ssl-config:${version}": ':libs:elasticsearch-ssl-config',
  243     "org.elasticsearch.client:elasticsearch-rest-client:${version}": ':client:rest',
  244     "org.elasticsearch.client:elasticsearch-rest-client-sniffer:${version}": ':client:sniffer',
  245     "org.elasticsearch.client:elasticsearch-rest-high-level-client:${version}": ':client:rest-high-level',
  246     "org.elasticsearch.client:test:${version}": ':client:test',
  247     "org.elasticsearch.client:transport:${version}": ':client:transport',
  248     "org.elasticsearch.plugin:elasticsearch-scripting-painless-spi:${version}": ':modules:lang-painless:spi',
  249     "org.elasticsearch.test:framework:${version}": ':test:framework',
  250     "org.elasticsearch.distribution.integ-test-zip:elasticsearch:${version}": ':distribution:archives:integ-test-zip',
  251     "org.elasticsearch.distribution.zip:elasticsearch:${version}": ':distribution:archives:zip',
  252     "org.elasticsearch.distribution.zip:elasticsearch-oss:${version}": ':distribution:archives:oss-zip',
  253     "org.elasticsearch.distribution.tar:elasticsearch:${version}": ':distribution:archives:tar',
  254     "org.elasticsearch.distribution.tar:elasticsearch-oss:${version}": ':distribution:archives:oss-tar',
  255     "org.elasticsearch.distribution.rpm:elasticsearch:${version}": ':distribution:packages:rpm',
  256     "org.elasticsearch.distribution.rpm:elasticsearch-oss:${version}": ':distribution:packages:oss-rpm',
  257     "org.elasticsearch.distribution.deb:elasticsearch:${version}": ':distribution:packages:deb',
  258     "org.elasticsearch.distribution.deb:elasticsearch-oss:${version}": ':distribution:packages:oss-deb',
  259     "org.elasticsearch.test:logger-usage:${version}": ':test:logger-usage',
  260     "org.elasticsearch.xpack.test:feature-aware:${version}": ':x-pack:test:feature-aware',
  261     // for transport client
  262     "org.elasticsearch.plugin:transport-netty4-client:${version}": ':modules:transport-netty4',
  263     "org.elasticsearch.plugin:reindex-client:${version}": ':modules:reindex',
  264     "org.elasticsearch.plugin:lang-mustache-client:${version}": ':modules:lang-mustache',
  265     "org.elasticsearch.plugin:parent-join-client:${version}": ':modules:parent-join',
  266     "org.elasticsearch.plugin:aggs-matrix-stats-client:${version}": ':modules:aggs-matrix-stats',
  267     "org.elasticsearch.plugin:percolator-client:${version}": ':modules:percolator',
  268     "org.elasticsearch.plugin:rank-eval-client:${version}": ':modules:rank-eval',
  269     // for security example plugins
  270     "org.elasticsearch.plugin:x-pack-core:${version}": ':x-pack:plugin:core',
  271     "org.elasticsearch.client.x-pack-transport:${version}": ':x-pack:transport-client'
  272   ]
  273   // substitute unreleased versions with projects that check out and build locally
  274   bwcVersions.forPreviousUnreleased { VersionCollection.UnreleasedVersionInfo unreleasedVersion ->
  275     Version unreleased = unreleasedVersion.version
  276     String snapshotProject = ":distribution:bwc:${unreleasedVersion.gradleProjectName}"
  277     ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${unreleased}"] = snapshotProject
  278     ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${unreleased}"] = snapshotProject
  279     ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${unreleased}"] = snapshotProject
  280     if (unreleased.onOrAfter('6.3.0')) {
  281       ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch-oss:${unreleased}"] = snapshotProject
  282       ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch-oss:${unreleased}"] = snapshotProject
  283       ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch-oss:${unreleased}"] = snapshotProject
  284     }
  285   }
  286 
  287   /*
  288    * Gradle only resolve project substitutions during dependency resolution but
  289    * we sometimes want to do the resolution at other times. This creates a
  290    * convenient method we can call to do it.
  291    */
  292   ext.dependencyToProject = { Dependency dep ->
  293     if (dep instanceof ProjectDependency) {
  294       return dep.dependencyProject
  295     } else {
  296       String substitution = projectSubstitutions.get("${dep.group}:${dep.name}:${dep.version}")
  297       if (substitution != null) {
  298         return findProject(substitution)
  299       }
  300       return null
  301     }
  302   }
  303 
  304   project.afterEvaluate {
  305     configurations.all {
  306       resolutionStrategy.dependencySubstitution { DependencySubstitutions subs ->
  307         projectSubstitutions.each { k,v ->
  308           subs.substitute(subs.module(k)).with(subs.project(v))
  309         }
  310       }
  311     }
  312 
  313     // Handle javadoc dependencies across projects. Order matters: the linksOffline for
  314     // org.elasticsearch:elasticsearch must be the last one or all the links for the
  315     // other packages (e.g org.elasticsearch.client) will point to server rather than
  316     // their own artifacts.
  317     if (project.plugins.hasPlugin(BuildPlugin) || project.plugins.hasPlugin(PluginBuildPlugin)) {
  318       String artifactsHost = VersionProperties.elasticsearch.endsWith("-SNAPSHOT") ? "https://snapshots.elastic.co" : "https://artifacts.elastic.co"
  319       Closure sortClosure = { a, b -> b.group <=> a.group }
  320       Closure depJavadocClosure = { shadowed, dep ->
  321         if (dep.group == null || false == dep.group.startsWith('org.elasticsearch')) {
  322           return
  323         }
  324         Project upstreamProject = project.ext.dependencyToProject(dep)
  325         if (upstreamProject == null) {
  326           return
  327         }
  328         if (shadowed) {
  329           /*
  330            * Include the source of shadowed upstream projects so we don't
  331            * have to publish their javadoc.
  332            */
  333           project.evaluationDependsOn(upstreamProject.path)
  334           project.javadoc.source += upstreamProject.javadoc.source
  335           /*
  336            * Instead we need the upstream project's javadoc classpath so
  337            * we don't barf on the classes that it references.
  338            */
  339           project.javadoc.classpath += upstreamProject.javadoc.classpath
  340         } else {
  341           // Link to non-shadowed dependant projects
  342           project.javadoc.dependsOn "${upstreamProject.path}:javadoc"
  343           String artifactPath = dep.group.replaceAll('\\.', '/') + '/' + dep.name.replaceAll('\\.', '/') + '/' + dep.version
  344           project.javadoc.options.linksOffline artifactsHost + "/javadoc/" + artifactPath, "${upstreamProject.buildDir}/docs/javadoc/"
  345         }
  346       }
  347       boolean hasShadow = project.plugins.hasPlugin(ShadowPlugin)
  348       project.configurations.compile.dependencies
  349           .findAll()
  350           .toSorted(sortClosure)
  351           .each({ c -> depJavadocClosure(false, c) })
  352       project.configurations.compileOnly.dependencies
  353           .findAll()
  354           .toSorted(sortClosure)
  355           .each({ c -> depJavadocClosure(false, c) })
  356       if (hasShadow) {
  357         project.configurations.bundle.dependencies
  358             .findAll()
  359             .toSorted(sortClosure)
  360             .each({ c -> depJavadocClosure(true, c) })
  361       }
  362     }
  363   }
  364 }
  365 
  366 // Ensure similar tasks in dependent projects run first. The projectsEvaluated here is
  367 // important because, while dependencies.all will pickup future dependencies,
  368 // it is not necessarily true that the task exists in both projects at the time
  369 // the dependency is added.
  370 gradle.projectsEvaluated {
  371   allprojects {
  372     if (project.path == ':test:framework') {
  373       // :test:framework:test cannot run before and after :server:test
  374       return
  375     }
  376     if (tasks.findByPath('test') != null && tasks.findByPath('integTest') != null) {
  377       integTest.mustRunAfter test
  378     }
  379     configurations.all { Configuration configuration ->
  380       dependencies.all { Dependency dep ->
  381         Project upstreamProject = dependencyToProject(dep)
  382         if (upstreamProject != null) {
  383           if (project.path == upstreamProject.path) {
  384             // TODO: distribution integ tests depend on themselves (!), fix that
  385             return
  386           }
  387           for (String taskName : ['test', 'integTest']) {
  388             Task task = project.tasks.findByName(taskName)
  389             Task upstreamTask = upstreamProject.tasks.findByName(taskName)
  390             if (task != null && upstreamTask != null) {
  391               task.shouldRunAfter(upstreamTask)
  392             }
  393           }
  394         }
  395       }
  396     }
  397   }
  398 }
  399 
  400 // eclipse configuration
  401 allprojects {
  402   apply plugin: 'eclipse'
  403   // Name all the non-root projects after their path so that paths get grouped together when imported into eclipse.
  404   if (path != ':') {
  405     eclipse.project.name = path
  406     if (Os.isFamily(Os.FAMILY_WINDOWS)) {
  407       eclipse.project.name = eclipse.project.name.replace(':', '_')
  408     }
  409   }
  410 
  411   plugins.withType(JavaBasePlugin) {
  412     eclipse.classpath.defaultOutputDir = file('build-eclipse')
  413     eclipse.classpath.file.whenMerged { classpath ->
  414       // give each source folder a unique corresponding output folder
  415       int i = 0;
  416       classpath.entries.findAll { it instanceof SourceFolder }.each { folder ->
  417         i++;
  418         folder.output = "build-eclipse/" + i
  419       }
  420     }
  421   }
  422 
  423   File licenseHeaderFile
  424   String prefix = ':x-pack'
  425   if (Os.isFamily(Os.FAMILY_WINDOWS)) {
  426     prefix = prefix.replace(':', '_')
  427   }
  428   if (eclipse.project.name.startsWith(prefix)) {
  429       licenseHeaderFile = new File(project.rootDir, 'buildSrc/src/main/resources/license-headers/elastic-license-header.txt')
  430   } else {
  431       licenseHeaderFile = new File(project.rootDir, 'buildSrc/src/main/resources/license-headers/oss-license-header.txt')
  432   }
  433 
  434   String lineSeparator = Os.isFamily(Os.FAMILY_WINDOWS) ? '\\\\r\\\\n' : '\\\\n'
  435   String licenseHeader = licenseHeaderFile.getText('UTF-8').replace(System.lineSeparator(), lineSeparator)
  436   task copyEclipseSettings(type: Copy) {
  437     // TODO: "package this up" for external builds
  438     from new File(project.rootDir, 'buildSrc/src/main/resources/eclipse.settings')
  439     into '.settings'
  440     filter{ it.replaceAll('@@LICENSE_HEADER_TEXT@@', licenseHeader)}
  441   }
  442   // otherwise .settings is not nuked entirely
  443   task wipeEclipseSettings(type: Delete) {
  444     delete '.settings'
  445   }
  446   tasks.cleanEclipse.dependsOn(wipeEclipseSettings)
  447   // otherwise the eclipse merging is *super confusing*
  448   tasks.eclipse.dependsOn(cleanEclipse, copyEclipseSettings)
  449 
  450   // work arround https://github.com/gradle/gradle/issues/6582
  451   tasks.eclipseProject.mustRunAfter tasks.cleanEclipseProject
  452   tasks.matching { it.name == 'eclipseClasspath' }.all {
  453     it.mustRunAfter { tasks.cleanEclipseClasspath }
  454   }
  455   tasks.matching { it.name == 'eclipseJdt' }.all {
  456     it.mustRunAfter { tasks.cleanEclipseJdt }
  457   }
  458   tasks.copyEclipseSettings.mustRunAfter tasks.wipeEclipseSettings
  459 }
  460 
  461 allprojects {
  462   /*
  463    * IntelliJ and Eclipse don't know about the shadow plugin so when we're
  464    * in "IntelliJ mode" or "Eclipse mode" switch "bundle" dependencies into
  465    * regular "compile" dependencies. This isn't needed for the project
  466    * itself because the IDE configuration is done by SourceSets but it is
  467    * *is* needed for projects that depends on the project doing the shadowing.
  468    * Without this they won't properly depend on the shadowed project.
  469    */
  470   if (isEclipse) {
  471     project.plugins.withType(ShadowPlugin).whenPluginAdded {
  472       project.afterEvaluate {
  473         project.configurations.compile.extendsFrom project.configurations.bundle
  474       }
  475     }
  476   }
  477 }
  478 
  479 // we need to add the same --debug-jvm option as
  480 // the real RunTask has, so we can pass it through
  481 class Run extends DefaultTask {
  482   boolean debug = false
  483 
  484   @Option(
  485         option = "debug-jvm",
  486         description = "Enable debugging configuration, to allow attaching a debugger to elasticsearch."
  487   )
  488   public void setDebug(boolean enabled) {
  489     project.project(':distribution').run.clusterConfig.debug = enabled
  490   }
  491 }
  492 task run(type: Run) {
  493   dependsOn ':distribution:run'
  494   description = 'Runs elasticsearch in the foreground'
  495   group = 'Verification'
  496   impliesSubProjects = true
  497 }
  498 
  499 wrapper {
  500     distributionType = 'ALL'
  501     doLast {
  502         final DistributionLocator locator = new DistributionLocator()
  503         final GradleVersion version = GradleVersion.version(wrapper.gradleVersion)
  504         final URI distributionUri = locator.getDistributionFor(version, wrapper.distributionType.name().toLowerCase(Locale.ENGLISH))
  505         final URI sha256Uri = new URI(distributionUri.toString() + ".sha256")
  506         final String sha256Sum = new String(sha256Uri.toURL().bytes)
  507         wrapper.getPropertiesFile() << "distributionSha256Sum=${sha256Sum}\n"
  508         println "Added checksum to wrapper properties"
  509         // Update build-tools to reflect the Gradle upgrade
  510         // TODO: we can remove this once we have tests to make sure older versions work.
  511         project(':build-tools').file('src/main/resources/minimumGradleVersion').text = gradleVersion
  512         println "Updated minimum Gradle Version"
  513     }
  514 }
  515 
  516 gradle.projectsEvaluated {
  517   subprojects {
  518     /*
  519      * Remove assemble/dependenciesInfo on all qa projects because we don't
  520      * need to publish artifacts for them.
  521      */
  522     if (project.name.equals('qa') || project.path.contains(':qa:')) {
  523       Task assemble = project.tasks.findByName('assemble')
  524       if (assemble) {
  525         assemble.enabled = false
  526       }
  527       Task dependenciesInfo = project.tasks.findByName('dependenciesInfo')
  528       if (dependenciesInfo) {
  529         dependenciesInfo.enabled = false
  530       }
  531     }
  532   }
  533 }
  534 
  535 if (System.properties.get("build.compare") != null) {
  536   apply plugin: 'compare-gradle-builds'
  537   compareGradleBuilds {
  538     ext.referenceProject = System.properties.get("build.compare")
  539     doFirst {
  540       if (file(referenceProject).exists() == false) {
  541         throw new GradleException(
  542                 "Use git worktree to check out a version to compare against to ../elasticsearch_build_reference"
  543         )
  544       }
  545     }
  546     sourceBuild {
  547       gradleVersion = gradle.getGradleVersion()
  548       projectDir = referenceProject
  549       tasks = ["clean", "assemble"]
  550       arguments = ["-Dbuild.compare_friendly=true"]
  551     }
  552     targetBuild {
  553       tasks = ["clean", "assemble"]
  554       // use -Dorg.gradle.java.home= to alter jdk versions
  555       arguments = ["-Dbuild.compare_friendly=true"]
  556     }
  557   }
  558 }
  559 
  560 allprojects {
  561   task resolveAllDependencies {
  562     if (project.path.contains("fixture")) {
  563       dependsOn tasks.withType(ComposePull)
  564     }
  565     doLast {
  566       configurations.findAll { it.isCanBeResolved() }.each { it.resolve() }
  567     }
  568   }
  569 }
  570 
  571 allprojects {
  572   task checkPart1
  573   task checkPart2
  574   tasks.matching { it.name == "check" }.all { check ->
  575     if (check.path.startsWith(":x-pack:")) {
  576       checkPart2.dependsOn check
  577     } else {
  578       checkPart1.dependsOn check
  579     }
  580   }
  581 }
  582 
  583 
  584 
  585