-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbuild.gradle
69 lines (56 loc) · 1.74 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
// set the dependencies for running the groovy script
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.codehaus.groovy:groovy-all:2.0.5'
classpath 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1'
}
}
plugins {
id 'groovy'
}
// get the cluster connection details
Properties props = new Properties()
props.load(new FileInputStream("$projectDir/../../connection.properties"))
// Set default service name to check
def service_name = "HDFS"
// set the dependencies for compiling the groovy script
repositories {
mavenCentral()
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.0.5'
compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1'
}
// tell gradle the groovy script is in the same folder as the build.gradle file
sourceSets {
main {
groovy {
srcDirs = ['.']
}
}
}
// Get service name from command line argument
// For example -Pservice=YARN.
// See service ServiceCheck.grooyv for valid value
if (project.hasProperty('service')) {
service_name = service
}
// task to run the Example.groovy script
['ListServices', 'ShowMaster', 'AlertServices', 'HdfsServiceCheck', 'ServiceCheck', 'RestartService'].each { taskName ->
task "$taskName" (type: JavaExec) {
// if running this task with clean, ensure clean runs first
mustRunAfter clean
environment 'ambariUrl', props.ambariUrl
environment 'ambariUsername', props.ambariUsername
environment 'ambariPassword', props.ambariPassword
environment 'service_name', service_name
main = taskName
classpath = sourceSets.main.runtimeClasspath
}
}
task('Example') {
dependsOn ListServices, HdfsServiceCheck, ShowMaster
}