build.gradle 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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. import com.carrotsearch.gradle.junit4.RandomizedTestingTask
  20. import org.elasticsearch.gradle.BuildPlugin
  21. apply plugin: 'elasticsearch.build'
  22. apply plugin: 'nebula.optional-base'
  23. apply plugin: 'nebula.maven-base-publish'
  24. apply plugin: 'nebula.maven-scm'
  25. publishing {
  26. publications {
  27. nebula {
  28. artifactId 'elasticsearch'
  29. }
  30. }
  31. }
  32. archivesBaseName = 'elasticsearch'
  33. dependencies {
  34. // lucene
  35. compile "org.apache.lucene:lucene-core:${versions.lucene}"
  36. compile "org.apache.lucene:lucene-analyzers-common:${versions.lucene}"
  37. compile "org.apache.lucene:lucene-backward-codecs:${versions.lucene}"
  38. compile "org.apache.lucene:lucene-grouping:${versions.lucene}"
  39. compile "org.apache.lucene:lucene-highlighter:${versions.lucene}"
  40. compile "org.apache.lucene:lucene-join:${versions.lucene}"
  41. compile "org.apache.lucene:lucene-memory:${versions.lucene}"
  42. compile "org.apache.lucene:lucene-misc:${versions.lucene}"
  43. compile "org.apache.lucene:lucene-queries:${versions.lucene}"
  44. compile "org.apache.lucene:lucene-queryparser:${versions.lucene}"
  45. compile "org.apache.lucene:lucene-sandbox:${versions.lucene}"
  46. compile "org.apache.lucene:lucene-spatial:${versions.lucene}"
  47. compile "org.apache.lucene:lucene-spatial-extras:${versions.lucene}"
  48. compile "org.apache.lucene:lucene-spatial3d:${versions.lucene}"
  49. compile "org.apache.lucene:lucene-suggest:${versions.lucene}"
  50. compile 'org.elasticsearch:securesm:1.1'
  51. // utilities
  52. compile 'net.sf.jopt-simple:jopt-simple:5.0.2'
  53. compile 'com.carrotsearch:hppc:0.7.1'
  54. // time handling, remove with java 8 time
  55. compile 'joda-time:joda-time:2.9.5'
  56. // json and yaml
  57. compile "org.yaml:snakeyaml:${versions.snakeyaml}"
  58. compile "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
  59. compile "com.fasterxml.jackson.dataformat:jackson-dataformat-smile:${versions.jackson}"
  60. compile "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${versions.jackson}"
  61. compile "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:${versions.jackson}"
  62. // percentiles aggregation
  63. compile 'com.tdunning:t-digest:3.0'
  64. // precentil ranks aggregation
  65. compile 'org.hdrhistogram:HdrHistogram:2.1.6'
  66. // lucene spatial
  67. compile "org.locationtech.spatial4j:spatial4j:${versions.spatial4j}", optional
  68. compile "com.vividsolutions:jts:${versions.jts}", optional
  69. // logging
  70. compile "org.apache.logging.log4j:log4j-api:${versions.log4j}", optional
  71. compile "org.apache.logging.log4j:log4j-core:${versions.log4j}", optional
  72. // to bridge dependencies that are still on Log4j 1 to Log4j 2
  73. compile "org.apache.logging.log4j:log4j-1.2-api:${versions.log4j}", optional
  74. compile "net.java.dev.jna:jna:${versions.jna}"
  75. if (isEclipse == false || project.path == ":core-tests") {
  76. testCompile("org.elasticsearch.test:framework:${version}") {
  77. // tests use the locally compiled version of core
  78. exclude group: 'org.elasticsearch', module: 'elasticsearch'
  79. }
  80. }
  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 == ":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. compileJava.options.compilerArgs << "-Xlint:-cast,-deprecation,-rawtypes,-try,-unchecked"
  95. compileTestJava.options.compilerArgs << "-Xlint:-cast,-deprecation,-rawtypes,-try,-unchecked"
  96. forbiddenPatterns {
  97. exclude '**/*.json'
  98. exclude '**/*.jmx'
  99. exclude '**/org/elasticsearch/cluster/routing/shard_routes.txt'
  100. }
  101. task generateModulesList {
  102. List<String> modules = project(':modules').subprojects.collect { it.name }
  103. File modulesFile = new File(buildDir, 'generated-resources/modules.txt')
  104. processResources.from(modulesFile)
  105. inputs.property('modules', modules)
  106. outputs.file(modulesFile)
  107. doLast {
  108. modulesFile.parentFile.mkdirs()
  109. modulesFile.setText(modules.join('\n'), 'UTF-8')
  110. }
  111. }
  112. task generatePluginsList {
  113. List<String> plugins = project(':plugins').subprojects
  114. .findAll { it.name.contains('example') == false }
  115. .collect { it.name }
  116. File pluginsFile = new File(buildDir, 'generated-resources/plugins.txt')
  117. processResources.from(pluginsFile)
  118. inputs.property('plugins', plugins)
  119. outputs.file(pluginsFile)
  120. doLast {
  121. pluginsFile.parentFile.mkdirs()
  122. pluginsFile.setText(plugins.join('\n'), 'UTF-8')
  123. }
  124. }
  125. processResources {
  126. dependsOn generateModulesList, generatePluginsList
  127. }
  128. thirdPartyAudit.excludes = [
  129. // classes are missing!
  130. // from com.fasterxml.jackson.dataformat.yaml.YAMLMapper (jackson-dataformat-yaml)
  131. 'com.fasterxml.jackson.databind.ObjectMapper',
  132. // from log4j
  133. 'com.beust.jcommander.IStringConverter',
  134. 'com.beust.jcommander.JCommander',
  135. 'com.conversantmedia.util.concurrent.DisruptorBlockingQueue',
  136. 'com.conversantmedia.util.concurrent.SpinPolicy',
  137. 'com.fasterxml.jackson.annotation.JsonInclude$Include',
  138. 'com.fasterxml.jackson.databind.DeserializationContext',
  139. 'com.fasterxml.jackson.databind.JsonMappingException',
  140. 'com.fasterxml.jackson.databind.JsonNode',
  141. 'com.fasterxml.jackson.databind.Module$SetupContext',
  142. 'com.fasterxml.jackson.databind.ObjectReader',
  143. 'com.fasterxml.jackson.databind.ObjectWriter',
  144. 'com.fasterxml.jackson.databind.SerializerProvider',
  145. 'com.fasterxml.jackson.databind.deser.std.StdDeserializer',
  146. 'com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer',
  147. 'com.fasterxml.jackson.databind.module.SimpleModule',
  148. 'com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter',
  149. 'com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider',
  150. 'com.fasterxml.jackson.databind.ser.std.StdScalarSerializer',
  151. 'com.fasterxml.jackson.databind.ser.std.StdSerializer',
  152. 'com.fasterxml.jackson.dataformat.xml.JacksonXmlModule',
  153. 'com.fasterxml.jackson.dataformat.xml.XmlMapper',
  154. 'com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter',
  155. 'com.fasterxml.jackson.databind.node.JsonNodeFactory',
  156. 'com.fasterxml.jackson.databind.node.ObjectNode',
  157. 'org.fusesource.jansi.Ansi',
  158. 'org.fusesource.jansi.AnsiRenderer$Code',
  159. 'com.lmax.disruptor.BlockingWaitStrategy',
  160. 'com.lmax.disruptor.BusySpinWaitStrategy',
  161. 'com.lmax.disruptor.EventFactory',
  162. 'com.lmax.disruptor.EventTranslator',
  163. 'com.lmax.disruptor.EventTranslatorTwoArg',
  164. 'com.lmax.disruptor.EventTranslatorVararg',
  165. 'com.lmax.disruptor.ExceptionHandler',
  166. 'com.lmax.disruptor.LifecycleAware',
  167. 'com.lmax.disruptor.RingBuffer',
  168. 'com.lmax.disruptor.Sequence',
  169. 'com.lmax.disruptor.SequenceReportingEventHandler',
  170. 'com.lmax.disruptor.SleepingWaitStrategy',
  171. 'com.lmax.disruptor.TimeoutBlockingWaitStrategy',
  172. 'com.lmax.disruptor.WaitStrategy',
  173. 'com.lmax.disruptor.YieldingWaitStrategy',
  174. 'com.lmax.disruptor.dsl.Disruptor',
  175. 'com.lmax.disruptor.dsl.ProducerType',
  176. 'javax.jms.Connection',
  177. 'javax.jms.ConnectionFactory',
  178. 'javax.jms.Destination',
  179. 'javax.jms.Message',
  180. 'javax.jms.MessageConsumer',
  181. 'javax.jms.MessageListener',
  182. 'javax.jms.MessageProducer',
  183. 'javax.jms.ObjectMessage',
  184. 'javax.jms.Session',
  185. 'javax.mail.Authenticator',
  186. 'javax.mail.Message$RecipientType',
  187. 'javax.mail.PasswordAuthentication',
  188. 'javax.mail.Session',
  189. 'javax.mail.Transport',
  190. 'javax.mail.internet.InternetAddress',
  191. 'javax.mail.internet.InternetHeaders',
  192. 'javax.mail.internet.MimeBodyPart',
  193. 'javax.mail.internet.MimeMessage',
  194. 'javax.mail.internet.MimeMultipart',
  195. 'javax.mail.internet.MimeUtility',
  196. 'javax.mail.util.ByteArrayDataSource',
  197. 'javax.persistence.AttributeConverter',
  198. 'javax.persistence.EntityManager',
  199. 'javax.persistence.EntityManagerFactory',
  200. 'javax.persistence.EntityTransaction',
  201. 'javax.persistence.Persistence',
  202. 'javax.persistence.PersistenceException',
  203. 'org.apache.commons.compress.compressors.CompressorStreamFactory',
  204. 'org.apache.commons.compress.utils.IOUtils',
  205. 'org.apache.commons.csv.CSVFormat',
  206. 'org.apache.commons.csv.QuoteMode',
  207. 'org.apache.kafka.clients.producer.KafkaProducer',
  208. 'org.apache.kafka.clients.producer.Producer',
  209. 'org.apache.kafka.clients.producer.ProducerRecord',
  210. 'org.codehaus.stax2.XMLStreamWriter2',
  211. 'org.jctools.queues.MessagePassingQueue$Consumer',
  212. 'org.jctools.queues.MpscArrayQueue',
  213. 'org.osgi.framework.AdaptPermission',
  214. 'org.osgi.framework.AdminPermission',
  215. 'org.osgi.framework.Bundle',
  216. 'org.osgi.framework.BundleActivator',
  217. 'org.osgi.framework.BundleContext',
  218. 'org.osgi.framework.BundleEvent',
  219. 'org.osgi.framework.BundleReference',
  220. 'org.osgi.framework.FrameworkUtil',
  221. 'org.osgi.framework.SynchronousBundleListener',
  222. 'org.osgi.framework.wiring.BundleWire',
  223. 'org.osgi.framework.wiring.BundleWiring',
  224. 'org.zeromq.ZMQ$Context',
  225. 'org.zeromq.ZMQ$Socket',
  226. 'org.zeromq.ZMQ',
  227. // from org.locationtech.spatial4j.io.GeoJSONReader (spatial4j)
  228. 'org.noggit.JSONParser',
  229. ]
  230. dependencyLicenses {
  231. mapping from: /lucene-.*/, to: 'lucene'
  232. mapping from: /jackson-.*/, to: 'jackson'
  233. }
  234. if (isEclipse == false || project.path == ":core-tests") {
  235. task integTest(type: RandomizedTestingTask,
  236. group: JavaBasePlugin.VERIFICATION_GROUP,
  237. description: 'Multi-node tests',
  238. dependsOn: test.dependsOn) {
  239. configure(BuildPlugin.commonTestConfig(project))
  240. classpath = project.test.classpath
  241. testClassesDir = project.test.testClassesDir
  242. include '**/*IT.class'
  243. }
  244. check.dependsOn integTest
  245. integTest.mustRunAfter test
  246. }