forked from hmcts/civil-ccd-definition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
246 lines (203 loc) · 6.71 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
plugins {
id 'application'
id 'checkstyle'
id 'jacoco'
id 'org.owasp.dependencycheck' version '6.2.2'
id 'com.github.ben-manes.versions' version '0.39.0'
id 'org.sonarqube' version '3.3'
id 'au.com.dius.pact' version '4.2.7'
id 'net.ltgt.apt' version '0.21'
}
group = 'uk.gov.hmcts.reform'
version = '0.0.1'
allprojects {
sourceCompatibility = '11'
targetCompatibility = '11'
apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'checkstyle'
apply plugin: 'org.owasp.dependencycheck'
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'net.ltgt.apt'
checkstyle {
maxWarnings = 0
toolVersion = '8.29'
getConfigDirectory().set(new File(rootDir, 'config/checkstyle'))
}
jacoco {
toolVersion = '0.8.5' // jacocoMavenPluginVersion
reportsDir = file("$buildDir/reports/jacoco")
}
// before committing a change, make sure task still works
dependencyUpdates {
def isNonStable = { String version ->
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { qualifier -> version.toUpperCase().contains(qualifier) }
def regex = /^[0-9,.v-]+$/
return !stableKeyword && !(version ==~ regex)
}
rejectVersionIf { selection -> // <---- notice how the closure argument is named
return isNonStable(selection.candidate.version) && !isNonStable(selection.currentVersion)
}
}
// 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
}
}
repositories {
mavenLocal()
jcenter()
mavenCentral()
maven {
url 'https://jitpack.io'
}
maven {
url "http://repo.spring.io/milestone"
}
maven {
url "https://repo.spring.io/libs-milestone"
}
}
}
sourceSets {
functionalTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/functionalTest/java')
}
resources.srcDir file('src/functionalTest/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"
}
tasks.withType(Test) {
useJUnitPlatform()
testLogging {
exceptionFormat = 'full'
}
}
test {
failFast = true
}
jar {
getArchiveFileName().set(provider {
'empty.jar'
})
manifest {
attributes('Implementation-Version': project.version.toString())
}
}
task highLevelDataSetup(type: JavaExec) {
main = "uk.gov.hmcts.reform.civil.HighLevelDataSetupApp"
classpath += sourceSets.main.runtimeClasspath
jvmArgs = ['--add-opens=java.base/java.lang.reflect=ALL-UNNAMED']
}
task installDependencies(type: Exec, description: 'Installs Yarn dependencies.') {
commandLine '/usr/bin/yarn', '--mutex', 'network', '--frozen-lockfile', '--silent', 'install'
}
task checkDependenciesIntegrity(type: Exec, description: 'Checks integrity of Yarn dependencies.') {
commandLine '/usr/bin/yarn', '--mutex', 'network', '--frozen-lockfile', '--silent', 'check', '--integrity'
}
task lintUserInterfaceTests(type: Exec, description: 'Runs linting of E2E tests.') {
commandLine '/usr/bin/yarn', '--silent', 'lint'
}
task awaitApplicationReadiness(type: Exec, description: 'Awaits until application is ready.') {
commandLine './bin/wait-for.sh', System.env.URL
commandLine './bin/wait-for.sh', System.env.CIVIL_SERVICE_URL
}
task runSmokeTests(type: Exec, description: 'Runs smoke tests.') {
commandLine '/usr/bin/yarn', '--silent', 'test:smoke'
}
task runFunctionalTests(type: Exec, description: 'Runs functional tests.') {
commandLine '/usr/bin/yarn', '--silent', 'test:functional'
}
task runRpaHandOffTests(type: Exec, description: 'Runs functional tests.') {
commandLine '/usr/bin/yarn', '--silent', 'test:rpa'
}
def inStrictOrder(Task... tasks) {
for (int i = 0; i < tasks.size() - 1; i++) {
tasks[i + 1].mustRunAfter(tasks[i])
}
return tasks
}
task smoke(description: 'Runs the smoke tests.') {
dependsOn(inStrictOrder(awaitApplicationReadiness, installDependencies, checkDependenciesIntegrity, lintUserInterfaceTests, runSmokeTests))
}
task functional(description: 'Runs the functional tests.') {
dependsOn(inStrictOrder(awaitApplicationReadiness, installDependencies, checkDependenciesIntegrity, runFunctionalTests))
}
project.tasks['sonarqube'].dependsOn test, jacocoTestReport
sonarqube {
properties {
property "sonar.projectName", "CIVIL :: ccd-definition"
property "sonar.projectKey", "civil-ccd-definition"
property "sonar.coverage.jacoco.xmlReportPaths", "${jacocoTestReport.reports.xml.destination.path}"
property "sonar.coverage.exclusions", "**/HighLevelDataSetupApp.java"
property "sonar.host.url", "https://sonar.reform.hmcts.net/"
}
}
jacocoTestReport {
executionData(test)
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")
subprojects.each {
sourceSets it.sourceSets.main
}
reports {
xml.enabled = true
csv.enabled = false
xml.destination file("${buildDir}/reports/jacoco/test/jacocoTestReport.xml")
}
}
jacocoTestReport.dependsOn {
subprojects*.test
}
def versions = [
junit : '5.7.0',
junitPlatform : '1.7.1',
reformLogging : '5.1.5'
]
ext.libraries = [
junit5: [
"org.junit.jupiter:junit-jupiter-api:${versions.junit}",
"org.junit.jupiter:junit-jupiter-engine:${versions.junit}",
"org.junit.jupiter:junit-jupiter-params:${versions.junit}",
"org.junit.platform:junit-platform-commons:${versions.junitPlatform}",
"org.junit.platform:junit-platform-engine:${versions.junitPlatform}"
]
]
dependencies {
implementation group: 'com.github.hmcts', name: 'befta-fw', version: '8.3.0'
constraints {
implementation('org.apache.commons:commons-compress:1.21') {
because 'CVE-2021-35515, CVE-2021-35516, CVE-2021-35517, CVE-2021-36090'
}
}
testImplementation libraries.junit5
functionalTestImplementation sourceSets.main.runtimeClasspath
smokeTestImplementation sourceSets.main.runtimeClasspath
}
wrapper {
distributionType = Wrapper.DistributionType.ALL
}
project.ext {
pactVersion = getCheckedOutGitCommitHash()
}
def getCheckedOutGitCommitHash() {
'git rev-parse --verify --short HEAD'.execute().text.trim()
}