forked from elastic/elasticsearch-hadoop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
983 lines (815 loc) · 31.4 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
import org.gradle.internal.jvm.Jvm
description = 'Elasticsearch for Apache Hadoop'
buildscript {
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/plugins-release' }
}
dependencies {
classpath('org.springframework.build.gradle:propdeps-plugin:0.0.7')
}
}
apply plugin: 'es.hadoop.build'
allprojects {
repositories {
mavenCentral()
// cascading
maven { url "http://conjars.org/repo" }
// storm dependencies
maven { url "https://clojars.org/repo" }
maven { url 'https://repo.spring.io/plugins-release' }
maven { url "https://oss.sonatype.org/content/groups/public/" }
// For Elasticsearch snapshots.
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
// For Lucene Snapshots, Use the lucene version interpreted from build source
if (luceneVersion.contains('-snapshot')) {
// extract the revision number from the version with a regex matcher
String revision = (luceneVersion =~ /\w+-snapshot-([a-z0-9]+)/)[0][1]
maven {
name 'lucene-snapshots'
url "http://s3.amazonaws.com/download.elasticsearch.org/lucenesnapshots/${revision}"
}
}
}
apply plugin: "java"
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'propdeps'
apply plugin: 'propdeps-idea'
apply plugin: 'propdeps-eclipse'
// report plugins
apply plugin: 'findbugs'
apply plugin: 'pmd'
apply plugin: 'jacoco'
apply plugin: 'es.hadoop.build'
apply from: "$rootDir/dist.gradle"
}
println "Building version [$version]"
ext.hadoopClient = []
ext.hadoopDistro = project.hasProperty("distro") ? project.getProperty("distro") : "hadoopStable"
boolean java8 = org.gradle.api.JavaVersion.current().isJava8Compatible()
// Hadoop aliases
String hadoopStableVersion = hadoop22Version
String hadoopYarnVersion = hadoop2Version
String hadoopVersion = hadoopStableVersion
String hadoopMsg
switch (hadoopDistro) {
// Hadoop YARN/2.0.x
case "hadoopYarn":
hadoopVersion = hadoopYarnVersion
hadoopMsg = "Using Apache Hadoop YARN [$hadoopVersion]"
hadoopClient = ["org.apache.hadoop:hadoop-client:$hadoopVersion"]
break
default:
hadoopMsg = "Using Apache Hadoop Stable [$hadoopVersion]"
hadoopVersion = hadoopStableVersion
hadoopClient = ["org.apache.hadoop:hadoop-client:$hadoopVersion"]
}
allprojects {
dependencies {
testCompile "junit:junit:$junitVersion"
testCompile "org.hamcrest:hamcrest-all:$hamcrestVersion"
}
}
if (rootProject == project) {
println hadoopMsg
}
File gitBranch() {
// parse the git files to find out the revision
File gitHead = file("$rootDir/.git/HEAD")
if (gitHead != null && !gitHead.exists()) {
// Try as a sub module
subModuleGit = file("$rootDir/.git")
if (subModuleGit != null && subModuleGit.exists()) {
String content = subModuleGit.text.trim()
if (content.startsWith("gitdir:")) {
gitHead = file("$rootDir/" + content.replace('gitdir: ','') + "/HEAD")
}
}
}
if (gitHead != null && gitHead.exists()) {
String content = gitHead.text.trim()
if (content.startsWith("ref:")) {
return file("$rootDir/.git/" + content.replace('ref: ',''))
}
return gitHead
}
return null
}
String gitHash() {
String rev = "unknown"
File gitHead = gitBranch()
if (gitHead.exists()) {
rev = gitHead.text.trim()
}
return rev
}
String revHash = gitHash()
String nullLog4jConfig = file("$rootDir/mr/src/test/resources/log4jnull.properties").toURI().toURL().toString()
ext.manifestTemplate = manifest {
attributes["Created-By"] = "${System.getProperty("java.version")} (${System.getProperty("java.specification.vendor")})"
attributes['Implementation-Title'] = project.name
attributes['Implementation-Version'] = project.version
attributes['Implementation-URL'] = "https://github.com/elastic/elasticsearch-hadoop"
attributes['Implementation-Vendor'] = "Elastic"
attributes['Implementation-Vendor-Id'] = "org.elasticsearch.hadoop"
String build = System.env['ESHDP.BUILD']
if (build != null)
attributes['Build'] = build
attributes['Repository-Revision'] = revHash
}
allprojects { Project project ->
compileJava {
sourceCompatibility = 1.6
targetCompatibility = 1.6
}
compileJava.options*.compilerArgs = [
"-Xlint:unchecked", "-Xlint:options"
]
compileTestJava {
sourceCompatibility = 1.6
targetCompatibility = 1.6
}
sourceSets.test.resources.srcDirs = ["src/test/resources", "src/test/java"]
test {
reports.html.enabled = true
jacoco {
enabled = project.hasProperty("enableJacoco")
destinationFile = file("${rootProject.buildDir}/jacoco/jacocoTest.exec")
excludes = ["org.elasticsearch.spark.*"]
if (enabled) {
System.setProperty("log4j.configuration", "$nullLog4jConfig")
}
}
}
sourceSets {
itest {
}
}
dependencies {
// makes eclipse classpath easier
testCompile("org.elasticsearch:elasticsearch:${elasticsearchVersion}") {
exclude group: "org.apache.logging.log4j", module: "log4j-api"
exclude group: "org.elasticsearch", module: "elasticsearch-cli"
exclude group: "org.elasticsearch", module: "elasticsearch-core"
exclude group: "org.elasticsearch", module: "elasticsearch-secure-sm"
}
testRuntime "org.slf4j:slf4j-log4j12:1.7.6"
testRuntime "org.apache.logging.log4j:log4j-api:$log4jVersion"
testRuntime "org.apache.logging.log4j:log4j-core:$log4jVersion"
testRuntime "org.apache.logging.log4j:log4j-1.2-api:$log4jVersion"
testRuntime "net.java.dev.jna:jna:4.2.2"
testCompile "org.codehaus.groovy:groovy:$groovyVersion:indy"
testRuntime "org.locationtech.spatial4j:spatial4j:0.6"
testRuntime "com.vividsolutions:jts:1.13"
itestCompile sourceSets.main.output
itestCompile configurations.testCompile
itestCompile configurations.provided
itestCompile sourceSets.test.output
itestRuntime configurations.testRuntime
}
// deal with the messy conflicts out there
configurations.all { Configuration conf ->
conf.resolutionStrategy {
// force the use of commons-http from Hadoop 1.x
// to avoid SLF4J warnings, force only one version
force 'commons-httpclient:commons-httpclient:3.0.1' //, 'org.slf4j:slf4j-log4j12:1.7.6', 'org.slf4j:slf4j-api:1.7.6'
//force 'com.google.guava:guava:18.0' // force guava version for Elastic
force 'joda-time:joda-time:2.8' // force guava version for Spark
force "org.codehaus.jackson:jackson-mapper-asl:$jacksonVersion", "org.codehaus.jackson:jackson-core-asl:$jacksonVersion"
// used when using Elastic non-shaded version
force "commons-cli:commons-cli:1.2"
eachDependency { details ->
// for slf4j use each dependency since there are so many variants
if (details.requested.name.contains("slf4j-")) {
details.useVersion "1.7.6"
}
// log4j needs careful tending with the version
if (details.requested.name.contains("org.apache.logging.log4j") && details.requested.name.contains("log4j-")) {
details.useVersion log4jVersion
}
if (details.requested.name.equals("servlet-api")) {
details.useTarget group: "org.eclipse.jetty.orbit", name: "javax.servlet", version: "3.0.0.v201112011016"
}
}
}
}
// adding the M/R project creates duplicates in the Eclipse CP so here we filter them out
// the lib entries with sources seem to be placed first so they 'win' over those w/o sources
eclipse {
classpath.file {
whenMerged { cp ->
entries.unique { a, b ->
return a.path.compareTo(b.path)
}
entries.removeAll { it.path.endsWith('.pom') }
}
}
jdt {
// use Java 7 since it is required by ES
// ES-Hadoop is still on Java 6 (since Hadoop <2.7 is still on 6)
// but ES 5.0 is JDK8
javaRuntimeName = "JavaSE-1.8"
// specify again the compatibility to override the default JavaRE settings
sourceCompatibility = 1.6
targetCompatibility = 1.6
}
}
jar {
manifest {
from manifestTemplate
}
from("$rootDir/docs/src/info") {
include "license.txt"
include "notice.txt"
into "META-INF"
expand(copyright: new Date().format('yyyy'), version: project.version)
}
}
task sourcesJar(type: Jar, dependsOn:classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
javadoc {
ext.srcDir = file("${rootProject}/docs/src/api")
configure(options) {
//stylesheetFile = file("${rootProject.projectDir}/docs/src/api/javadoc.css")
//overview = "${rootProject.projectDir}/docs/src/api/overview.html"
docFilesSubDirs = true
outputLevel = org.gradle.external.javadoc.JavadocOutputLevel.QUIET
breakIterator = true
author = false
header = project.name
showFromProtected()
// enable it for java 1.8 or higher
if (java8)
addStringOption('Xdoclint:none', '-quiet')
groups = [
'Elasticsearch Map/Reduce' : ['org.elasticsearch.hadoop.mr*'],
'Elasticsearch Cascading' : ['org.elasticsearch.hadoop.cascading*'],
'Elasticsearch Hive' : ['org.elasticsearch.hadoop.hive*'],
'Elasticsearch Pig' : ['org.elasticsearch.hadoop.pig*'],
'Elasticsearch Spark' : ['org.elasticsearch.spark*'],
'Elasticsearch Storm' : ['org.elasticsearch.storm*'],
]
links = [
"https://docs.oracle.com/javase/6/docs/api/",
"https://commons.apache.org/proper/commons-logging/apidocs/",
"https://hadoop.apache.org/docs/stable2/api/",
"https://pig.apache.org/docs/r0.15.0/api/",
"https://hive.apache.org/javadocs/r1.2.1/api/",
"http://docs.cascading.org/cascading/2.6/javadoc/",
"https://spark.apache.org/docs/latest/api/java/",
"https://storm.apache.org/releases/current/javadocs/"
]
excludes = [
"org/elasticsearch/hadoop/mr/compat/**",
"org/elasticsearch/hadoop/rest/**",
"org/elasticsearch/hadoop/serialization/**",
"org/elasticsearch/hadoop/util/**",
"org/apache/hadoop/hive/**"
]
}
title = "${rootProject.description} ${version} API"
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
assemble {
doLast {
project.copy {
from jar.archivePath
from javadocJar.archivePath
from sourcesJar.archivePath
into "$buildDir/distributions"
}
}
}
task pack(dependsOn: [jar, javadocJar, sourcesJar]) {
outputs.files {
jar.archivePath
javadocJar.archivePath
sourcesJar.archivePath
}
artifacts {
archives javadocJar
archives sourcesJar
}
}
configurations { s3 }
uploadToS3 {
ext.toDir = "hadoop"
}
}
configure(rootProject) {
Set<Project> eshModules = subprojects
// jar used for testing Hadoop remotely (es-hadoop + tests)
task hadoopTestingJar(type: Jar, dependsOn: jar) {
eshModules.each { subproject ->
from subproject.sourceSets.test.output
from subproject.sourceSets.main.output
from subproject.sourceSets.itest.output
}
classifier = 'testing'
logger.info("Created Remote Testing Jar")
}
// Simple utility task to help with downloading artifacts and jars
if (project.hasProperty("find-artifact")) {
String artifact = project.getProperty("find-artifact")
configurations {
findJar
}
dependencies {
findJar artifact
}
task find(type: Copy) {
dependsOn configurations.findJar
from configurations.findJar.first()
into new File(rootProject.buildDir, 'found/')
doLast {
if (configurations.findJar.files.size() > 0) {
String artifactName = configurations.findJar.first().name
File found = new File(rootProject.buildDir, 'found/')
logger.lifecycle("Found [$artifactName] and stored it in [$found]")
if (configurations.findJar.size() > 1) {
configurations.findJar.each { logger.lifecycle("Also found other dependencies: [${ it.name }]") }
}
} else {
logger.lifecycle("Could not find artifact [$artifact]")
}
}
}
}
}
static String findJavaHome() {
String javaHome = System.getenv('JAVA_HOME')
if (javaHome == null) {
if (System.getProperty("idea.active") != null || System.getProperty("eclipse.launcher") != null) {
// intellij doesn't set JAVA_HOME, so we use the jdk gradle was run with
javaHome = Jvm.current().javaHome
} else {
throw new GradleException('JAVA_HOME must be set to build Elasticsearch')
}
}
return javaHome
}
project.ext.javaHome = findJavaHome()
project.ext.runtimeJavaHome = javaHome
allprojects { project ->
task integrationTest(type: Test, dependsOn: rootProject.hadoopTestingJar) {
testClassesDirs = sourceSets.itest.output.classesDirs
classpath = sourceSets.itest.runtimeClasspath
excludes = ["**/Abstract*.class"]
ignoreFailures = true
minHeapSize = "256m"
maxHeapSize = "2g"
if (!java8)
jvmArgs '-XX:MaxPermSize=496m'
testLogging {
displayGranularity 0
events "started", "failed" //, "standardOut", "standardError"
exceptionFormat "full"
showCauses true
showExceptions true
showStackTraces true
stackTraceFilters "groovy"
minGranularity 2
maxGranularity 2
}
reports.html.enabled = false
jacoco {
enabled = project.hasProperty("enableJacoco")
append = true
destinationFile = file("${rootProject.buildDir}/jacoco/jacocoTest.exec")
excludes = ["org.elasticsearch.spark.*"]
if (enabled) {
System.setProperty("log4j.configuration", "$nullLog4jConfig")
}
}
}
// Only add cluster settings if it's not the root project
if (project != rootProject) {
logger.info "Configuring ${project.name} integrationTest task to use ES Fixture"
// Create the cluster fixture around the integration test.
// There's probably a more elegant way to do this in Gradle
apply plugin: "es.hadoop.cluster"
}
}
project(":elasticsearch-hadoop-mr") {
description = "Elasticsearch Hadoop Map/Reduce"
dependencies {
provided(hadoopClient)
provided("org.codehaus.jackson:jackson-mapper-asl:$jacksonVersion")
// Testing
if (hadoopVersion.contains("1.0.")) {
// missing dependency in Hadoop 1.0.3/1.0.4
testCompile "commons-io:commons-io:2.1"
}
testCompile "io.netty:netty-all:4.0.29.Final"
testCompile "org.elasticsearch:securemock:1.2"
}
String generatedResources = "$buildDir/generated-resources/main"
sourceSets {
main {
output.dir(generatedResources, builtBy: "generateGitHash")
}
}
task generateGitHash {
inputs.file gitBranch()
outputs.file generatedResources
doLast {
Properties props = new Properties()
props.put("version", version)
props.put("hash", gitHash())
File output = new File(generatedResources, "esh-build.properties")
new File(generatedResources).mkdirs()
output.createNewFile()
props.store(output.newWriter(), null)
}
}
eclipse.classpath.file {
whenMerged { cp ->
// export all jars (to be used upstream by dependent projects) <-- for some reason Gradle removes all jars
cp.entries.each { entry ->
if (entry.hasProperty("exported"))
entry.exported = true
}
}
}
artifacts {
s3 javadocJar
s3 sourcesJar
s3 jar
}
}
// reusable method to nest Map/Reduce module in the rest of the projects to make them usable stand-alone
void nestMRProject(Project target) {
target.evaluationDependsOn(':elasticsearch-hadoop-mr')
target.dependencies {
provided(project(":elasticsearch-hadoop-mr"))
provided(project(path: ":elasticsearch-hadoop-mr", configuration:"compile"))
testCompile project(":elasticsearch-hadoop-mr").sourceSets.test.runtimeClasspath
itestCompile project(":elasticsearch-hadoop-mr").sourceSets.itest.runtimeClasspath
}
target.jar {
from(zipTree(project(":elasticsearch-hadoop-mr").jar.archivePath)) {
include "org/elasticsearch/hadoop/**"
include "esh-build.properties"
}
}
target.javadoc {
source += project(":elasticsearch-hadoop-mr").sourceSets.main.allJava
classpath += files(project(":elasticsearch-hadoop-mr").sourceSets.main.compileClasspath)
}
target.sourcesJar {
from project(":elasticsearch-hadoop-mr").sourceSets.main.allJava.srcDirs
}
target.artifacts {
s3 target.javadocJar
s3 target.sourcesJar
s3 target.jar
}
}
project(":elasticsearch-hadoop-cascading") {
description = "Elasticsearch Hadoop Cascading"
nestMRProject(project)
dependencies {
provided("cascading:cascading-hadoop:$cascadingVersion")
provided("cascading:cascading-local:$cascadingVersion")
}
}
project(":elasticsearch-hadoop-pig") {
description = "Elasticsearch Hadoop Pig"
nestMRProject(project)
ext.pigClassifier = "h2"
dependencies {
provided("org.apache.pig:pig:$pigVersion:$pigClassifier")
testRuntime("joda-time:joda-time:$jodaVersion")
testRuntime "com.google.guava:guava:11.0"
testRuntime "jline:jline:0.9.94"
itestRuntime "dk.brics.automaton:automaton:1.11-8"
}
}
project(":elasticsearch-hadoop-hive") {
description = "Elasticsearch Hadoop Hive"
nestMRProject(project)
dependencies {
provided("org.apache.hive:hive-service:$hiveVersion") {
exclude module: "log4j-slf4j-impl"
}
itestRuntime("org.apache.hive:hive-jdbc:$hiveVersion") {
exclude module: "log4j-slf4j-impl"
}
}
}
// reusable method to nest Map/Reduce module in the rest of the projects to make them usable stand-alone
void baseSparkProject(Project target, String sparkVersion) {
String scalaVer = project.hasProperty("scala") ? project.getProperty("scala") : "211"
switch (scalaVer) {
case "210":
ext.scalaVersion = scala210Version
ext.scalaMajorVersion = scala210MajorVersion
break
case "211":
ext.scalaVersion = scala211Version
ext.scalaMajorVersion = scala211MajorVersion
break
default:
ext.scalaVersion = scala211Version
ext.scalaMajorVersion = scala211MajorVersion
}
target.archivesBaseName += "_$scalaMajorVersion"
target.apply plugin: 'scala'
target.compileScala {
configure(scalaCompileOptions.forkOptions) {
memoryMaximumSize = '1g'
jvmArgs = ['-XX:MaxPermSize=512m']
}
scalaCompileOptions.additionalParameters = [
"-feature",
"-unchecked",
"-deprecation",
"-Xfuture",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Xfatal-warnings"
]
sourceCompatibility = 1.6
targetCompatibility = 1.6
}
println "Spark $sparkVersion compiled using Scala $scalaMajorVersion [$scalaVersion]"
// when using Scala 2.10 use a different folder to cache the artifacts between builds
if (scalaVer == "210") {
target.sourceSets.each {
it.output.classesDir = file(it.output.classesDir.absolutePath.replaceAll("classes", "classes.210"))
}
target.javadoc {
destinationDir = file("$project.docsDir/javadoc-210")
}
target.integrationTest {
// update test target
testClassesDirs = target.sourceSets.itest.output.classesDirs
}
}
String coreSrc = file("$target.projectDir/../core").absolutePath.replace('\\','/')
target.sourceSets {
main.scala.srcDirs += "$coreSrc/main/scala"
test.scala.srcDirs += "$coreSrc/test/scala"
itest.java.srcDirs += "$coreSrc/itest/java"
itest.scala.srcDirs += "$coreSrc/itest/scala"
itest.resources.srcDirs += "$coreSrc/itest/resources"
}
// currently the outside project folders are transformed into linked resources however
// Gradle only supports one so the project will be invalid as not all sources will be in there
// as such, they are setup here manually for Eclipse. IntelliJ probably needs a similar approach
target.eclipse {
project.file.whenMerged { pj ->
// eliminated resources created by gradle
linkedResources.clear()
linkedResources.add(new org.gradle.plugins.ide.eclipse.model.Link("core/main/scala", "2", "$coreSrc/main/scala", null))
linkedResources.add(new org.gradle.plugins.ide.eclipse.model.Link("core/test/scala", "2", "$coreSrc/test/scala", null))
linkedResources.add(new org.gradle.plugins.ide.eclipse.model.Link("core/itest/java", "2", "$coreSrc/itest/java", null))
linkedResources.add(new org.gradle.plugins.ide.eclipse.model.Link("core/itest/scala", "2", "$coreSrc/itest/scala", null))
linkedResources.add(new org.gradle.plugins.ide.eclipse.model.Link("core/itest/resources","2", "$coreSrc/itest/resources", null))
}
classpath.file {
whenMerged { cp ->
entries.removeAll { entry ->
entry.kind == 'src' && (entry.path in ["scala", "java", "resources"] || entry.path.startsWith("itest-") || entry.path.endsWith("-scala"))
}
entries.add(new org.gradle.plugins.ide.eclipse.model.SourceFolder("core/main/scala", null))
entries.add(new org.gradle.plugins.ide.eclipse.model.SourceFolder("core/test/scala", null))
entries.add(new org.gradle.plugins.ide.eclipse.model.SourceFolder("core/itest/java", null))
entries.add(new org.gradle.plugins.ide.eclipse.model.SourceFolder("core/itest/scala", null))
entries.add(new org.gradle.plugins.ide.eclipse.model.SourceFolder("core/itest/resources", null))
}
}
}
target.dependencies {
provided("org.apache.spark:spark-core_$scalaMajorVersion:$sparkVersion") {
exclude group: 'javax.servlet'
exclude group: 'org.apache.hadoop'
}
optional("org.apache.spark:spark-sql_$scalaMajorVersion:$sparkVersion") {
exclude group: 'org.apache.hadoop'
}
compile("org.scala-lang:scala-library:$scalaVersion")
itestCompile("org.apache.spark:spark-sql_$scalaMajorVersion:$sparkVersion") {
exclude group: 'org.apache.hadoop'
}
}
nestMRProject(target)
// disable jacoco as it will fail
test {
jacoco {
enabled = false
}
}
target.scaladoc {
title = "${rootProject.description} ${version} API"
}
}
project(":elasticsearch-spark-13") {
description = "Elasticsearch Spark (for Spark 1.3-1.6)"
baseSparkProject(project, spark13Version)
dependencies {
optional("org.apache.spark:spark-streaming_$scalaMajorVersion:$spark13Version") {
exclude group: 'org.apache.hadoop'
}
itestCompile("org.apache.spark:spark-streaming_$scalaMajorVersion:$spark13Version") {
exclude group: 'org.apache.hadoop'
}
}
// deal with the messy conflicts out there
configurations.all { Configuration conf ->
conf.resolutionStrategy {
eachDependency { details ->
// in a similar vein, change all javax.servlet artifacts to the one used by Spark
// otherwise these will lead to SecurityException (signer information wrong)
if (details.requested.name.contains("servlet") && !details.requested.name.contains("guice")) {
details.useTarget group: "org.eclipse.jetty.orbit", name: "javax.servlet", version: "3.0.0.v201112011016"
}
}
}
conf.exclude group: "org.mortbay.jetty"
}
}
project(":elasticsearch-spark-20") {
description = "Elasticsearch Spark (for Spark 2.0)"
baseSparkProject(project, spark20Version)
dependencies {
optional("org.apache.spark:spark-streaming_$scalaMajorVersion:$spark20Version") {
exclude group: 'org.apache.hadoop'
}
itestCompile("org.apache.spark:spark-streaming_$scalaMajorVersion:$spark20Version") {
exclude group: 'org.apache.hadoop'
}
}
}
project(":elasticsearch-storm") {
description = "Elasticsearch Storm"
nestMRProject(project)
dependencies {
provided("org.apache.storm:storm-core:$stormVersion") {
exclude module: "log4j-slf4j-impl"
}
itestCompile "com.google.guava:guava:16.0.1"
itestRuntime "com.twitter:carbonite:1.4.0"
}
// add itest to Eclipse
//eclipse.classpath.plusConfigurations += [configurations.itestCompile]
integrationTest.enabled = false
}
configure(rootProject) {
description = "Elasticsearch Hadoop"
// include Spark 2.0 support in main jar
Set<Project> eshModules = subprojects - project(":elasticsearch-spark-13")
// build root project dependencies
// extract optional and provided dependencies
eshModules.each { subproject ->
for (scope in ["provided", "optional"]) {
subproject.configurations[scope].allDependencies.findAll { dep ->
// look only at external dependencies
dep instanceof org.gradle.api.artifacts.ExternalDependency
}.each { match ->
// convert all dependencies outside Hadoop (and Jackson) from provided to optional
String depScope = (match.group in ["org.apache.hadoop", "org.codehaus.jackson"] ? "provided" : "optional")
project.dependencies.add(depScope, match)
}
}
}
sourcesJar {
eshModules.each { subproject ->
from subproject.sourceSets.main.allJava.srcDirs
}
}
jar {
dependsOn {
eshModules.collect {
it.tasks.getByName("jar")
}
}
duplicatesStrategy = "exclude"
eshModules.each { subproject ->
from(zipTree(subproject.jar.archivePath)) {
exclude "META-INF/**"
include "**/*"
}
}
doLast {
logger.lifecycle("Writing core JAR with sub projects: ${eshModules.collect {sub -> sub.jar.archivePath}}")
}
}
javadoc {
// aggregate
source eshModules*.javadoc*.source
classpath += files(eshModules*.sourceSets*.main.flatten().compileClasspath)
}
// packaging
task distZip(type: Zip, dependsOn: pack) {
group = "Distribution"
description = "Builds -${classifier} archive, containing all jars and docs, suitable for download page."
dependsOn {
eshModules.collect { it.tasks["pack"] }
}
configurations { s3 }
artifacts { s3 distZip }
ext.folderName = "${baseName}" + "-" + "${version}"
from(".") {
include "README.md"
include "LICENSE.txt"
include "NOTICE.txt"
into folderName
//expand(yyyy: new Date().format("yyyy"), version: project.version)
}
from ("build/libs") {
into "$folderName/dist"
exclude "*-testing.jar"
}
eshModules.each { subproject ->
from (subproject.jar.destinationDir) {
into ("${folderName}/dist")
}
}
// execution phase only
doLast {
ant.checksum(file: archivePath, algorithm: 'SHA1', format: 'MD5SUM', fileext: '.sha1.txt')
}
}
uploadToS3() {
dependsOn(distZip)
}
jacocoTestReport {
subprojects.each {
sourceSets it.sourceSets.main
}
reports {
xml.enabled false
csv.enabled false
html {
enabled = true
destination "${buildDir}/jacoco/html"
}
}
afterEvaluate {
classDirectories = files(classDirectories.files.collect {
// We're excluding Spark since the Scala bytecode trips Jacoco over and the plugin can't import yet filters
fileTree(dir: it, excludes: [ "org/apache/hadoop/hive/**", "org/elasticsearch/spark/**", "org/elasticsearch/plugin/hadoop/**"])
})
}
}
task testReport(type: TestReport) {
destinationDir = file("$buildDir/reports/allTests")
// Include the results from the `test` task in all subprojects
reportOn subprojects*.test
reportOn subprojects*.integrationTest
}
task wrapper(type: Wrapper) {
description = 'Generates gradlew[.bat] scripts'
gradleVersion = '4.5'
}
}
// reporting
allprojects { project ->
findbugs {
toolVersion = "3.0.1"
ignoreFailures = true
effort = "max"
reportLevel = "low"
sourceSets = [sourceSets.main]
}
findbugsMain {
reports {
xml.enabled = true
html.enabled = false
}
enabled = project.hasProperty("enableFindbugs")
}
pmd {
ignoreFailures = true
sourceSets = [sourceSets.main]
toolVersion = "5.3.3"
}
pmdMain {
reports {
xml.enabled = true
html.enabled = false
}
enabled = project.hasProperty("enablePmd")
}
jacoco {
toolVersion = "0.7.5.201505241946"
}
if (java8) {
findbugsMain.enabled = false
pmdMain.enabled = false
}
}
// skip creation of javadoc jars
//assemble.dependsOn = ['jar', 'hadoopTestingJar']
build {
dependsOn 'hadoopTestingJar'
}
defaultTasks 'build'