forked from spring-attic/spring-hadoop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
474 lines (384 loc) · 13.7 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
buildscript {
repositories {
maven { url 'http://repo.springsource.org/plugins-snapshot' }
}
dependencies {
classpath 'org.springframework.build.gradle:docbook-reference-plugin:0.1.6'
classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.3-SNAPSHOT'
}
}
description = 'Spring for Apache Hadoop'
group = 'org.springframework.data'
repositories {
maven { url "http://repo.springsource.org/libs-snapshot" }
}
apply plugin: "java"
apply plugin: 'eclipse'
apply plugin: 'idea'
apply from: "$rootDir/maven.gradle"
apply plugin: 'docbook-reference'
apply plugin: 'propdeps'
apply plugin: 'propdeps-idea'
apply plugin: 'propdeps-eclipse'
//
// Select the Hadoop distribution used for building the binaries
//
def List hadoop = []
def hadoopDistro = project.hasProperty("distro") ? project.getProperty("distro") : "hadoop10"
def hadoopVersion = hadoop10Version
// handle older Hive version
def hiveGroup = "org.apache.hive"
// default is Hadoop 1.0.x
switch (hadoopDistro) {
// Cloudera CDH3
case "cdh3":
hadoopVersion = cdh3Version
println "Using Cloudera CDH3 [$hadoopVersion]"
dependencies {
optional("org.apache.hadoop:hadoop-streaming:$hadoopVersion")
optional("org.apache.hadoop:hadoop-tools:$hadoopVersion")
}
hbaseVersion = cdh3HbaseVersion
// Hive in CDH3 is too old and does not allow Hive Server to be compiled
// Note that the POMs and repo are incomplete (hive-builtin is missing)
// hiveVersion = cdh3HiveVersion
// hiveGroup = "org.apache.hadoop.hive"
pigVersion = cdh3PigVersion
break;
// Cloudera CDH4
case "cdh4":
hadoopVersion = cdh4MR1Version
println "Using Cloudera CDH4 [$hadoopVersion]"
dependencies {
optional("org.apache.hadoop:hadoop-streaming:$cdh4MR1Version")
optional("org.apache.hadoop:hadoop-tools:$cdh4MR1Version")
optional("org.apache.hadoop:hadoop-common:$cdh4Version")
optional("org.apache.hadoop:hadoop-hdfs:$cdh4Version")
}
hbaseVersion = cdh4HbaseVersion
hiveVersion = cdh4HiveVersion
pigVersion = cdh4PigVersion
thriftVersion = cdh4ThriftVersion
break;
// Hadoop 1.1.x
case "hadoop11":
hadoopVersion = hadoop11Version
println "Using Apache Hadoop 1.1.x [$hadoopVersion]"
hadoop = ["org.apache.hadoop:hadoop-streaming:$hadoopVersion",
"org.apache.hadoop:hadoop-tools:$hadoopVersion"]
break;
default:
println "Using Apache Hadoop 1.0.x [$hadoopVersion]"
hadoopVersion = hadoop10Version
hadoop = ["org.apache.hadoop:hadoop-streaming:$hadoopVersion",
"org.apache.hadoop:hadoop-tools:$hadoopVersion"]
}
// Common dependencies
dependencies {
compile hadoop
// Logging
compile("org.slf4j:slf4j-api:$slf4jVersion")
optional("org.slf4j:jcl-over-slf4j:$slf4jVersion")
testRuntime("log4j:log4j:$log4jVersion")
testRuntime("org.slf4j:slf4j-log4j12:$slf4jVersion")
// Spring Framework
compile("org.springframework:spring-core:$springVersion") {
exclude module: "commons-logging"
}
compile "org.springframework:spring-context-support:$springVersion"
optional("org.springframework:spring-tx:$springVersion")
optional("org.springframework:spring-aop:$springVersion")
optional("org.springframework:spring-jdbc:$springVersion")
optional("org.springframework.batch:spring-batch-core:$springBatchVersion")
optional("org.springframework.integration:spring-integration-stream:$springIntVersion")
optional("org.springframework.integration:spring-integration-file:$springIntVersion")
// cascading
optional("cascading:cascading-hadoop:$cascadingVersion") { dep ->
exclude module: "hadoop-core"
}
// Missing dependency in Hadoop 1.0.3
testRuntime "commons-io:commons-io:$commonsioVersion"
testRuntime "org.codehaus.jackson:jackson-mapper-asl:$jacksonVersion"
testRuntime "cglib:cglib:$cglibVersion"
// Hive
optional("$hiveGroup:hive-service:$hiveVersion")
// needed by JDBC test
testRuntime "$hiveGroup:hive-jdbc:$hiveVersion"
// needed by the Hive Server tests
// testRuntime "$hiveGroup:hive-builtins:$hiveVersion"
// testRuntime("$hiveGroup:hive-metastore:$hiveVersion")
//testRuntime "$hiveGroup:hive-common:$hiveVersion"
//testRuntime "$hiveGroup:hive-shims:$hiveVersion"
//testRuntime "$hiveGroup:hive-serde:$hiveVersion"
//testRuntime "org.apache.thrift:libthrift:$thriftVersion"
//testRuntime "org.apache.thrift:libfb303:$thriftVersion"
// Pig
optional("org.apache.pig:pig:$pigVersion")
// HBase
optional("org.apache.hbase:hbase:$hbaseVersion") { dep ->
exclude module: "thrift"
}
// Libs dependencies (specified to cope with incompatibilities between them)
// testRuntime "org.antlr:antlr:$antlrVersion"
// testRuntime "org.antlr:antlr-runtime:$antlrVersion"
// Testing
testCompile "junit:junit:$junitVersion"
testCompile "org.mockito:mockito-core:$mockitoVersion"
testCompile "org.springframework:spring-test:$springVersion"
testCompile("javax.annotation:jsr250-api:1.0")
testCompile "org.apache.hadoop:hadoop-examples:$hadoopVersion"
testRuntime "org.springframework.integration:spring-integration-event:$springIntVersion"
testRuntime "org.codehaus.groovy:groovy:$groovyVersion"
testRuntime "org.jruby:jruby:$jrubyVersion"
testRuntime "org.python:jython-standalone:$jythonVersion"
// specify a version of antlr that works with both hive and pig (works only during compilation)
testRuntime "org.antlr:antlr-runtime:$antlrVersion"
testCompile "cascading:cascading-local:$cascadingVersion"
}
// exclude poms from the classpath (pulled in by Cloudera)
eclipse.classpath.file {
whenMerged { classpath ->
classpath.entries.removeAll { entry -> entry.toString().contains(".pom") }
}
}
sourceCompatibility = 1.6
targetCompatibility = 1.6
ext.skipPig = true
ext.skipHive = true
ext.skipHBase = true
ext.skipWebHdfs = true
task enablePigTests {
description = "Enable Pig tests"
group = "Verification"
doLast() {
project.ext.skipPig = false
}
}
task enableHiveTests {
description = "Enable Hive tests"
group = "Verification"
doLast() {
project.ext.skipHive = false
}
}
task enableHBaseTests {
description = "Enable HBase tests"
group = "Verification"
doLast() {
project.ext.skipHBase = false
}
}
task enableWebHdfsTests {
description = "Enable WebHdfs tests"
group = "Verification"
doLast() {
project.ext.skipWebHdfs = false
}
}
task enableAllTests() {
description = "Enable all (incl. Pig, Hive, HBase, WebHdfs) tests"
group = "Verification"
doFirst() {
println "Enable all tests"
project.ext.skipPig = false
project.ext.skipHBase = false
project.ext.skipHive = false
project.ext.skipWebHdfs = false
}
}
test {
//forkEvery = 1
systemProperties['input.path'] = 'build/classes/test/input'
systemProperties['output.path'] = 'build/classes/test/output'
includes = ["**/*.class"]
testLogging {
events "started"
minGranularity 2
maxGranularity 2
}
doFirst() {
ext.msg = ""
if (skipPig) {
ext.msg += "Pig "
excludes.add("**/pig/**")
}
if (skipHBase) {
ext.msg += "HBase "
excludes.add("**/hbase/**")
}
if (skipHive) {
ext.msg += "Hive "
excludes.add("**/hive/**")
}
if (skipWebHdfs) {
ext.msg += "WebHdfs"
excludes.add("**/WebHdfs*")
}
if (!msg.isEmpty())
println "Skipping [$msg] Tests";
// check prefix for hd.fs
// first copy the properties since we can't change them
ext.projProps = project.properties
if (projProps.containsKey("hd.fs")) {
String hdfs = projProps["hd.fs"].toString()
if (!hdfs.contains("://")) {
projProps.put("hd.fs", "hdfs://" + hdfs)
}
}
// due to GRADLE-2475, set the system properties manually
projProps.each { k,v ->
if (k.toString().startsWith("hd.")) {
systemProperties[k] = projProps[k]
}
}
}
}
javadoc {
ext.srcDir = file("${projectDir}/docs/src/api")
configure(options) {
stylesheetFile = file("${srcDir}/spring-javadoc.css")
overview = "${srcDir}/overview.html"
docFilesSubDirs = true
outputLevel = org.gradle.external.javadoc.JavadocOutputLevel.QUIET
breakIterator = true
author = true
showFromProtected()
// groups = [
// 'Spring Data Hadoop' : ['org.springframework.data.hadoop*'],
// ]
links = [
"http://static.springframework.org/spring/docs/3.0.x/javadoc-api",
"http://download.oracle.com/javase/6/docs/api",
"http://logging.apache.org/log4j/1.2/apidocs/",
"http://hadoop.apache.org/common/docs/current/api/",
"http://hbase.apache.org/apidocs/",
"http://pig.apache.org/docs/r0.9.2/api/",
"http://hive.apache.org/docs/r0.8.1/api/",
"http://static.springsource.org/spring-batch/apidocs/",
"http://static.springsource.org/spring-integration/api/",
"https://builds.apache.org/job/Thrift/javadoc/",
"http://jakarta.apache.org/commons/logging/apidocs/",
"http://docs.cascading.org/cascading/2.0/javadoc/"
]
exclude "org/springframework/data/hadoop/config/**"
}
title = "${rootProject.description} ${version} API"
}
jar {
manifest.attributes["Created-By"] = "${System.getProperty("java.version")} (${System.getProperty("java.specification.vendor")})"
manifest.attributes['Implementation-Title'] = 'spring-data-hadoop'
manifest.attributes['Implementation-Version'] = project.version
manifest.attributes['Implementation-URL'] = "http://www.springsource.org/spring-data/hadoop"
manifest.attributes['Implementation-Vendor'] = "SpringSource"
manifest.attributes['Implementation-Vendor-Id'] = "org.springframework"
def build = System.env['SHDP.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
}
task sourcesJar(type: Jar, dependsOn:classes) {
classifier = 'sources'
from sourceSets.main.allJava
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
reference {
sourceDir = file('docs/src/reference/docbook')
//pdfFileName = 'spring-data-hadoop-reference.pdf'
}
task docsZip(type: Zip) {
group = 'Distribution'
classifier = 'docs'
description = "Builds -${classifier} archive containing api and reference for deployment"
from('docs/src/info') {
include 'changelog.txt'
}
from (javadoc) {
into 'api'
}
from (reference) {
into 'reference'
}
}
task schemaZip(type: Zip) {
group = 'Distribution'
classifier = 'schema'
description = "Builds -${classifier} archive containing all XSDs for deployment"
def Properties schemas = new Properties();
sourceSets.main.resources.find {
it.path.endsWith('META-INF' + File.separator + 'spring.schemas')
}?.withInputStream { schemas.load(it) }
for (def key : schemas.keySet()) {
def shortName = key.replaceAll(/http.*schema.(.*).spring-.*/, '$1')
def alias = key.replaceAll(/http.*schema.(.*).(spring-.*)/, '$2')
assert shortName != key
File xsdFile = sourceSets.main.resources.find {
it.path.replace('\\', '/').endsWith(schemas.get(key))
}
assert xsdFile != null
into (shortName) {
from xsdFile.path
rename { String fileName -> alias }
}
}
}
task distZip(type: Zip, dependsOn: [jar, docsZip, schemaZip, sourcesJar, javadocJar]) {
group = 'Distribution'
classifier = 'dist'
description = "Builds -${classifier} archive, containing all jars and docs, " +
"suitable for community download page."
ext.zipRootDir = "${project.name}-${project.version}"
into (zipRootDir) {
from('docs/src/info') {
include 'readme.txt'
include 'license.txt'
include 'notice.txt'
expand(copyright: new Date().format('yyyy'), version: project.version)
}
from('samples/') {
into 'samples'
exclude '**/build/**'
exclude '**/bin/**'
exclude '**/.settings/**'
exclude '**/.gradle/**'
exclude '**/.*'
}
from(zipTree(docsZip.archivePath)) {
into "docs"
}
from(zipTree(schemaZip.archivePath)) {
into "schema"
}
into ("dist") {
from rootProject.collect { project -> project.libsDir }
}
}
}
artifacts {
archives sourcesJar
archives javadocJar
archives docsZip
archives schemaZip
archives distZip
}
task wrapper(type: Wrapper) {
description = 'Generates gradlew[.bat] scripts'
gradleVersion = '1.3'
}
assemble.dependsOn = ['jar', 'sourcesJar']
defaultTasks 'build'