settings.gradle 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
  3. * or more contributor license agreements. Licensed under the Elastic License
  4. * 2.0 and the Server Side Public License, v 1; you may not use this file except
  5. * in compliance with, at your election, the Elastic License 2.0 or the Server
  6. * Side Public License, v 1.
  7. */
  8. plugins {
  9. id "com.gradle.enterprise" version "3.8.1"
  10. }
  11. // Include all subdirectories as example projects
  12. rootDir.listFiles().findAll { it.directory && new File(it, 'build.gradle').exists() }.each { subDir ->
  13. include ":${subDir.name}"
  14. }
  15. gradle.rootProject {
  16. ext {
  17. // Fetch Elasticsearch version from outer build
  18. new File(rootDir.parentFile.parentFile, 'build-tools-internal/version.properties').withInputStream { is ->
  19. def props = new Properties()
  20. props.load(is)
  21. elasticsearchVersion = "${props.get('elasticsearch')}-SNAPSHOT"
  22. log4jVersion = props.get('log4j')
  23. luceneVersion = props.get('lucene')
  24. }
  25. }
  26. }
  27. gradle.projectsEvaluated {
  28. if (gradle.includedBuilds) {
  29. gradle.allprojects {
  30. configurations.all {
  31. resolutionStrategy.dependencySubstitution {
  32. // When using composite builds we need to tell Gradle to use the project names since we rename the published artifacts
  33. substitute module('org.elasticsearch:elasticsearch') using module("org.elasticsearch:server:${elasticsearchVersion}")
  34. substitute module('org.elasticsearch.client:elasticsearch-rest-client') using module("org.elasticsearch.client:rest:${elasticsearchVersion}")
  35. substitute module('org.elasticsearch.plugin:x-pack-core') with module("org.elasticsearch.plugin:core:${elasticsearchVersion}")
  36. substitute module('org.elasticsearch.plugin:elasticsearch-scripting-painless-spi') with module("org.elasticsearch.plugin:spi:${elasticsearchVersion}")
  37. substitute module('org.elasticsearch.distribution.integ-test-zip:elasticsearch') using variant(module("org.elasticsearch.distribution.integ-test-zip:integ-test-zip:${elasticsearchVersion}")) {
  38. attributes {
  39. attribute(Attribute.of("composite", Boolean.class), true)
  40. }
  41. }
  42. substitute module('elasticsearch-distribution-snapshot:elasticsearch') using variant(module("org.elasticsearch.distribution.default:${getDefaultDistroProjectName()}:${elasticsearchVersion}")) {
  43. attributes {
  44. attribute(Attribute.of("composite", Boolean.class), true)
  45. }
  46. }
  47. }
  48. }
  49. }
  50. }
  51. }
  52. /*
  53. * Determine which :distribution:archives project to use when resolving as part of a composite build.
  54. * We have to duplicate this somewhat, since the example plugins can't use InternalDistributionDownloadPlugin (this is intentional) which is where
  55. * that resolution logic lives.
  56. */
  57. static def getDefaultDistroProjectName() {
  58. String os = System.getProperty("os.name", "")
  59. boolean isArm = System.getProperty("os.arch", "") == 'aarch64'
  60. if (os.startsWith("Windows")) {
  61. return 'windows-zip'
  62. } else if (os.startsWith("Linux") || os.startsWith("LINUX")) {
  63. return isArm ? 'linux-aarch64-tar' : 'linux-tar'
  64. } else if (os.startsWith("Mac")) {
  65. return isArm ? 'darwin-aarch64-tar' : 'darwin-tar'
  66. } else {
  67. throw new GradleException("Unable to determine system platform type.")
  68. }
  69. }