build.gradle 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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 'java-gradle-plugin'
  10. id 'groovy'
  11. id 'java-test-fixtures'
  12. id 'elasticsearch.publish'
  13. id 'elasticsearch.build-tools'
  14. id 'elasticsearch.eclipse'
  15. id 'elasticsearch.versions'
  16. id 'elasticsearch.formatting'
  17. }
  18. description = "The elasticsearch build tools"
  19. group = "org.elasticsearch.gradle"
  20. version = versions.getProperty("elasticsearch")
  21. java {
  22. targetCompatibility = versions.get("minimumRuntimeJava")
  23. sourceCompatibility = versions.get("minimumRuntimeJava")
  24. }
  25. gradlePlugin {
  26. // We already configure publication and we don't need or want the one that comes
  27. // with the java-gradle-plugin
  28. automatedPublishing = false
  29. plugins {
  30. distributionDownload {
  31. id = 'elasticsearch.distribution-download'
  32. implementationClass = 'org.elasticsearch.gradle.DistributionDownloadPlugin'
  33. }
  34. esPlugin {
  35. id = 'elasticsearch.esplugin'
  36. implementationClass = 'org.elasticsearch.gradle.plugin.PluginBuildPlugin'
  37. }
  38. stableEsPlugin {
  39. id = 'elasticsearch.stable-esplugin'
  40. implementationClass = 'org.elasticsearch.gradle.plugin.StablePluginBuildPlugin'
  41. }
  42. javaRestTest {
  43. id = 'elasticsearch.java-rest-test'
  44. implementationClass = 'org.elasticsearch.gradle.test.JavaRestTestPlugin'
  45. }
  46. testclusters {
  47. id = 'elasticsearch.testclusters'
  48. implementationClass = 'org.elasticsearch.gradle.testclusters.TestClustersPlugin'
  49. }
  50. reaper {
  51. id = 'elasticsearch.reaper'
  52. implementationClass = 'org.elasticsearch.gradle.ReaperPlugin'
  53. }
  54. testpermissions {
  55. id = 'elasticsearch.test-gradle-policy'
  56. implementationClass = 'org.elasticsearch.gradle.test.GradleTestPolicySetupPlugin'
  57. }
  58. yamlTests {
  59. id = 'elasticsearch.yaml-rest-test'
  60. implementationClass = 'org.elasticsearch.gradle.test.YamlRestTestPlugin'
  61. }
  62. }
  63. }
  64. // we update the version property to reflect if we are building a snapshot or a release build
  65. // we write this back out below to load it in the Build.java which will be shown in rest main action
  66. // to indicate this being a snapshot build or a release build.
  67. def generateVersionProperties = tasks.register("generateVersionProperties", WriteProperties) {
  68. destinationFile = new File(buildDir, "version.properties");
  69. comment = 'Generated version properties'
  70. properties(versions)
  71. }
  72. tasks.named("processResources").configure {
  73. from(generateVersionProperties)
  74. into('META-INF') {
  75. from configurations.reaper
  76. }
  77. }
  78. sourceSets {
  79. integTest {
  80. compileClasspath += sourceSets["main"].output + configurations["testRuntimeClasspath"]
  81. runtimeClasspath += output + compileClasspath
  82. }
  83. }
  84. // we do not publish the test fixtures of build-tools
  85. components.java.withVariantsFromConfiguration(configurations.testFixturesApiElements) { skip() }
  86. components.java.withVariantsFromConfiguration(configurations.testFixturesRuntimeElements) { skip() }
  87. publishing.publications.named("elastic").configure {
  88. suppressPomMetadataWarningsFor("testFixturesApiElements")
  89. suppressPomMetadataWarningsFor("testFixturesRuntimeElements")
  90. }
  91. configurations {
  92. integTestImplementation.extendsFrom(testFixturesApi)
  93. integTestImplementation.extendsFrom(testImplementation)
  94. integTestRuntimeOnly.extendsFrom(testRuntimeOnly)
  95. register("reaper")
  96. }
  97. repositories {
  98. mavenCentral()
  99. gradlePluginPortal()
  100. }
  101. dependencies {
  102. constraints {
  103. // ensuring brought asm version brought in by spock is up-to-date
  104. testFixturesApi buildLibs.asm
  105. integTestImplementation buildLibs.asm
  106. }
  107. reaper project('reaper')
  108. api localGroovy()
  109. api gradleApi()
  110. api buildLibs.apache.compress
  111. api buildLibs.ant
  112. api buildLibs.commmons.io
  113. implementation buildLibs.asm.tree
  114. implementation buildLibs.asm
  115. implementation buildLibs.jackson.core
  116. implementation buildLibs.jackson.databind
  117. testFixturesApi gradleApi()
  118. testFixturesApi gradleTestKit()
  119. testFixturesApi buildLibs.junit
  120. testFixturesApi buildLibs.wiremock
  121. testFixturesApi platform(buildLibs.spock.platform)
  122. testFixturesApi(buildLibs.spock.core) {
  123. exclude module: "groovy"
  124. }
  125. testFixturesApi(buildLibs.bytebuddy) {
  126. because 'Generating dynamic plugin apis'
  127. }
  128. testImplementation(buildLibs.spock.junit4) {
  129. because 'required as we rely on junit4 rules'
  130. }
  131. testImplementation(platform(buildLibs.junit5.platform))
  132. testImplementation(buildLibs.junit5.jupiter) {
  133. because 'allows to write and run Jupiter tests'
  134. }
  135. testRuntimeOnly(buildLibs.junit5.vintage) {
  136. because 'allows JUnit 3 and JUnit 4 tests to run'
  137. }
  138. testRuntimeOnly(buildLibs.junit5.platform.launcher) {
  139. because 'allows tests to run from IDEs that bundle older version of launcher'
  140. }
  141. }
  142. tasks.withType(JavaCompile).configureEach {
  143. options.incremental = System.getenv("JENKINS_URL") == null && System.getenv("BUILDKITE_BUILD_URL") == null && System.getProperty("isCI") == null
  144. }
  145. tasks.named('test').configure {
  146. useJUnitPlatform()
  147. }
  148. tasks.register("integTest", Test) {
  149. testClassesDirs = sourceSets.integTest.output.classesDirs
  150. classpath = sourceSets.integTest.runtimeClasspath
  151. useJUnitPlatform()
  152. }
  153. normalization {
  154. runtimeClasspath {
  155. // We already include the reaper jar as part of our runtime classpath. Ignore the copy in META-INF.
  156. ignore('META-INF/reaper.jar')
  157. }
  158. }
  159. tasks.named("check").configure { dependsOn("integTest") }