build.gradle 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import org.elasticsearch.gradle.precommit.PrecommitTasks
  2. /*
  3. * Licensed to Elasticsearch under one or more contributor
  4. * license agreements. See the NOTICE file distributed with
  5. * this work for additional information regarding copyright
  6. * ownership. Elasticsearch licenses this file to you under
  7. * the Apache License, Version 2.0 (the "License"); you may
  8. * not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. */
  20. apply plugin: 'nebula.optional-base'
  21. apply plugin: 'nebula.maven-base-publish'
  22. apply plugin: 'nebula.maven-scm'
  23. archivesBaseName = 'elasticsearch-core'
  24. // we want to keep the JDKs in our IDEs set to JDK 8 until minimum JDK is bumped to 9 so we do not include this source set in our IDEs
  25. if (!isEclipse && !isIdea) {
  26. sourceSets {
  27. java9 {
  28. java {
  29. srcDirs = ['src/main/java9']
  30. }
  31. }
  32. }
  33. configurations {
  34. java9Compile.extendsFrom(compile)
  35. }
  36. dependencies {
  37. java9Compile sourceSets.main.output
  38. }
  39. compileJava9Java {
  40. sourceCompatibility = 9
  41. targetCompatibility = 9
  42. }
  43. /* Enable this when forbiddenapis was updated to 2.6.
  44. * See: https://github.com/elastic/elasticsearch/issues/29292
  45. forbiddenApisJava9 {
  46. targetCompatibility = 9
  47. }
  48. */
  49. jar {
  50. metaInf {
  51. into 'versions/9'
  52. from sourceSets.java9.output
  53. }
  54. manifest.attributes('Multi-Release': 'true')
  55. }
  56. }
  57. publishing {
  58. publications {
  59. nebula {
  60. artifactId = archivesBaseName
  61. }
  62. }
  63. }
  64. dependencies {
  65. testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
  66. testCompile "junit:junit:${versions.junit}"
  67. testCompile "org.hamcrest:hamcrest-all:${versions.hamcrest}"
  68. if (!isEclipse && !isIdea) {
  69. java9Compile sourceSets.main.output
  70. }
  71. if (isEclipse == false || project.path == ":libs:elasticsearch-core-tests") {
  72. testCompile("org.elasticsearch.test:framework:${version}") {
  73. exclude group: 'org.elasticsearch', module: 'elasticsearch-core'
  74. }
  75. }
  76. }
  77. forbiddenApisMain {
  78. // elasticsearch-core does not depend on server
  79. // TODO: Need to decide how we want to handle for forbidden signatures with the changes to core
  80. signaturesURLs = [PrecommitTasks.getResource('/forbidden/jdk-signatures.txt')]
  81. }
  82. if (isEclipse) {
  83. // in eclipse the project is under a fake root, we need to change around the source sets
  84. sourceSets {
  85. if (project.path == ":libs:elasticsearch-core") {
  86. main.java.srcDirs = ['java']
  87. main.resources.srcDirs = ['resources']
  88. } else {
  89. test.java.srcDirs = ['java']
  90. test.resources.srcDirs = ['resources']
  91. }
  92. }
  93. }
  94. thirdPartyAudit.excludes = [
  95. // from log4j
  96. 'org/osgi/framework/AdaptPermission',
  97. 'org/osgi/framework/AdminPermission',
  98. 'org/osgi/framework/Bundle',
  99. 'org/osgi/framework/BundleActivator',
  100. 'org/osgi/framework/BundleContext',
  101. 'org/osgi/framework/BundleEvent',
  102. 'org/osgi/framework/SynchronousBundleListener',
  103. 'org/osgi/framework/wiring/BundleWire',
  104. 'org/osgi/framework/wiring/BundleWiring'
  105. ]