This repository has been archived by the owner on Sep 15, 2022. It is now read-only.
generated from hmcts/spring-boot-template
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
328 lines (278 loc) · 10.2 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
buildscript {
repositories {
jcenter()
}
dependencies {
classpath("net.serenity-bdd:serenity-gradle-plugin:2.4.24")
}
}
plugins {
id 'idea'
id 'application'
id 'checkstyle'
id 'jacoco'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'org.springframework.boot' version '2.5.2'
id 'org.owasp.dependencycheck' version '6.1.5'
id 'com.github.ben-manes.versions' version '0.38.0'
id 'org.sonarqube' version '3.1.1'
id "io.freefair.lombok" version "5.3.3.3"
id 'org.flywaydb.flyway' version '7.8.0'
}
apply plugin: 'net.serenity-bdd.aggregator'
group = 'uk.gov.hmcts.reform'
version = '0.0.1'
sourceCompatibility = 11
targetCompatibility = 11
sourceSets {
functionalTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/functionalTest/java')
}
resources.srcDir file('src/functionalTest/resources')
}
integrationTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/integrationTest/java')
}
resources.srcDir file('src/integrationTest/resources')
}
smokeTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/smokeTest/java')
}
resources.srcDir file('src/smokeTest/resources')
}
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Werror"
}
task functional(type: Test, description: 'Runs the functional tests.', group: 'Verification') {
testClassesDirs = sourceSets.functionalTest.output.classesDirs
classpath = sourceSets.functionalTest.runtimeClasspath
}
task integration(type: Test, description: 'Runs the integration tests.', group: 'Verification') {
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
useJUnitPlatform()
// set your environment variables here
// environment("APPINSIGHTS_INSTRUMENTATIONKEY", "test-key")
}
task smoke(type: GradleBuild, description: 'Runs smoke tests', group: 'Verification') {
buildFile = './build.gradle'
tasks = ['smokeTest']
}
checkstyle {
maxWarnings = 0
toolVersion = '8.18'
// need to set configDir to rootDir otherwise submodule will use submodule/config/checkstyle
configDir = new File(rootDir, 'config/checkstyle')
}
jacoco {
toolVersion = "0.8.4"
}
jacocoTestReport {
executionData(test)
reports {
xml.enabled = true
csv.enabled = false
xml.destination file("${buildDir}/reports/jacoco/test/jacocoTestReport.xml")
}
}
def sonarExclusions = [
'**/Application.java',
'**/config/*.java',
'**/CcdPollingController.java',
'**/LastRunTimeService.java',
'**/AuthController.java',
'**/Authorize.java',
'**/IdamService.java',
'**/UserDetails.java',
'**/Task.java',
'**/EmailSendingService.java',
'**/QueueClientSupplier.java',
'**/*Exception.java',
'**/TaskErrorHandler.java'
]
sonarqube {
properties {
property "sonar.projectKey", "CTSC-WORK-ALLOCATION"
property "sonar.projectName", "CTSC-Work-Allocation-app"
property "sonar.coverage.jacoco.xmlReportPaths", "${project.buildDir}/reports/jacoco/test/jacocoTestReport.xml"
property "sonar.exclusions", sonarExclusions.join(", ")
property "sonar.test.exclusions", sonarExclusions.join(", ")
property "sonar.coverage.exclusions", sonarExclusions.join(", ")
}
}
project.tasks['sonarqube'].dependsOn jacocoTestReport
dependencyUpdates.resolutionStrategy = {
componentSelection { rules ->
rules.all { ComponentSelection selection ->
boolean rejected = ['alpha', 'beta', 'rc', 'cr', 'm'].any { qualifier ->
selection.candidate.version ==~ /(?i).*[.-]${qualifier}[.\d-]*/
}
if (rejected) {
selection.reject('Release candidate')
}
}
}
}
// https://jeremylong.github.io/DependencyCheck/dependency-check-gradle/configuration.html
dependencyCheck {
// Specifies if the build should be failed if a CVSS score above a specified level is identified.
// range of 0-10 fails the build, anything greater and it doesn't fail the build
failBuildOnCVSS = System.getProperty('dependencyCheck.failBuild') == 'true' ? 0 : 11
suppressionFile = 'config/owasp/suppressions.xml'
analyzers {
// Disable scanning of .NET related binaries
assemblyEnabled = false
}
}
dependencyManagement {
dependencies {
dependency group: 'org.bouncycastle', name: 'bcpkix-jdk15on', version: '1.68'
// CVE-2018-10237 - Unbounded memory allocation
dependencySet(group: 'com.google.guava', version: '30.1.1-jre') {
entry 'guava'
}
dependencySet(group: 'io.netty', version: '4.1.65.Final') {
entry 'netty-buffer'
entry 'netty-codec'
entry 'netty-codec-http'
entry 'netty-codec-socks'
entry 'netty-common'
entry 'netty-handler'
entry 'netty-handler-proxy'
entry 'netty-resolver'
entry 'netty-transport'
entry 'netty-transport-native-epoll'
entry 'netty-transport-native-kqueue'
entry 'netty-transport-native-unix-common'
entry 'netty-codec-dns'
entry 'netty-resolver-dns'
entry 'netty-resolver-dns-native-macos'
}
}
}
repositories {
mavenLocal()
jcenter()
mavenCentral()
}
def versions = [
junit : '5.5.0',
reformLogging : '5.0.1',
springBoot : springBoot.class.package.implementationVersion,
serenity : '2.2.12'
]
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'org.codehaus.groovy') {
details.useVersion "3.0.3"
details.because "needed by rest-assured>=4.3"
}
}
}
}
dependencies {
implementation group: 'uk.gov.hmcts.reform', name: 'java-logging', version: '5.0.1'
implementation group: 'uk.gov.hmcts.reform', name: 'java-logging-spring', version: '5.0.1'
implementation group: 'uk.gov.hmcts.reform', name: 'service-auth-provider-client', version: '4.0.0'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-aop'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-json'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-mail'
implementation group: 'com.microsoft.azure', name: 'applicationinsights-spring-boot-starter', version: '2.6.3'
implementation group: 'io.springfox', name: 'springfox-boot-starter', version: '3.0.0'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-hystrix', version: '2.2.8.RELEASE'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-bootstrap', version: '3.0.3'
implementation group: 'uk.gov.hmcts.reform', name: 'java-logging', version: versions.reformLogging
implementation group: 'com.microsoft.azure', name: 'azure-servicebus', version: '3.6.2'
implementation group: 'com.microsoft.azure', name: 'applicationinsights-logging-logback', version: '2.6.3'
implementation group: 'org.springframework.retry', name: 'spring-retry', version: '1.3.1'
implementation group: 'org.postgresql', name: 'postgresql', version: '42.2.19'
implementation group: 'org.apache.velocity', name: 'velocity', version: '1.7'
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jdk8', version: '2.12.3'
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.12.3'
implementation group: 'io.vavr', name: 'vavr', version: '0.10.3'
implementation group: 'org.flywaydb', name: 'flyway-core', version: '7.8.0'
testCompile group: 'io.rest-assured', name: 'rest-assured', version: '4.3.3'
testCompile group: 'io.rest-assured', name: 'json-path', version: '4.3.3'
testCompile group: 'io.rest-assured', name: 'xml-path', version: '4.3.3'
testCompile group: 'net.serenity-bdd', name: 'serenity-core', version: versions.serenity
testCompile group: 'net.serenity-bdd', name: 'serenity-spring', version: versions.serenity
testCompile(group: 'org.springframework.boot', name: 'spring-boot-starter-test') {
exclude(module: 'commons-logging')
}
integrationTestCompile sourceSets.main.runtimeClasspath
integrationTestCompile sourceSets.test.runtimeClasspath
// smoke
smokeTestCompile sourceSets.test.runtimeClasspath
smokeTestCompile sourceSets.main.runtimeClasspath
// functional
functionalTestCompile sourceSets.test.runtimeClasspath
functionalTestCompile sourceSets.main.runtimeClasspath
testCompile 'junit:junit:4.13.2'
testCompile 'org.assertj:assertj-core:3.19.0'
testCompile 'com.tngtech.java:junit-dataprovider:1.13.1'
compileOnly 'com.google.code.findbugs:annotations:3.0.1u2'
}
test {
finalizedBy aggregate
}
mainClassName = 'uk.gov.hmcts.reform.workallocation.Application'
jar {
enabled = true
}
bootJar {
getArchiveFileName().set(provider {
'ctsc-work-allocation.jar'
})
manifest {
attributes('Implementation-Version': project.version.toString())
}
}
springBoot {
mainClassName = 'uk.gov.hmcts.reform.workallocation.Application'
buildInfo()
}
dependencyCheck {
failBuildOnCVSS = 0
suppressionFile = 'dependency-check-suppressions.xml'
}
apply plugin: 'idea'
idea {
module {
testSourceDirs += project.sourceSets.smokeTest.java.srcDirs
testSourceDirs += project.sourceSets.smokeTest.resources.srcDirs
testSourceDirs += project.sourceSets.functionalTest.java.srcDirs
testSourceDirs += project.sourceSets.functionalTest.resources.srcDirs
}
}
task smokeTest(type: Test, description: 'Runs the smoke tests', group: 'Verification') {
testClassesDirs = sourceSets.smokeTest.output.classesDirs
classpath = sourceSets.smokeTest.runtimeClasspath
finalizedBy aggregate
}
flyway {
url = System.getenv('FLYWAY_URL')
user = System.getenv('FLYWAY_USER')
password = System.getenv('FLYWAY_PASSWORD')
baselineOnMigrate = true
baselineVersion = '000'
}
task migratePostgresDatabase(type: org.flywaydb.gradle.task.FlywayMigrateTask) {
baselineOnMigrate = true
if (project.hasProperty("dburl")) {
url = "jdbc:postgresql://${dburl}"
}
}