This repository has been archived by the owner on Jan 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 602
/
build.gradle
508 lines (423 loc) · 14.9 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
import org.apache.tools.ant.filters.ReplaceTokens
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'download-task'
apply plugin: 'com.github.ben-manes.versions'
ext.configDir = new File(rootDir, 'config')
ext.hadoopBinaries = "${rootDir}/hadoop-binaries".toString()
ext.javaDriverVersion = '3.2.1'
ext.hiveVersion = System.getenv("HIVE_VERSION") ?: '1.2.1'
ext.pigVersion = System.getenv("PIG_VERSION") ?: '0.15.0'
ext.hadoopVersion = System.getenv("HADOOP_VERSION") ?: '2.7.2'
ext.sparkVersion = System.getenv("SPARK_VERSION") ?: '1.6.0'
ext.scalaVersion = System.getenv("SCALA_VERSION") ?: '2.11'
ext.isHadoopV1 = "$hadoopVersion".startsWith("1.")
ext.hadoopHome = System.getenv("HADOOP_HOME") ?: "${hadoopBinaries}/hadoop-${hadoopVersion}".toString()
ext.hiveHome = System.getenv("HIVE_HOME") ?: "${hadoopBinaries}/apache-hive-${hiveVersion}-bin".toString()
ext.pigHome = System.getenv("PIG_HOME") ?: "${hadoopBinaries}/pig-${pigVersion}".toString()
ext.dataHome = "${hadoopBinaries}/examples/data".toString()
ext.docsHome = "${rootDir}/docs"
ext.mongoimport = '/usr/local/bin/mongoimport';
ext.mongorestore = '/usr/local/bin/mongorestore';
ext.mongoURI = System.getenv("MONGO_INPUT_URI")
ext.mongoAuthURI = System.getenv("MONGO_AUTH_URI")
ext.mongoUsername = System.getenv("MONGO_USER")
ext.mongoPassword = System.getenv("MONGO_PASSWORD")
buildscript {
repositories {
mavenLocal()
mavenCentral()
jcenter()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
dependencies {
classpath 'org.codehaus.groovy:groovy-backports-compat23:2.3.5'
classpath 'org.zeroturnaround:zt-exec:1.6'
classpath 'com.bmuschko:gradle-nexus-plugin:2.1.1'
classpath 'me.trnl:clirr-gradle-plugin:0.4'
classpath 'de.undercouch:gradle-download-task:1.0'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.6'
}
}
//apply from: 'gradle/maven-deployment.gradle'
apply from: 'gradle/functions.gradle'
apply from: 'gradle/hadoop.gradle'
task wrapper(type: Wrapper) {
gradleVersion = '2.2.1'
}
if(project.hasProperty("clusterVersion")) {
println "The cluster version property has been obsoleted. See https://jira.mongodb.org/browse/HADOOP-160 for details."
}
allprojects {
version = '2.0.2'
group = 'org.mongodb.mongo-hadoop'
}
configure(subprojects) {
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'checkstyle'
apply plugin: 'findbugs'
apply plugin: 'com.bmuschko.nexus'
repositories {
mavenCentral()
mavenLocal()
maven { url "https://repository.cloudera.com/artifactory/cloudera-repos/" }
}
sourceCompatibility = JavaVersion.VERSION_1_6
targetCompatibility = JavaVersion.VERSION_1_6
/*
configurations {
tests
tests.extendsFrom(testCompile)
provided
provided.extendsFrom(compile)
}
sourceSets.main.compileClasspath += configurations.provided
sourceSets.test.compileClasspath += configurations.provided
sourceSets.test.runtimeClasspath += configurations.provided
*/
dependencies {
compile "org.mongodb:mongo-java-driver:${javaDriverVersion}"
testCompile 'junit:junit:4.11'
testCompile 'org.hamcrest:hamcrest-all:1.3'
testCompile 'org.zeroturnaround:zt-exec:1.6'
testCompile 'com.jayway.awaitility:awaitility:1.6.0'
testCompile 'commons-daemon:commons-daemon:1.0.15'
if (isHadoopV1) {
testCompile "org.apache.hadoop:hadoop-test:${hadoopVersion}"
} else {
testCompile "org.apache.hadoop:hadoop-hdfs:${hadoopVersion}"
testCompile "org.apache.hadoop:hadoop-hdfs:${hadoopVersion}:tests"
testCompile "org.apache.hadoop:hadoop-common:${hadoopVersion}:tests"
testCompile "org.apache.hadoop:hadoop-yarn-server-tests:${hadoopVersion}:tests"
testCompile "org.apache.hadoop:hadoop-mapreduce-client-jobclient:${hadoopVersion}:tests"
}
}
/* Compiling */
tasks.withType(AbstractCompile) {
options.encoding = 'ISO-8859-1'
options.fork = true
options.debug = true
options.compilerArgs = [/*'-Xlint:deprecation',*/ '-Xlint:-options']
}
project.ext.buildingWith = { n ->
project.hasProperty(n) && project.property(n).toBoolean()
}
// /* Testing */
// task testJar(type: Jar, dependsOn: testClasses) {
// from sourceSets.test.output
// }
tasks.withType(Test) {
maxParallelForks = 1
systemProperty 'project.version', project.version
systemProperty 'cluster.version', hadoopVersion
systemProperty 'hadoop.version', hadoopVersion
systemProperty 'hive.version', hiveVersion
systemProperty 'pig.version', pigVersion
systemProperties << System.getProperties()
beforeTest { descr ->
logger.info("[Test ${descr.className} > ${descr.name}]")
}
finalizedBy ':shutdownCluster'
}
test.dependsOn ':startCluster'
clean.dependsOn ':cleanHadoop'
/* Code quality */
checkstyle {
configFile = new File("$configDir/checkstyle.xml")
}
checkstyleTest {
classpath += configurations.compile
classpath += configurations.testCompile
}
checkstyleMain {
classpath += configurations.compile
}
task quickCheck(dependsOn: [checkstyleMain, checkstyleTest] ) << {}
findbugs {
excludeFilter = new File("$configDir/findbugs-exclude.xml")
sourceSets = [sourceSets.main]
}
tasks.withType(FindBugs) {
reports {
xml.enabled = project.buildingWith('xmlReports.enabled')
html.enabled = !project.buildingWith('xmlReports.enabled')
}
}
javadoc {
options.version = true
options.links 'http://docs.oracle.com/javase/8/docs/api/'
options.links 'http://hadoop.apache.org/docs/r2.7.2/api'
options.links 'http://api.mongodb.org/java/3.2/'
if (JavaVersion.current().isJava8Compatible()) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
gradle.taskGraph.whenReady { taskGraph ->
copyFiles.dependsOn 'jar', 'testsJar'
}
// artifacts {
// tests testJar
// }
test {
dependsOn 'jar', 'testsJar', ':startCluster', ':downloadEnronEmails'
}
modifyPom {
project {
name = 'MongoDB Connector for Hadoop'
description = 'The MongoDB Connector for Hadoop is a plugin for Hadoop that provides the ability to use MongoDB as an input source and/or an output destination.'
url 'https://github.com/mongodb/mongo-hadoop.git'
scm {
url 'https://github.com/mongodb/mongo-hadoop.git'
connection 'scm:git:git://github.com/mongodb/mongo-hadoop.git'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
name 'Various'
organization = 'MongoDB'
}
}
}
whenConfigured { resultPom ->
resultPom.dependencies.removeAll { dep -> dep.scope != 'compile' }
resultPom.dependencies*.scope = null
}
}
extraArchive {
sources = true
tests = true
javadoc = true
}
nexus {
sign = true
}
}
task apidocs {
// Depends on "javadoc" task for all projects.
dependsOn {
subprojects*.getTasksByName("javadoc", true)
}
// Exclude examples.
def noExamples = subprojects.findAll {
proj -> !proj.getName().contains("examples/")
}
// Create docs directory if it doesn't already exist.
def docsHomeDir = new File(docsHome)
if (!docsHomeDir.exists()) {
docsHomeDir.mkdir()
}
noExamples.each {
proj -> copy {
from new File(proj.docsDir, "javadoc")
into new File(docsHomeDir, proj.getName())
}
}
// Generate an index.html.
new File("docs/index.html").withWriter { writer ->
writer.write("<html><head><title>MongoDB Hadoop Connector " +
"Modules</title></head><body><h3>MongoDB Hadoop Connector " +
"Modules</h3><ul>")
noExamples.each { proj ->
writer.append("<li><a href='" + proj.getName() + "/index.html' " +
"rel='nofollow'>" + proj.getName() + "</li>")
}
writer.append("</ul></body></html>")
}
}
idea {
module {
excludeDirs += file('hadoop-binaries')
}
}
configure(subprojects.findAll { it.name.contains('examples/') }) {
def exampleName = project.name.split('/')[1]
jar {
baseName = exampleName
}
group += ".mongo-hadoop-examples"
}
project(":core") {
archivesBaseName = "mongo-hadoop-core"
dependencies {
if (isHadoopV1) {
compile "org.apache.hadoop:hadoop-core:${hadoopVersion}"
compile "org.apache.hadoop:hadoop-client:${hadoopVersion}"
compile "org.apache.hadoop:hadoop-tools:${hadoopVersion}"
} else {
compile "org.apache.hadoop:hadoop-common:${hadoopVersion}"
compile "org.apache.hadoop:hadoop-mapreduce-client-core:${hadoopVersion}"
compile "org.apache.hadoop:hadoop-mapreduce-client-common:${hadoopVersion}"
compile "org.apache.hadoop:hadoop-mapreduce-client-shuffle:${hadoopVersion}"
compile "org.apache.hadoop:hadoop-mapreduce-client-app:${hadoopVersion}"
compile "org.apache.hadoop:hadoop-mapreduce-client-jobclient:${hadoopVersion}"
}
testCompile "org.mockito:mockito-core:1.10.19"
}
}
project(':spark') {
apply plugin: 'scala'
archivesBaseName = "mongo-hadoop-spark"
dependencies {
compile "org.apache.spark:spark-core_${scalaVersion}:${sparkVersion}"
compile project(':core')
}
jar {
from project(':core').sourceSets.main.output
from sourceSets.main.output
configurations.compile.filter {
it.name.startsWith('mongo-java-driver')
}.each {
from zipTree(it)
}
}
extraArchive {
tests = false
}
test {
dependsOn.remove('testsJar')
}
}
project(':hive') {
archivesBaseName = 'mongo-hadoop-hive'
configurations {
// Dependencies of hive-exec, but not available on Maven.
all*.exclude group: 'org.pentaho', module: 'pentaho-aggdesigner-algorithm'
all*.exclude group: 'eigenbase', module: 'eigenbase-properties'
}
test {
onlyIf { JavaVersion.current().isJava7Compatible() }
}
dependencies {
compile project(':core')
compile "org.apache.hive:hive-exec:${hiveVersion}"
compile "org.apache.hive:hive-serde:${hiveVersion}"
testCompile "org.apache.hive:hive-cli:${hiveVersion}"
testCompile "org.apache.hive:hive-service:${hiveVersion}"
testCompile "org.apache.hive:hive-jdbc:${hiveVersion}"
testCompile files(project(':core').sourceSets.test.output)
testCompile("com.nitayjoffe.thirdparty.com.jointhegrid:hive_test:4.0.0") {
exclude group: 'org.apache.derby', module: 'derby'
exclude group: 'org.apache.hadoop', module: 'hadoop-core'
}
}
}
project(":pig") {
archivesBaseName = "mongo-hadoop-pig"
dependencies {
compile project(":core")
if (isHadoopV1) {
compile "org.apache.pig:pig:${pigVersion}"
} else {
compile "org.apache.pig:pig:${pigVersion}:h2"
}
compile 'joda-time:joda-time:2.7'
testCompile files(project(':core').sourceSets.main.output)
testCompile files(project(':core').sourceSets.test.output)
testCompile "org.apache.pig:pigunit:${pigVersion}"
testCompile "org.antlr:antlr:3.5.2"
testCompile "org.mockito:mockito-core:1.10.19"
}
processTestResources {
outputs.upToDateWhen{ false }
filter ReplaceTokens, tokens: [
JAVA_DRIVER_JAR : project(':core').configurations.compile.find { it.name.startsWith("mongo-java-driver") }.toString(),
PROJECT_VERSION : project(':core').version,
PROJECT_HOME : project.rootDir.getAbsolutePath(),
PIG_RESOURCES : project(':pig').sourceSets.test.output.resourcesDir.toString()
]
}
jar {
from project(':core').sourceSets.main.output
from sourceSets.main.output
configurations.compile.filter {
it.name.startsWith('mongo-java-driver')
}.each {
from zipTree(it)
}
}
}
project(":streaming") {
archivesBaseName = "mongo-hadoop-streaming"
dependencies {
compile project(":core")
compile "org.apache.hadoop:hadoop-streaming:${hadoopVersion}"
testCompile "org.mockito:mockito-core:1.10.19"
}
jar {
from project(':core').sourceSets.main.output
from sourceSets.main.output
configurations.compile.filter {
it.name.startsWith('mongo-java-driver')
}.each {
from zipTree(it)
}
}
}
project(":flume") {
dependencies {
compile project(":core")
compile("com.cloudera:flume-core:0.9.4-cdh3u3") {
exclude group: 'org.apache.hadoop', module: 'hadoop-core'
exclude group: 'com.cloudera.cdh', module: 'hadoop-ant'
}
}
}
project(":examples/treasury_yield") {
uploadArchives.onlyIf { false }
dependencies {
compile project(':core')
testCompile files(project(':core').sourceSets.test.output)
testCompile project(':streaming')
testCompile 'org.slf4j:slf4j-jdk14:1.7.7'
}
}
project(":examples/enron") {
uploadArchives.onlyIf { false }
dependencies {
compile project(':core')
}
}
project(":examples/enron/spark") {
archivesBaseName = "mongo-spark-enron"
dependencies {
compile project(":core")
compile project(":spark")
compile "org.apache.spark:spark-sql_${scalaVersion}:${sparkVersion}"
}
jar {
from sourceSets.main.output
from project(':spark').sourceSets.main.output
from project(':core').sourceSets.main.output
configurations.compile.filter {
it.name.startsWith('mongo-java-driver')
}.each {
from zipTree(it)
}
}
}
project(":examples/sensors") {
uploadArchives.onlyIf { false }
dependencies {
compile project(":core")
}
}
project(":examples/shakespeare") {
uploadArchives.onlyIf { false }
dependencies {
compile project(":core")
}
}
task cleanLogs(type: Delete) {
delete fileTree(dir: "logs", exclude: ".keep")
}
task cleanHadoop(type: Delete, dependsOn: cleanLogs) {
delete hadoopHome, hiveHome, pigHome
}