forked from Nike-Inc/cerberus-serverless-components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
141 lines (121 loc) · 4.11 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
group 'com.nike'
buildscript {
apply from: file('gradle/buildscript.gradle'), to: buildscript
}
// load environment specific props from global and environment profiles
def environment = project.hasProperty('env') ? project.'env' : 'dev'
Properties props = new Properties()
def globalProperties = new File("$project.projectDir/profile/global.properties")
if (globalProperties.exists()) {
props.load(new FileInputStream(globalProperties))
} else {
logger.warn("${globalProperties.absolutePath} does not exit, no properties to load")
}
def envSpecificProps = new File("$project.projectDir/profile/${environment}.properties")
if (envSpecificProps.exists()) {
props.load(new FileInputStream(envSpecificProps))
} else {
logger.warn("${envSpecificProps.absolutePath} does not exit, no properties to load")
}
project.ext.set('environment', environment)
props.each { prop ->
project.ext.set(prop.key, prop.value)
}
Map<String, String> getRegionBucketMap(String serializedMap) {
List<String> keyValuePairs = serializedMap.split(/,/)
Map<String, String> regionBucketMap = [:]
keyValuePairs.each { kvPair ->
Collection kv = kvPair.split(/:/);
if (kv.size() == 2) {
String key = kv[0]
String value = kv[1]
regionBucketMap.put(key, value)
}
}
return regionBucketMap
}
String getProfileProperty(String key) {
if (project.hasProperty(key)) {
def value = project."${key}"
logger.lifecycle("profile prop found: [ $key: $value ]")
return value
} else {
logger.warn("The project did not have extention property: ${key} for env: ${project.environment}, returning empty string")
return ''
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'jacoco'
apply plugin: "com.github.johnrengelman.shadow"
apply plugin: 'com.github.kt3k.coveralls'
apply plugin: "com.fieldju.aws-sam-deployer"
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
jcenter()
}
jacoco {
toolVersion = "0.7.6.201602180812"
reportsDir = file("$buildDir/reports")
}
jacocoTestReport {
reports {
xml.enabled true
csv.enabled false
html.destination "${buildDir}/reports/jacocoHtml"
xml.destination "${buildDir}/reports/jacoco/test/jacocoTestReport.xml"
}
afterEvaluate {
classDirectories = files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
'**/com/nike/cerberus/lambda/waf/ALBAccessLogEvent*'
])
})
}
}
configurations {
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
}
sourceSets {
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integration-test/java')
}
groovy {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integration-test/groovy')
}
resources.srcDir file('src/integration-test/resources')
}
}
task integrationTest(type: Test) {
testClassesDir = sourceSets.integrationTest.output.classesDir
classpath = sourceSets.integrationTest.runtimeClasspath
// copy the needed props to the int tests
systemProperties = [
arn: System.getProperty('arn'),
bucketName: System.getProperty('bucketName'),
logKey: System.getProperty('logKey')
]
}
tasks.withType(Test) {
reports.html.destination = file("${reporting.baseDir}/${name}")
testLogging {
events "passed", "skipped", "failed"
}
}
integrationTest {
testLogging {
showStandardStreams = true
}
}
dependencies {
compile 'com.fieldju:commons:1.2.0'
}
}