build.gradle 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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. apply plugin: 'elasticsearch.build'
  20. apply plugin: 'nebula.optional-base'
  21. apply plugin: 'elasticsearch.publish'
  22. apply plugin: 'elasticsearch.internal-cluster-test'
  23. publishing {
  24. publications {
  25. nebula {
  26. artifactId 'elasticsearch'
  27. }
  28. }
  29. }
  30. archivesBaseName = 'elasticsearch'
  31. dependencies {
  32. api project(':libs:elasticsearch-core')
  33. api project(':libs:elasticsearch-secure-sm')
  34. api project(':libs:elasticsearch-x-content')
  35. api project(":libs:elasticsearch-geo")
  36. compileOnly project(':libs:elasticsearch-plugin-classloader')
  37. testRuntimeOnly project(':libs:elasticsearch-plugin-classloader')
  38. // lucene
  39. api "org.apache.lucene:lucene-core:${versions.lucene}"
  40. api "org.apache.lucene:lucene-analyzers-common:${versions.lucene}"
  41. api "org.apache.lucene:lucene-backward-codecs:${versions.lucene}"
  42. api "org.apache.lucene:lucene-grouping:${versions.lucene}"
  43. api "org.apache.lucene:lucene-highlighter:${versions.lucene}"
  44. api "org.apache.lucene:lucene-join:${versions.lucene}"
  45. api "org.apache.lucene:lucene-memory:${versions.lucene}"
  46. api "org.apache.lucene:lucene-misc:${versions.lucene}"
  47. api "org.apache.lucene:lucene-queries:${versions.lucene}"
  48. api "org.apache.lucene:lucene-queryparser:${versions.lucene}"
  49. api "org.apache.lucene:lucene-sandbox:${versions.lucene}"
  50. api "org.apache.lucene:lucene-spatial-extras:${versions.lucene}"
  51. api "org.apache.lucene:lucene-spatial3d:${versions.lucene}"
  52. api "org.apache.lucene:lucene-suggest:${versions.lucene}"
  53. // utilities
  54. api project(":libs:elasticsearch-cli")
  55. api 'com.carrotsearch:hppc:0.8.1'
  56. // time handling, remove with java 8 time
  57. api "joda-time:joda-time:${versions.joda}"
  58. // percentiles aggregation
  59. api 'com.tdunning:t-digest:3.2'
  60. // precentil ranks aggregation
  61. api 'org.hdrhistogram:HdrHistogram:2.1.9'
  62. // lucene spatial
  63. api "org.locationtech.spatial4j:spatial4j:${versions.spatial4j}", optional
  64. api "org.locationtech.jts:jts-core:${versions.jts}", optional
  65. // logging
  66. api "org.apache.logging.log4j:log4j-api:${versions.log4j}"
  67. api "org.apache.logging.log4j:log4j-core:${versions.log4j}", optional
  68. // repackaged jna with native bits linked against all elastic supported platforms
  69. api "org.elasticsearch:jna:${versions.jna}"
  70. api "co.elastic.logging:log4j2-ecs-layout:${versions.ecsLogging}"
  71. api "co.elastic.logging:ecs-logging-core:${versions.ecsLogging}"
  72. testImplementation(project(":test:framework")) {
  73. // tests use the locally compiled version of server
  74. exclude group: 'org.elasticsearch', module: 'server'
  75. }
  76. internalClusterTestImplementation(project(":test:framework")) {
  77. exclude group: 'org.elasticsearch', module: 'server'
  78. }
  79. }
  80. tasks.withType(JavaCompile).configureEach {
  81. options.compilerArgs << "-Xlint:-cast,-rawtypes,-unchecked"
  82. }
  83. // Until this project is always being formatted with spotless, we need to
  84. // guard against `spotless()` not existing.
  85. try {
  86. spotless {
  87. java {
  88. // Contains large data tables that do not format well.
  89. targetExclude 'src/main/java/org/elasticsearch/search/aggregations/metrics/HyperLogLogPlusPlus.java'
  90. }
  91. }
  92. }
  93. catch (Exception e) {
  94. if (e.getMessage().contains("Could not find method spotless") == false) {
  95. throw e;
  96. }
  97. }
  98. tasks.named("forbiddenPatterns").configure {
  99. exclude '**/*.json'
  100. exclude '**/*.jmx'
  101. exclude '**/*.dic'
  102. exclude '**/*.binary'
  103. exclude '**/*.st'
  104. }
  105. tasks.named("testingConventions").configure {
  106. naming.clear()
  107. naming {
  108. Tests {
  109. baseClass "org.apache.lucene.util.LuceneTestCase"
  110. }
  111. IT {
  112. baseClass "org.elasticsearch.test.ESIntegTestCase"
  113. baseClass "org.elasticsearch.test.ESSingleNodeTestCase"
  114. }
  115. }
  116. }
  117. def generateModulesList = tasks.register("generateModulesList") {
  118. List<String> modules = project(':modules').subprojects.collect { it.name }
  119. modules.add('x-pack')
  120. File modulesFile = new File(buildDir, 'generated-resources/modules.txt')
  121. processResources.from(modulesFile)
  122. inputs.property('modules', modules)
  123. outputs.file(modulesFile)
  124. doLast {
  125. modulesFile.parentFile.mkdirs()
  126. modulesFile.setText(modules.join('\n'), 'UTF-8')
  127. }
  128. }
  129. def generatePluginsList = tasks.register("generatePluginsList") {
  130. Set<String> plugins = new TreeSet<>(project(':plugins').childProjects.keySet())
  131. plugins.remove('example')
  132. File pluginsFile = new File(buildDir, 'generated-resources/plugins.txt')
  133. processResources.from(pluginsFile)
  134. inputs.property('plugins', plugins)
  135. outputs.file(pluginsFile)
  136. doLast {
  137. pluginsFile.parentFile.mkdirs()
  138. pluginsFile.setText(plugins.join('\n'), 'UTF-8')
  139. }
  140. }
  141. tasks.named("processResources").configure {
  142. dependsOn generateModulesList, generatePluginsList
  143. }
  144. tasks.named("thirdPartyAudit").configure {
  145. ignoreMissingClasses(
  146. // from com.fasterxml.jackson.dataformat.yaml.YAMLMapper (jackson-dataformat-yaml)
  147. 'com.fasterxml.jackson.databind.ObjectMapper',
  148. // from log4j
  149. 'com.conversantmedia.util.concurrent.DisruptorBlockingQueue',
  150. 'com.conversantmedia.util.concurrent.SpinPolicy',
  151. 'com.fasterxml.jackson.databind.SerializationFeature',
  152. 'com.fasterxml.jackson.annotation.JsonInclude$Include',
  153. 'com.fasterxml.jackson.databind.DeserializationContext',
  154. 'com.fasterxml.jackson.databind.DeserializationFeature',
  155. 'com.fasterxml.jackson.databind.JsonMappingException',
  156. 'com.fasterxml.jackson.databind.JsonNode',
  157. 'com.fasterxml.jackson.databind.Module$SetupContext',
  158. 'com.fasterxml.jackson.databind.ObjectReader',
  159. 'com.fasterxml.jackson.databind.ObjectWriter',
  160. 'com.fasterxml.jackson.databind.SerializerProvider',
  161. 'com.fasterxml.jackson.databind.deser.std.StdDeserializer',
  162. 'com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer',
  163. 'com.fasterxml.jackson.databind.module.SimpleModule',
  164. 'com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter',
  165. 'com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider',
  166. 'com.fasterxml.jackson.databind.ser.std.StdScalarSerializer',
  167. 'com.fasterxml.jackson.databind.ser.std.StdSerializer',
  168. 'com.fasterxml.jackson.dataformat.xml.JacksonXmlModule',
  169. 'com.fasterxml.jackson.dataformat.xml.XmlMapper',
  170. 'com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter',
  171. 'com.fasterxml.jackson.databind.node.ObjectNode',
  172. 'org.fusesource.jansi.Ansi',
  173. 'org.fusesource.jansi.AnsiRenderer$Code',
  174. 'com.lmax.disruptor.BlockingWaitStrategy',
  175. 'com.lmax.disruptor.BusySpinWaitStrategy',
  176. 'com.lmax.disruptor.EventFactory',
  177. 'com.lmax.disruptor.EventTranslator',
  178. 'com.lmax.disruptor.EventTranslatorTwoArg',
  179. 'com.lmax.disruptor.EventTranslatorVararg',
  180. 'com.lmax.disruptor.ExceptionHandler',
  181. 'com.lmax.disruptor.LifecycleAware',
  182. 'com.lmax.disruptor.RingBuffer',
  183. 'com.lmax.disruptor.Sequence',
  184. 'com.lmax.disruptor.SequenceReportingEventHandler',
  185. 'com.lmax.disruptor.SleepingWaitStrategy',
  186. 'com.lmax.disruptor.TimeoutBlockingWaitStrategy',
  187. 'com.lmax.disruptor.WaitStrategy',
  188. 'com.lmax.disruptor.YieldingWaitStrategy',
  189. 'com.lmax.disruptor.dsl.Disruptor',
  190. 'com.lmax.disruptor.dsl.ProducerType',
  191. 'javax.jms.Connection',
  192. 'javax.jms.ConnectionFactory',
  193. 'javax.jms.Destination',
  194. 'javax.jms.JMSException',
  195. 'javax.jms.MapMessage',
  196. 'javax.jms.Message',
  197. 'javax.jms.MessageConsumer',
  198. 'javax.jms.MessageProducer',
  199. 'javax.jms.Session',
  200. 'javax.mail.Authenticator',
  201. 'javax.mail.Message$RecipientType',
  202. 'javax.mail.PasswordAuthentication',
  203. 'javax.mail.Session',
  204. 'javax.mail.Transport',
  205. 'javax.mail.internet.InternetAddress',
  206. 'javax.mail.internet.InternetHeaders',
  207. 'javax.mail.internet.MimeBodyPart',
  208. 'javax.mail.internet.MimeMessage',
  209. 'javax.mail.internet.MimeMultipart',
  210. 'javax.mail.internet.MimeUtility',
  211. 'javax.mail.util.ByteArrayDataSource',
  212. 'org.apache.commons.compress.compressors.CompressorStreamFactory',
  213. 'org.apache.commons.compress.utils.IOUtils',
  214. 'org.apache.commons.csv.CSVFormat',
  215. 'org.apache.commons.csv.QuoteMode',
  216. 'org.apache.kafka.clients.producer.Callback',
  217. 'org.apache.kafka.clients.producer.KafkaProducer',
  218. 'org.apache.kafka.clients.producer.Producer',
  219. 'org.apache.kafka.clients.producer.ProducerRecord',
  220. 'org.apache.kafka.clients.producer.RecordMetadata',
  221. 'org.codehaus.stax2.XMLStreamWriter2',
  222. 'org.jctools.queues.MessagePassingQueue$Consumer',
  223. 'org.jctools.queues.MpscArrayQueue',
  224. 'org.osgi.framework.AdaptPermission',
  225. 'org.osgi.framework.AdminPermission',
  226. 'org.osgi.framework.Bundle',
  227. 'org.osgi.framework.BundleActivator',
  228. 'org.osgi.framework.BundleContext',
  229. 'org.osgi.framework.BundleEvent',
  230. 'org.osgi.framework.BundleReference',
  231. 'org.osgi.framework.FrameworkUtil',
  232. 'org.osgi.framework.ServiceRegistration',
  233. 'org.osgi.framework.SynchronousBundleListener',
  234. 'org.osgi.framework.wiring.BundleWire',
  235. 'org.osgi.framework.wiring.BundleWiring',
  236. 'org.zeromq.ZMQ$Context',
  237. 'org.zeromq.ZMQ$Socket',
  238. 'org.zeromq.ZMQ',
  239. // from org.locationtech.spatial4j.io.GeoJSONReader (spatial4j)
  240. 'org.noggit.JSONParser',
  241. // from lucene-spatial
  242. 'com.fasterxml.jackson.databind.JsonSerializer',
  243. 'com.fasterxml.jackson.databind.JsonDeserializer',
  244. 'com.fasterxml.jackson.databind.node.ArrayNode',
  245. 'com.google.common.geometry.S2Cell',
  246. 'com.google.common.geometry.S2CellId',
  247. 'com.google.common.geometry.S2Projections',
  248. 'com.google.common.geometry.S2Point',
  249. 'com.google.common.geometry.S2$Metric',
  250. 'com.google.common.geometry.S2LatLng'
  251. )
  252. ignoreMissingClasses 'javax.xml.bind.DatatypeConverter'
  253. }
  254. tasks.named("dependencyLicenses").configure {
  255. mapping from: /lucene-.*/, to: 'lucene'
  256. dependencies = project.configurations.runtimeClasspath.fileCollection {
  257. it.group.startsWith('org.elasticsearch') == false ||
  258. // keep the following org.elasticsearch jars in
  259. (it.name == 'jna' ||
  260. it.name == 'securesm')
  261. }
  262. }
  263. tasks.named("licenseHeaders").configure {
  264. // Ignore our vendored version of Google Guice
  265. excludes << 'org/elasticsearch/common/inject/**/*'
  266. }