forked from department-of-veterans-affairs/abd-vro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
256 lines (237 loc) · 9.33 KB
/
Copy pathbuild.gradle
File metadata and controls
256 lines (237 loc) · 9.33 KB
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
buildscript {
dependencies {
classpath "gov.va.starter:plugins:${starter_boot_version}"
classpath "gov.va.starter:cookiecutter:${starter_boot_version}"
classpath "se.patrikerdes:gradle-use-latest-versions-plugin:${use_latest_versions_plugin_version}"
classpath "com.github.ben-manes:gradle-versions-plugin:${versions_plugin_version}"
}
// There's a conflict between versions of jgit between spotless and axion release plugin
configurations.classpath {
resolutionStrategy {
force 'org.eclipse.jgit:org.eclipse.jgit:5.7.0.202003110725-r'
}
}
}
plugins {
// Set versions for these plugins (but don't apply) so we don't have to specify the version later
id("org.ajoberstar.grgit") version "${grgit_version}" apply false
id("io.freefair.lombok") version "8.0.1" apply false
id("org.springframework.boot") version "${spring_boot_version}" apply false
id("io.swagger.swaggerhub") version "${swaggerhub_version}" apply false
id("com.diffplug.spotless") version "${spotless_plugin_version}" apply false
id("com.palantir.docker") version "${palantir_docker_plugin_version}" apply false
id("com.palantir.docker-run") version "${palantir_docker_run_plugin_version}" apply false
id("net.rdrei.android.buildtimetracker") version "${buildtimetracker_version}" apply false
id("com.github.ben-manes.versions") version "${versions_plugin_version}" apply false
id("se.patrikerdes.use-latest-versions") version "${use_latest_versions_plugin_version}" apply false
id("com.github.johnrengelman.processes") version "${processes_plugin_version}" apply false
id("org.springdoc.openapi-gradle-plugin") version "${openapi_gradle_plugin_version}" apply false
id("org.flywaydb.flyway") version "${flyway_plugin_version}" apply false
id("com.felipefzdz.gradle.shellcheck") version "${shellcheck_plugin_version}" apply false
id("org.barfuin.gradle.jacocolog") version "${jacocolog_plugin_version}" apply false
// Apply these
id("org.barfuin.gradle.taskinfo") version "${taskinfo_plugin_version}"
id('nebula.lint') version '18.0.3'
id("pl.allegro.tech.build.axion-release") version "${axion_release_plugin_version}"
// VA's starter plugins
// https://github.com/department-of-veterans-affairs/lighthouse-di-starter-boot/tree/main/buildSrc/src/main/groovy
id("starter.java.build-utils-property-conventions") version "${starter_boot_version}"
id("starter.java.build-utils-task-conventions") version "${starter_boot_version}"
id("starter.java.release-conventions") version "${starter_boot_version}"
id("starter.metrics.build-time-tracker-conventions") version "${starter_boot_version}"
id("starter.java.versions-conventions") version "${starter_boot_version}"
id("starter.java.test-jacoco-aggregation-conventions") version "${starter_boot_version}"
id('starter.java.doc-mkdocs-conventions') version "${starter_boot_version}"
}
allprojects {
apply plugin: 'nebula.lint'
gradleLint {
alwaysRun = false
reportFormat = 'text'
// https://github.com/nebula-plugins/gradle-lint-plugin/wiki
rules = ['unused-dependency']
// criticalRules will fail the build in the event of a violation
criticalRules = [
'minimum-dependency-version',
'overridden-dependency-version',
'unused-exclude-by-dep',
'unused-exclude-by-conf',
'dependency-parentheses',
'duplicate-dependency-class',
'archaic-wrapper',
'all-nebula-renames'
]
}
afterEvaluate {
// Workaround for gradleLint failure
// https://github.com/nebula-plugins/gradle-lint-plugin/issues/336#issuecomment-844989277
// https://github.com/gradle/gradle/issues/6854
configurations.all {
if (name.startsWith("incrementalScalaAnalysis")) {
extendsFrom = []
}
}
}
apply plugin: 'com.diffplug.spotless'
spotless {
// to format build.gradle files consistently
groovyGradle {
greclipse()
indentWithSpaces(2)
}
}
}
subprojects {
task allDependencies(type: DependencyReportTask) {}
pluginManager.withPlugin('java') {
// Constrains transitive dependencies to use versions without vulnerabilities
// buildSrc/src/main/groovy/local.java.vro-dep-constraints.gradle
apply plugin: 'local.java.vro-dep-constraints'
// Defines springBom, annotationBom, and checkstyleRules
// https://github.com/department-of-veterans-affairs/lighthouse-di-starter-boot/blob/main/buildSrc/src/main/groovy/starter.java.config-conventions.gradle
apply plugin: 'starter.java.config-conventions'
dependencies {
// https://github.com/department-of-veterans-affairs/lighthouse-di-starter-boot/blob/main/starter-bom/build.gradle
annotationBom platform("gov.va.starter:starter-bom:${starter_boot_version}")
// https://github.com/department-of-veterans-affairs/lighthouse-di-starter-boot/blob/main/checkstyle-bom/build.gradle
checkstyleRules platform("gov.va.starter:checkstyle-bom:${starter_boot_version}")
}
// List all failedTest at the end of a build -- copied from https://stackoverflow.com/a/43936442
// add a collection to track failedTests
ext.failedTests = []
// add a listener to all tasks of type Test
tasks.withType(Test) {
afterTest { TestDescriptor descriptor, TestResult result ->
if(result.resultType == org.gradle.api.tasks.testing.TestResult.ResultType.FAILURE){
failedTests << "${descriptor.className}::${descriptor.name}"
}
}
}
// print out tracked failed tests when the build has finished
gradle.buildFinished {
if(!failedTests.empty){
println "Failed tests:"
failedTests.each { failedTest ->
println "- " + failedTest
}
println ""
}
}
}
}
ext {
jacoco_enforce_violations = true
jacoco_minimum_coverage = 0.8
// Modules that use Java code
codeModules = [
':app',
':persistence:model',
':shared:lib-camel-connector',
':domain-rrd:rrd-api-controller',
':domain-rrd:rrd-workflows',
':domain-rrd:rrd-shared',
':svc-lighthouse-api',
':console',
':mocks:mock-bip-ce-api',
':mocks:mock-bip-claims-api',
':mocks:mock-shared',
':mocks:mock-mas-api',
':mocks:mock-lighthouse-api',
':mocks:mock-slack',
':domain-xample:xample-api-controller',
':domain-xample:xample-shared',
':domain-xample:xample-workflows',
':domain-xample:svc-xample-j',
':domain-cc:cc-api-controller'
]
// Modules that create Docker images
dockerModules = [
':app',
':db-init',
':service-python:assessclaimdc7101',
':service-python:assessclaimdc6602',
':service-python:pdfgenerator',
':service-python:featuretoggle',
':svc-bgs-api',
':svc-lighthouse-api',
':console',
':mocks:mock-bip-ce-api',
':mocks:mock-bip-claims-api',
':mocks:mock-mas-api',
':mocks:mock-lighthouse-api',
':mocks:mock-slack',
':domain-xample:xample-workflows',
':domain-xample:svc-xample-j'
]
if (project.hasProperty("enablePrototype")) {
dockerModules.add(':service-python:assessclaimdc6602v2')
dockerModules.add(':service-python:assessclaimdc6510')
dockerModules.add(':service-python:assessclaimdc6522')
dockerModules.add(':service-python:assessclaimcancer')
}
}
// Used by `release` task to create a new version
scmVersion {
// never connect to remote
localOnly = true
useHighestVersion = true
hooks {
pre("fileUpdate", [file : "app/src/main/java/gov/va/vro/config/propmodel/Info.java",
pattern : { v, p -> /version = "v.*"/ },
replacement: { v, p -> "version = \"v$v\"" }])
// Here is where the appVersion is updated with each release
pre("fileUpdate", [file : "helm-app/Chart.yaml",
pattern : { v, p -> /appVersion: .*/ },
replacement: { v, p -> "appVersion: $v" }])
pre("commit")
}
}
allprojects {
// https://axion-release-plugin.readthedocs.io/en/latest/configuration/basic_usage
project.version = scmVersion.version
}
def maintainerclean = tasks.register('maintainerclean') {
group = "Workflow"
description = "clean all submodules"
def tb = taskBuilder('clean')
codeModules.each { dependsOn tb(it) }
dockerModules.each { dependsOn tb(it) }
//depender codeModules, taskBuilder('clean')
//depender dockerModules, taskBuilder('clean')
}
def dockerclean = tasks.register('dockerclean') {
group = "Workflow"
description = "clean docker images"
dependsOn ':app:dockerComposeDown'
dependsOn ':app:dockerPrune'
}
def dockermaintainerclean = tasks.register('dockermaintainerclean') {
group = "Workflow"
description = "clean docker images"
dependsOn ':app:dockerPruneVolume'
mustRunAfter dockerclean
}
def devloop = tasks.register('devloop') {
group = "Workflow"
description = "Rebuild code, docker images, and restart docker-compose"
dependsOn ':app:build'
def tb = taskBuilder('docker')
dockerModules.each { dependsOn tb(it) }
//depender(dockerModules, taskBuilder('docker'))
dependsOn ':app:dockerComposeUp'
mustRunAfter dockerclean
mustRunAfter dockermaintainerclean
}
def restartloop = tasks.register('restartloop') {
group = "Workflow"
description = "Stop docker-compose, delete unused images, continue with devloop task"
dependsOn dockerclean
dependsOn devloop
}
tasks.register('resetloop') {
group = "Workflow"
description = "Remove docker volumes, continue with restartloop task"
dependsOn dockerclean
dependsOn dockermaintainerclean
dependsOn restartloop
}