forked from elastic/elasticsearch-hadoop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
506 lines (419 loc) · 12.2 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
description = 'Elasticsearch Hadoop'
buildscript {
repositories {
mavenCentral()
maven { url 'http://dl.bintray.com/content/aalmiray/asciidoctor' }
maven { url 'http://jcenter.bintray.com' }
maven { url 'http://repo.springsource.org/plugins-release' }
}
dependencies {
classpath('org.asciidoctor:asciidoctor-gradle-plugin:0.5.0')
classpath('org.springframework.build.gradle:propdeps-plugin:0.0.5')
classpath('nl.javadude.gradle.plugins:license-gradle-plugin:0.5.0')
}
}
allprojects {
repositories {
mavenCentral()
maven { url "http://oss.sonatype.org/content/groups/public/" }
}
}
allprojects {
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 from: "$rootDir/maven.gradle"
apply plugin: 'license'
}
apply plugin: 'asciidoctor'
ext.hadoopClient = []
ext.hadoopDistro = project.hasProperty("distro") ? project.getProperty("distro") : "hadoopStable"
// Hadoop aliases
def hadoopStableVersion = hadoop12Version
def hadoopYarnVersion = hadoop2Version
def hadoopVersion = hadoopStableVersion
def 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;
// Hadoop 1.2.x
case "hadoop12":
hadoopVersion = hadoop12Version
hadoopMsg = "Using Apache Hadoop 1.2.x [$hadoopVersion]"
hadoopClient = ["org.apache.hadoop:hadoop-streaming:$hadoopVersion",
"org.apache.hadoop:hadoop-tools:$hadoopVersion"]
break;
// Hadoop 1.1.x
case "hadoop11":
hadoopVersion = hadoop11Version
hadoopMsg = "Using Apache Hadoop 1.1.x [$hadoopVersion]"
hadoopClient = ["org.apache.hadoop:hadoop-streaming:$hadoopVersion",
"org.apache.hadoop:hadoop-tools:$hadoopVersion"]
break;
// Hadoop 1.0.x
case "hadoop10":
hadoopVersion = hadoop10Version
hadoopMsg = "Using Apache Hadoop 1.0.x [$hadoopVersion]"
hadoopClient = ["org.apache.hadoop:hadoop-streaming:$hadoopVersion",
"org.apache.hadoop:hadoop-tools:$hadoopVersion"]
break;
default:
hadoopMsg = "Using Apache Hadoop Stable [$hadoopVersion]"
hadoopVersion = hadoopStableVersion
hadoopClient = ["org.apache.hadoop:hadoop-streaming:$hadoopVersion",
"org.apache.hadoop:hadoop-tools:$hadoopVersion"]
}
allprojects {
dependencies {
testCompile "junit:junit:$junitVersion"
testCompile "org.hamcrest:hamcrest-all:$hamcrestVersion"
testCompile "org.elasticsearch:elasticsearch:$esVersion"
testRuntime "log4j:log4j:$log4jVersion"
}
if (rootProject == project) {
println hadoopMsg
repositories {
// JDO ec2 missing from Maven Central
maven { url "http://www.datanucleus.org/downloads/maven2" }
maven { url "http://conjars.org/repo" }
}
dependencies {
provided(hadoopClient)
provided("org.codehaus.jackson:jackson-mapper-asl:$jacksonVersion")
// Pig
optional("org.apache.pig:pig:$pigVersion")
ext.hiveGroup = "org.apache.hive"
// Hive
optional("$hiveGroup:hive-service:$hiveVersion")
// Cascading
optional("cascading:cascading-hadoop:$cascadingVersion")
optional("cascading:cascading-local:$cascadingVersion")
// Testing
if (hadoopVersion.contains("1.0.")) {
// missing dependency in Hadoop 1.0.3/1.0.4
testCompile "commons-io:commons-io:2.1"
}
// testRuntime "$hiveGroup:hive-builtins:$hiveVersion"
// Required by Pig
testRuntime "com.google.guava:guava:11.0"
testRuntime "dk.brics.automaton:automaton:1.11-8"
optional("joda-time:joda-time:$jodaVersion")
// Required by Hive + Pig
// testRuntime "org.antlr:antlr-runtime:$antlrVersion"
// Required by Hive
testRuntime "org.apache.hive:hive-jdbc:$hiveVersion"
}
}
}
configurations.all {
resolutionStrategy {
forcedModules = ['commons-httpclient:commons-httpclient:3.0.1']
}
}
configure(allprojects) { project ->
compileJava {
sourceCompatibility = 1.6
targetCompatibility = 1.6
options.compilerArgs << "-Xlint:unchecked"
//options.compilerArgs << "-Xlint:deprecation"
options.compilerArgs << "-Xlint:options"
}
compileTestJava {
sourceCompatibility = 1.6
targetCompatibility = 1.6
}
test {
jacoco {
def jacocoEnabled = project.hasProperty("jacocoCoverage")
enabled = jacocoEnabled
if (jacocoEnabled)
println "Enabling Jacoco Coverage"
}
}
task sourcesJar(type: Jar, dependsOn:classes) {
classifier = 'sources'
from sourceSets.main.allJava
}
artifacts {
archives sourcesJar
}
}
// enable javadoc only for root project
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
artifacts {
archives javadocJar
}
ext.skipCascading = true
ext.skipMR = true
ext.skipHive = true
ext.skipPig = true
task enableMRTests {
description = "Enable Map/Reduce tests"
group = "Verification"
doLast() {
project.ext.skipMR = false
}
}
task enableCascadingTests {
description = "Enable Cascading tests"
group = "Verification"
doLast() {
project.ext.skipCascading = false
}
}
task enableHiveTests {
description = "Enable Hive tests"
group = "Verification"
doLast() {
project.ext.skipHive = false
}
}
task enablePigTests {
description = "Enable Pig tests"
group = "Verification"
doLast() {
project.ext.skipPig = false
}
}
task enableIntegrationTests() {
description = "Enable integration tests"
group = "Verification"
doLast() {
println "Enable all integration tests"
enableMRTests.execute()
enableCascadingTests.execute()
enablePigTests.execute()
//enableHiveTests.execute()
}
}
test {
systemProperties['input.path'] = 'build/classes/test/input'
systemProperties['output.path'] = 'build/classes/test/output'
includes = ["org/elasticsearch/hadoop/serialization/*.class",
"org/elasticsearch/hadoop/pig/*.class",
"org/elasticsearch/hadoop/rest/*.class",
"org/elasticsearch/hadoop/util/**/*.class",
"org/elasticsearch/hadoop/integration/**/*Suite.class"]
minHeapSize = "256m"
maxHeapSize = "768m"
testLogging {
events "started" //, "standardOut", "standardError"
minGranularity 2
maxGranularity 2
}
doFirst() {
ext.msg = ""
if (skipMR) {
ext.msg += "MapReduce "
excludes.add("**/integration/mr/**")
}
if (skipCascading) {
ext.msg += "Cascading "
excludes.add("**/integration/cascading/**")
}
if (skipHive) {
ext.msg += "Hive "
excludes.add("**/integration/hive/**")
}
if (skipPig) {
ext.msg += "Pig"
excludes.add("**/integration/pig/**")
}
if (!msg.isEmpty())
println "Skipping [$msg] Tests";
}
}
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 = true
showFromProtected()
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*'],
]
links = [
"http://download.oracle.com/javase/6/docs/api",
"http://commons.apache.org/proper/commons-logging/apidocs/",
"http://hadoop.apache.org/common/docs/stable1/api",
//"http://hbase.apache.org/apidocs/",
"http://pig.apache.org/docs/r0.12.0/api/",
"http://hive.apache.org/docs/r0.12.0/api/",
"http://docs.cascading.org/cascading/2.1/javadoc/"
]
excludes = [
"org/elasticsearch/hadoop/rest/**",
"org/elasticsearch/hadoop/serialization/**",
"org/elasticsearch/hadoop/util/**"
]
}
title = "${rootProject.description} ${version} API"
}
// jar used for testing Hadoop remotely (es-hadoop + tests)
task hadoopTestingJar(type: Jar) {
classifier = 'testing'
from sourceSets.test.output
from sourceSets.main.output
}
configure(allprojects) { project ->
licenseMain {
header rootProject.file('src/test/resources/HEADER')
strictCheck false
ignoreFailures true
}
licenseTest.enabled = false
// exclude properties file
tasks.withType(nl.javadude.gradle.plugins.license.License).each { licenseTask ->
licenseTask.exclude '**/*.properties'
licenseTask.exclude '**/package-info.java'
}
}
jar {
manifest.attributes["Created-By"] = "${System.getProperty("java.version")} (${System.getProperty("java.specification.vendor")})"
manifest.attributes['Implementation-Title'] = 'elasticsearch-hadoop'
manifest.attributes['Implementation-Version'] = project.version
manifest.attributes['Implementation-URL'] = "http://github.com/elasticsearch/elasticsearch-hadoop"
manifest.attributes['Implementation-Vendor'] = "Elasticsearch"
manifest.attributes['Implementation-Vendor-Id'] = "org.elasticsearch.hadoop"
def build = System.env['ESHDP.BUILD']
if (build != null)
manifest.attributes['Build'] = build
String rev = "unknown"
// parse the git files to find out the revision
File gitHead = file('.git/HEAD')
if (gitHead.exists()) {
gitHead = file('.git/' + gitHead.text.trim().replace('ref: ',''))
if (gitHead.exists()) { rev = gitHead.text }
}
from("$rootDir/docs/src/info") {
include "license.txt"
include "notice.txt"
into "META-INF"
expand(copyright: new Date().format('yyyy'), version: project.version)
}
manifest.attributes['Repository-Revision'] = rev
}
configure(jar) {
if (hadoopDistro == "hadoopYarn") {
classifier = 'yarn'
}
}
// this is in just as a convenience - the official docs are generated through an external process
asciidoctor {
//logDocuments = true
sourceDir = file("docs/src/reference/asciidoc")
sourceDocumentName = file("docs/src/reference/asciidoc/index.adoc")
options = [
doctype: 'book',
attributes: [
'source-highlighter': 'highlightjs',
icons: 'font',
badges: '',
toc2: '',
sectanchors: '',
//stylesheet: 'github.css',
copycss: '',
revnumber : project.version
//'linkcss!': ''
]
]
}
// reporting
configure(allprojects) { project ->
findbugsMain {
ignoreFailures = true
effort = "max"
reportLevel = "low"
reports {
xml.enabled = true
html.enabled = false
}
}
pmdMain {
ignoreFailures = true
reports {
xml.enabled = true
html.enabled = true
}
}
jacoco {
toolVersion = "0.6.3.201306030806"
}
jacocoTestReport {
reports {
xml.enabled true
csv.enabled true
html.enabled true
}
}
findbugsTest.enabled = false
pmdTest.enabled = false
}
// packaging
task distZip(type: Zip, dependsOn: [jar, sourcesJar, javadocJar]) {
group = "Distribution"
description = "Builds -${classifier} archive, containing all jars and docs, suitable for download page."
from(".") {
include "README.md"
include "LICENSE.txt"
include "NOTICE.txt"
into archiveName
//expand(yyyy: new Date().format("yyyy"), version: project.version)
}
from("build/asciidoc") {
into "${archiveName}/docs"
}
subprojects.each { subproject ->
into ("${archiveName}/build/libs") {
from subproject.jar
if (subproject.tasks.findByPath("sourcesJar")) {
from subproject.sourcesJar
}
if (subproject.tasks.findByPath("javadocJar")) {
from subproject.javadocJar
}
}
}
into ("${archiveName}/dist") {
from "build/libs"
exclude "*-testing.jar"
}
}
artifacts {
// include YARN is available
ext.yarn = file("$libsDir/$name-$version-yarn.jar")
if (yarn.exists()) {
archives yarn
}
//files(subprojects.configurations.archives.artifacts.file).each { File file ->
// archives file
//}
}
task wrapper(type: Wrapper) {
description = 'Generates gradlew[.bat] scripts'
gradleVersion = '1.8'
}
// skip creation of javadoc jars
assemble.dependsOn = ['jar', 'hadoopTestingJar']
defaultTasks 'build'