forked from Netflix/genie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
360 lines (301 loc) · 10.3 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
buildscript {
repositories {
jcenter()
maven {
url "http://repo.spring.io/milestone"
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${spring_boot_version}")
classpath("io.spring.gradle:dependency-management-plugin:0.6.1.RELEASE")
classpath("org.asciidoctor:asciidoctor-gradle-plugin:1.5.3")
classpath("gradle.plugin.com.gorylenko.gradle-git-properties:gradle-git-properties:1.4.17")
classpath("com.netflix.nebula:gradle-aggregate-javadocs-plugin:3.0.1")
}
}
plugins {
id "com.github.kt3k.coveralls" version "2.7.1"
id "nebula.netflixoss" version "3.5.2"
id "org.ajoberstar.github-pages" version "1.6.0"
}
apply plugin: "nebula-aggregate-javadocs"
ext.githubProjectName = rootProject.name
def javaProjects = subprojects.findAll {
it.name != "genie-demo" && it.name != "genie-ddl" && it.name != "genie-docs"
}
allprojects {
apply plugin: "jacoco"
apply plugin: "idea"
apply plugin: "eclipse"
repositories {
jcenter()
maven {
url "http://repo.spring.io/milestone"
}
}
}
idea {
project {
jdkName = "1.8"
languageLevel = "1.8"
vcs = "Git"
}
}
task clean(type: Delete) {
delete "build"
}
configure(javaProjects) {
apply plugin: "nebula.netflixoss"
apply plugin: "java"
apply plugin: "checkstyle"
apply plugin: "findbugs"
apply plugin: "pmd"
apply plugin: "io.spring.dependency-management"
apply plugin: "com.gorylenko.gradle-git-properties"
apply plugin: "groovy"
group = "com.netflix.${githubProjectName}"
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencyManagement {
imports {
mavenBom "io.spring.platform:platform-bom:${spring_platform_version}"
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${spring_cloud_version}"
}
}
ext {
generatedSourcesDir = new File("${projectDir}/src/generated")
generatedSourcesJavaDir = new File(generatedSourcesDir, "/java")
}
sourceSets {
main {
java {
srcDir generatedSourcesJavaDir
}
}
}
clean {
delete "${projectDir}/genie-db"
delete "${projectDir}/data"
delete generatedSourcesDir.toString()
}
configurations {
all*.exclude group: "javax.servlet", module: "servlet-api"
}
dependencies {
/*******************************
* Compile Dependencies
*******************************/
/*******************************
* Provided Dependencies
*******************************/
compileOnly("org.projectlombok:lombok")
compileOnly("com.google.code.findbugs:annotations:${findbugs_annotations_version}")
/*******************************
* Runtime Dependencies
*******************************/
/*******************************
* Test Dependencies
*******************************/
testCompile("cglib:cglib-nodep:${cglib_nodep_version}")
testCompile("org.spockframework:spock-core")
testCompile("org.spockframework:spock-spring")
testCompile("org.springframework.boot:spring-boot-starter-test")
testCompileOnly("org.projectlombok:lombok")
testCompileOnly("com.google.code.findbugs:annotations:${findbugs_annotations_version}")
testRuntime("javax.el:javax.el-api")
testRuntime("org.glassfish:javax.el")
}
task unitTests(type: Test, group: "verification") {
useJUnit {
includeCategories "com.netflix.genie.test.categories.UnitTest"
excludeCategories "com.netflix.genie.test.categories.IntegrationTest"
excludeCategories "com.netflix.genie.test.categories.DocumentationTest"
}
}
task integrationTests(type: Test, group: "verification") {
useJUnit {
includeCategories "com.netflix.genie.test.categories.IntegrationTest"
excludeCategories "com.netflix.genie.test.categories.UnitTest"
excludeCategories "com.netflix.genie.test.categories.DocumentationTest"
}
}
task documentationTests(type: Test, group: "verification") {
useJUnit {
includeCategories "com.netflix.genie.test.categories.DocumentationTest"
excludeCategories "com.netflix.genie.test.categories.UnitTest"
excludeCategories "com.netflix.genie.test.categories.IntegrationTest"
}
}
compileJava {
// options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
compileTestJava {
// options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
tasks.withType(Test) {
task ->
// set heap size for the test JVM(s)
minHeapSize = "256m"
maxHeapSize = "2g"
// If the project is running on a CI server
if (System.getenv("CI") != null) {
systemProperty "CI", System.getenv("CI")
}
reports.html.destination = file("${reporting.baseDir}/test/${task.name}")
jacocoTestReport.executionData += files("$buildDir/jacoco/${task.name}.exec")
}
license {
excludes(["${projectDir}/src/generated/*"])
}
checkstyle {
toolVersion = "6.11"
configFile = new File(project.parent.projectDir, "codequality/checkstyle/checkstyle.xml")
}
findbugs {
excludeFilter = new File(project.parent.projectDir, "codequality/findbugs/excludeFilter.xml")
}
tasks.withType(Pmd) {
reports.html.enabled true
}
jacocoTestReport {
reports {
html.enabled = true
xml.enabled = true
csv.enabled = false
}
}
}
task jacocoRootReport(type: JacocoReport, group: "Coverage reports") {
group = "Coverage Reports"
dependsOn javaProjects.test
additionalSourceDirs = files(javaProjects.sourceSets.main.allSource.srcDirs)
sourceDirectories = files(javaProjects.sourceSets.main.allSource.srcDirs)
classDirectories = files(javaProjects.sourceSets.main.output)
executionData = files(javaProjects.jacocoTestReport.executionData)
reports {
html.enabled = true
xml.enabled = true
}
onlyIf = {
true
}
doFirst {
executionData = files(
executionData.findAll {
it.exists()
}
)
}
afterEvaluate {
classDirectories = files(
classDirectories.files.collect {
fileTree(dir: it, exclude: ["com/netflix/genie/core/jpa/entities/*_*"])
}
)
}
}
/**********************************
* Coverage Tasks
**********************************/
coveralls {
sourceDirs = javaProjects.sourceSets.main.allSource.srcDirs.flatten()
jacocoReportPath = "${project.buildDir}/reports/jacoco/jacocoRootReport/jacocoRootReport.xml"
}
tasks.coveralls {
group = "Coverage reports"
description = "Uploads the aggregated coverage report to Coveralls"
dependsOn jacocoRootReport
onlyIf {
System.env."CI"
}
}
/**********************************
* Github Pages Tasks
**********************************/
task collectDocumentation(group: "documentation", description: "Copy the documentation from sub-projects") {
dependsOn "aggregateJavadocs"
// TODO: Maybe make this dependent on output of asciidoc tasks?
def restDocs = new File(project(":genie-web").buildDir, "asciidoc/html5")
def referenceDocs = new File(project(":genie-docs").buildDir, "asciidoc/html5")
def demoDocs = new File(project(":genie-demo").buildDir, "asciidoc/html5")
def dockerCompose = new File(project(":genie-demo").projectDir, "src/main/docker/docker-compose.yml")
def docsDir = new File(project.buildDir, "docs")
inputs.dir restDocs
inputs.dir referenceDocs
inputs.dir demoDocs
inputs.file dockerCompose
outputs.dir docsDir
doLast {
copy {
from dockerCompose
into new File(docsDir, "demo")
filter {
it.replace('${GENIE_VERSION}', project.version.toString())
}
}
copy {
from restDocs
into new File(docsDir, "rest")
}
copy {
from referenceDocs
into new File(docsDir, "reference")
}
copy {
from demoDocs
into new File(docsDir, "demo")
}
}
}
githubPages {
credentials {
username = System.getenv("GH_TOKEN")
password = ""
}
deleteExistingFiles = false
commitMessage = "Documentation generated for ${project.version} by Travis Build ${System.env.TRAVIS_BUILD_NUMBER}"
pages {
into("docs/${project.version}/") {
from "${project.buildDir}/docs/"
}
into("_releases") {
from new File(project(":genie-docs").projectDir, "src/templates/releaseTemplate.md")
rename {
String fileName -> fileName.replace("releaseTemplate", "${project.version}")
}
filter {
it.replace("GENIE_VERSION", project.version.toString())
}
}
}
}
prepareGhPages {
// This also depends on asciidoctor task for some sub-projects but that dependency is reverse mapped in the
// pertinent sub-project build file
dependsOn tasks.collectDocumentation
}
publishGhPages {
onlyIf {
System.env."CI"
}
}
/**********************************
* Docker Tasks
**********************************/
def isLatest() {
return (boolean) !project.version.toString().contains("SNAPSHOT") && !project.version.toString().contains("-rc.")
}
def getDockerTags(String appName) {
def tags = ["netflixoss/${appName}:${project.version}"]
if (isLatest()) {
tags.add("netflixoss/${appName}:latest")
}
return tags
}
task dockerLogout(type: Exec, group: "Docker", description: "Logout of docker hub") {
commandLine "docker", "logout"
}
task dockerLogin(type: Exec, group: "Docker", description: "Login to docker hub using DOCKER_USER and DOCKER_PASSWORD environment variables") {
dependsOn tasks.dockerLogout
commandLine "docker", "login", "-u", System.getenv("DOCKER_USER"), "-p", System.getenv("DOCKER_PASSWORD")
}