-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.gradle
112 lines (102 loc) · 3.53 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
import java.nio.file.StandardCopyOption
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.Files
import static java.nio.file.StandardCopyOption.COPY_ATTRIBUTES;
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING
import groovy.xml.MarkupBuilder
import groovy.xml.XmlUtil
buildscript {
repositories {
jcenter()
}
}
plugins {
id 'de.undercouch.download' version '3.2.0'
}
ext {
nutchVersion = "2.3.1"
hbaseVersion = "0.98.8"
nutchUrl = "http://apache.mirrors.pair.com/nutch/${nutchVersion}/apache-nutch-${nutchVersion}-src.tar.gz"
hbaseUrl = "https://archive.apache.org/dist/hbase/hbase-${hbaseVersion}/hbase-${hbaseVersion}-hadoop2-bin.tar.gz"
hbaseTarFile = "hbase-${hbaseVersion}.tar.gz"
nutchTarFile = "apache-nutch-${nutchVersion}.tar.gz"
nutchDir = "$buildDir/apache-nutch-$nutchVersion"
hbaseDir = "$buildDir/hbase-$hbaseVersion-hadoop2"
externalProductName = "Apache Nutch Indexer plugin for Watson Discovery"
}
import de.undercouch.gradle.tasks.download.Download
task configureHbase(){
def hbaseDataDir = "hbase-data"
def zkDataDir = "zk-data"
def hbaseDir = new File("$projectDir", hbaseDataDir)
def zkDir = new File("$projectDir", zkDataDir)
if(!hbaseDir.exists()){
hbaseDir.mkdirs()
}
if(!zkDir.exists()){
zkDir.mkdirs()
}
def hbaseSiteXml = "$projectDir/conf/hbase/hbase-site.xml"
def configuration = new XmlParser().parse(hbaseSiteXml)
configuration.property[0].value[0].value = "file://${projectDir}/$hbaseDataDir"
configuration.property[1].value[0].value = "$projectDir/$zkDataDir"
def writer = new FileWriter(hbaseSiteXml)
XmlUtil.serialize(configuration, writer)
println "Hbase root dir set to $projectDir/$hbaseDataDir"
println "Zookeeper root dir set to $projectDir/$zkDataDir"
}
task downloadNutch(type: Download) {
src nutchUrl
dest new File("$buildDir/$nutchTarFile")
}
task downloadHbase(type: Download) {
src hbaseUrl
dest new File("$buildDir/$hbaseTarFile")
}
task extractNutch(dependsOn: downloadNutch, type: Copy) {
from tarTree("$buildDir/$nutchTarFile")
into buildDir
}
task extractHbase(dependsOn: downloadHbase, type: Copy) {
from tarTree("$buildDir/$hbaseTarFile")
into buildDir
}
task setuphbase(dependsOn: extractHbase) {
doLast {
copyFile("$projectDir/conf/hbase/hbase-site.xml", "$hbaseDir/conf/hbase-site.xml")
}
}
def copyFile(source, destination) {
Path src = Paths.get(source)
Path dest = Paths.get(destination)
Files.copy(src, dest, StandardCopyOption.REPLACE_EXISTING)
}
task setupNutch(dependsOn: extractNutch){
doLast{
copy {
from "$projectDir/plugin/indexer-discovery"
into "$nutchDir/src/plugin/indexer-discovery"
}
copyFile("$projectDir/conf/hbase/ivy.xml", "$nutchDir/ivy/ivy.xml")
copyFile("$projectDir/conf/hbase/gora.properties", "$nutchDir/conf/gora.properties")
copyFile("$projectDir/conf/nutch-discovery/plugin/build.xml", "$nutchDir/src/plugin/build.xml")
copy {
from "$projectDir/windows_libraries/"
into "$nutchDir/lib/native/"
}
}
}
def nutchFile = new File("$nutchDir/build.xml")
if(nutchFile.exists()){
ant.importBuild("$nutchDir/build.xml")
}
//this runtime task is nutch ant runtime target created after extracting Nutch
if(project.tasks.findByName('runtime')){
task buildPlugin(dependsOn: runtime) {
doLast{
copyFile("$projectDir/conf/nutch-discovery/nutch-site.xml", "$nutchDir/runtime/local/conf/nutch-site.xml")
copyFile("$projectDir/conf/hbase/hbase-site.xml", "$nutchDir/runtime/local/conf/hbase-site.xml")
}
}
}