forked from mongodb/mongo-hadoop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
447 lines (372 loc) · 13.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
import org.apache.tools.ant.filters.ReplaceTokens
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'download-task'
apply plugin: 'versions'
apply from: 'gradle/functions.gradle'
ext.configDir = new File(rootDir, 'config')
ext.hadoopBinaries = "${System.getProperty('user.home')}/hadoop-binaries"
ext.branchVersion = project.getProperties().get('clusterVersion', '2.4').toLowerCase()
ext.hiveVersionMap = [
'1.0' : '0.10.0',
'1.1' : '0.10.0',
'cdh4': '0.10.0-cdh4.6.0',
'cdh5': '0.12.0-cdh5.0.0'
].withDefault {
'0.12.0'
}
ext.hadoopClusters = [
'0.23': '0.23.10',
'1.0' : '1.0.4',
'1.1' : '1.1.2',
'1.2' : '1.2.1',
'2.2' : '2.2.0',
'2.3' : '2.3.0',
'2.4' : '2.4.0',
'cdh4': '2.0.0-cdh4.6.0',
'cdh5': '2.3.0-cdh5.0.0',
].withDefault {
throw new GradleException("Unknown hadoop version: ${it}")
}
ext.pigVersionMap = [
'cdh4': '0.11.0-cdh4.6.0',
'cdh5': '0.12.0-cdh5.0.0'
].withDefault {
'0.13.0'
}
ext.javaDriverVersion = '2.12.3'
ext.clusterVersion = hadoopClusters[branchVersion]
ext.hiveVersion = hiveVersionMap[branchVersion]
ext.pigVersion = pigVersionMap[branchVersion]
ext.hadoopVersion = '2.4.1'
ext.hadoopHome = "${hadoopBinaries}/hadoop-${clusterVersion}"
ext.hiveHome = "${hadoopBinaries}/hive-${hiveVersion}"
ext.pigHome = "${hadoopBinaries}/pig-${pigVersion}"
ext.dataHome = "${hadoopBinaries}/examples/data"
ext.mongoimport = new File('/mnt/jenkins/mongodb/26/26-release/bin/mongoimport').exists() ?
'/mnt/jenkins/mongodb/26/26-release/bin/mongoimport' :
'/usr/local/bin/mongoimport';
ext.mongorestore = new File('/mnt/jenkins/mongodb/26/26-release/bin/mongorestore').exists() ?
'/mnt/jenkins/mongodb/26/26-release/bin/mongorestore' :
'/usr/local/bin/mongorestore';
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
jcenter()
maven { url "https://github.com/ben-manes/gradle-versions-plugin/raw/mvnrepo" }
}
dependencies {
classpath 'me.trnl:clirr-gradle-plugin:0.4'
classpath 'com.antwerkz.github:github-release-gradle-plugin:1.1.0'
classpath 'de.undercouch:gradle-download-task:1.0'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.5-beta-2'
}
}
task wrapper(type: Wrapper) {
gradleVersion = '1.11'
}
configure(subprojects) {
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'checkstyle'
apply plugin: 'findbugs'
repositories {
mavenCentral()
mavenLocal()
maven { url "https://repository.cloudera.com/artifactory/cloudera-repos/" }
}
group = 'org.mongodb'
version = '1.4.0-SNAPSHOT'
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'
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', hadoopClusters[branchVersion]
systemProperty 'hadoop.version', branchVersion
systemProperty 'hive.version', hiveVersion
systemProperty 'pig.version', pigVersion
systemProperties << System.getProperties()
beforeTest { descr ->
logger.info("[Test ${descr.className} > ${descr.name}]")
}
finalizedBy ':shutdownCluster'
}
test.dependsOn ':configureCluster'
compileJava.dependsOn ':generateScripts'
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/6/docs/api/'
options.links 'http://hadoop.apache.org/docs/r2.4.0/api'
options.links 'http://api.mongodb.org/java/2.12.3/'
}
gradle.taskGraph.whenReady { taskGraph ->
testJar {
baseName = "${archivesBaseName}-test"
mustRunAfter jar
}
}
configurations {
}
artifacts {
tests testJar
}
test {
dependsOn ':configureCluster', ':downloadEnronEmails'
finalizedBy ':shutdownCluster'
}
}
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 {
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}"
}
}
project(":hive") {
archivesBaseName = "mongo-hadoop-hive"
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 project(path: ':core', configuration: 'tests')
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")
compile "org.apache.pig:pig:${pigVersion}"
testCompile project(path: ':core', configuration: 'tests')
testCompile "org.antlr:antlr:3.5.2"
}
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(),
]
}
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}"
}
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 project(path: ':core', configuration: 'tests')
testCompile project(':streaming')
testCompile 'org.slf4j:slf4j-jdk14:1.7.7'
}
}
project(":examples/enron") {
uploadArchives.onlyIf { false }
dependencies {
compile project(":core")
}
}
project(":examples/sensors") {
uploadArchives.onlyIf { false }
dependencies {
compile project(":core")
}
}
project(":integration-tests") {
uploadArchives.onlyIf { false }
dependencies {
testCompile project(":core")
testCompile "${group}:mongo-hadoop-streaming:${version}"
testCompile 'org.slf4j:slf4j-jdk14:1.7.7'
}
}
task cleanLogs(type: Delete) {
delete fileTree(dir: "logs", exclude: ".keep")
}
task cleanHadoop(type: Delete, dependsOn: cleanLogs) {
delete hadoopHome, hiveHome, pigHome
}
task historicalYield(dependsOn: configureCluster) << {
exec() {
commandLine mongoimport, "-d", "mongo_hadoop", "-c", "yield_historical.in", "--drop",
"examples/treasury_yield/src/main/resources/yield_historical_in.json"
}
hadoop("examples/treasury_yield/build/libs/treasury_yield-${project(':core').version}.jar",
"com.mongodb.hadoop.examples.treasury.TreasuryYieldXMLConfig", [
"mongo.input.uri=mongodb://localhost:27017/mongo_hadoop.yield_historical.in",
"mongo.output.uri=mongodb://localhost:27017/mongo_hadoop.yield_historical.out"
])
}
task sensorData(dependsOn: 'configureCluster') << {
hadoop("examples/sensors/build/libs/sensors-${project(':core').version}.jar",
"com.mongodb.hadoop.examples.sensors.Devices", [])
hadoop("examples/sensors/build/libs/sensors-${project(':core').version}.jar",
"com.mongodb.hadoop.examples.sensors.Logs", ["io.sort.mb=100"])
}
task downloadEnronEmails() {
if (!new File("${dataHome}/dump").exists()) {
println "Downloading Enron email test data to ${dataHome}"
new File(dataHome).mkdirs()
def attempts = 0
while (!new File(dataHome, "enron_mongo.tar.bz2").exists() && attempts < 10) {
try {
download {
src 'https://s3.amazonaws.com/mongodb-enron-email/enron_mongo.tar.bz2'
dest dataHome
onlyIfNewer true
}
} catch (Exception e) {
attempts++
if (attempts == 10) {
throw e;
}
}
}
println "extracting email data"
copy {
from(tarTree("${dataHome}/enron_mongo.tar.bz2"))
into dataHome
}
}
}
task enronEmails(dependsOn: [downloadEnronEmails, configureCluster]) << {
exec() {
commandLine mongorestore, "-v", "-d", "mongo_hadoop", "--drop", "${dataHome}/dump/enron_mail"
}
hadoop("examples/enron/build/libs/enron-${project(':core').version}.jar",
"com.mongodb.hadoop.examples.enron.EnronMail", ["mongo.input.split_size=64"])
}
def hadoop(jar, className, args) {
def line = ["${hadoopHome}/bin/hadoop",
"jar", jar, className,
//Split settings
"-Dmongo.input.split_size=8",
"-Dmongo.job.verbose=true",
]
args.each {
line << "-D${it}"
}
println "Executing hadoop job:\n ${line.join(' \\\n\t')}"
def hadoopEnv = [:]
if (clusterVersion.contains("cdh")) {
hadoopEnv.MAPRED_DIR = 'share/hadoop/mapreduce2'
}
hadoopEnv.HADOOP_PREFIX=''
exec() {
environment << hadoopEnv
commandLine line
}
shutdownCluster.execute()
}
apply from: 'gradle/maven-deployment.gradle'