-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
257 lines (217 loc) · 7.58 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
import io.miret.etienne.gradle.sass.CompileSass
import org.yaml.snakeyaml.Yaml
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.yaml:snakeyaml:2.3'
}
}
plugins {
id 'org.springframework.boot' version '3.4.1'
id 'io.spring.dependency-management' version '1.1.7'
id 'java'
id 'com.adarshr.test-logger' version '4.0.0'
id 'jacoco'
id "org.flywaydb.flyway" version "[9.+,10.0["
id 'io.miret.etienne.sass' version '1.5.1'
id "io.sentry.jvm.gradle" version "4.14.1"
}
jacoco {
toolVersion = '0.8.10'
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
configurations.configureEach {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
def props = new Properties()
if (file(".env").exists()) {
file(".env").withInputStream { props.load(it) }
}
repositories {
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
mavenCentral()
}
def profile = props.getProperty('SPRING_PROFILES_ACTIVE')
def formFlowLibraryVersion = '1.6.2'
def useLocalLibrary = props.getProperty('USE_LOCAL_LIBRARY')
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator:3.4.1'
implementation 'ch.qos.logback.contrib:logback-json-classic:0.1.5'
implementation 'ch.qos.logback.contrib:logback-jackson:0.1.5'
implementation 'org.jobrunr:jobrunr-spring-boot-3-starter:7.3.2'
implementation 'org.apache.commons:commons-text:1.13.0'
implementation 'software.amazon.awssdk:s3:2.29.39'
if (useLocalLibrary == 'true') {
implementation fileTree(dir: "$rootDir/../form-flow/build/libs", include: '*.jar')
println "📦 Using local library"
} else {
implementation "org.codeforamerica.platform:form-flow:${formFlowLibraryVersion}"
println "📚Using form flow library ${formFlowLibraryVersion}"
}
compileOnly 'org.projectlombok:lombok:1.18.36'
developmentOnly 'org.springframework.boot:spring-boot-devtools:3.4.1'
annotationProcessor 'org.projectlombok:lombok:1.18.36'
testImplementation 'org.springframework.boot:spring-boot-starter-test:3.4.1'
testImplementation 'org.springframework.security:spring-security-test:6.4.2'
testImplementation 'org.seleniumhq.selenium:selenium-java:4.27.0'
testImplementation 'io.percy:percy-java-selenium:2.1.0'
testImplementation 'org.jsoup:jsoup:1.18.3'
testImplementation 'org.awaitility:awaitility:4.2.2'
testImplementation 'io.github.bonigarcia:webdrivermanager:5.9.2'
testImplementation 'com.h2database:h2:2.3.232'
testImplementation 'com.deque.html.axe-core:selenium:4.10.1'
testImplementation 'org.projectlombok:lombok:1.18.36'
testImplementation 'net.javacrumbs.json-unit:json-unit-assertj:4.1.0'
testAnnotationProcessor 'org.projectlombok:lombok'
testCompileOnly 'org.projectlombok:lombok'
runtimeOnly 'org.postgresql:postgresql:42.7.4'
}
springBoot {
buildInfo()
}
test {
finalizedBy jacocoTestReport
useJUnitPlatform()
}
jacocoTestReport {
reports {
xml.required = true
}
}
// -------------------------------------
// USWDS Tasks
// -------------------------------------
sass {
// Version of dart-sass: https://github.com/sass/dart-sass/releases
version = '1.69.3'
}
tasks.register('checkForNpm', Exec) {
group 'cfa-uswds'
description = 'Check if npm is accessible and install it if not.'
commandLine 'sh', './scripts/check_for_npm.sh'
}
tasks.register('npmInstall', Exec) {
group 'cfa-uswds'
description = 'Install frontend dependencies using npm.'
dependsOn 'checkForNpm'
commandLine 'npm', 'install'
}
tasks.register('moveNodeModulesToGenerated', Copy) {
group 'cfa-uswds'
description = 'Move Node Modules into Generated so that Spring Boot can use the assets.'
dependsOn 'npmInstall'
from 'node_modules'
into 'generated/main/resources/static'
finalizedBy(moveUSWDSImagesToGenerated)
}
tasks.register('moveUSWDSImagesToGenerated', Copy) {
group 'cfa-uswds'
description = 'Move USWDS images into generated folder for Spring Boot to use it.'
dependsOn 'moveNodeModulesToGenerated'
from 'node_modules/@uswds/uswds/dist/img'
into 'generated/main/resources/static/assets/css/img'
}
def sassConfiguration = { CompileSass task ->
// Load path
task.loadPath project.file("${projectDir}/generated/main/resources/static")
task.loadPath project.file("${projectDir}/generated/main/resources/static/@codeforamerica/uswds/packages")
task.loadPath project.file("${projectDir}/generated/main/resources/static/@uswds/uswds/packages")
// Set the output style:
// Possible values are “expanded” and “compressed”, default is “expanded”.
task.style = 'expanded'
// For now, do not load source maps
task.sourceMap = 'none'
// Source directory containing sass to compile:
task.sourceDir = project.file("${projectDir}/src/main/resources/static/assets/scss")
// Directory where to output generated CSS:
task.outputDir = project.file("${projectDir}/generated/main/resources/static/assets/css")
}
test {
useJUnitPlatform {
JUnitPlatformOptions options ->
options.excludeTags("a11y")
}
}
tasks.register("accessibilityTest", Test) {
Test task ->
task.useJUnitPlatform {
JUnitPlatformOptions options ->
options.includeTags 'a11y'
}
}
tasks.withType(Test).configureEach {
environment("SENTRY_DSN", "")
environment("MIXPANEL_API_KEY", "this-is-a-dummy-key-for-tests")
}
tasks.named('compileSass', CompileSass).configure { task ->
group 'cfa-uswds'
description = 'Compile Sass files into CSS.'
dependsOn 'moveNodeModulesToGenerated'
sassConfiguration(task)
}
tasks.register('compileJs', Exec) {
group 'cfa-uswds'
description = 'Compile CommonJS into JavaScript.'
dependsOn 'moveNodeModulesToGenerated'
commandLine 'npx', 'rollup', '--config', 'rollup.config.cjs'
}
tasks.register('watchCompileSass', CompileSass) { task ->
group 'cfa-uswds watch'
description = 'Infinite task to watch and recompile changes with SCSS.'
dependsOn installSass
sassConfiguration(task)
watch()
}
tasks.register('watchCompileJs', Exec) {
group 'cfa-uswds watch'
description = 'Infinite task to watch and recompile changes with JavaScript.'
dependsOn 'moveNodeModulesToGenerated'
commandLine 'npx', 'rollup', '--config', 'rollup.config.cjs', '--watch'
}
tasks.register('cleanGenerated') {
group 'cfa-uswds'
description = 'Delete the generated directory.'
doFirst {
delete "generated"
}
}
clean {
doFirst {
delete "generated"
delete "node_modules"
}
}
enum DesignSystem {
HONEYCRISP,
CFA_USWDS;
static DesignSystem fromString(String value) {
for (DesignSystem designSystem : values()) {
if (designSystem.name().replaceAll('_', '-').equalsIgnoreCase(value)) {
return designSystem
}
}
throw new IllegalArgumentException("Unknown design system: " + value)
}
}
def applicationYaml = file('src/main/resources/application.yaml')
def applicationProps = new Yaml().load(applicationYaml.text)
def designSystemNameString = applicationProps.get('form-flow')?.get('design-system')?.get('name')
def designSystem = DesignSystem.fromString(designSystemNameString ?: 'HONEYCRISP')
println "🎨 Using design system: $designSystem"
processResources {
if (designSystem == DesignSystem.CFA_USWDS) {
dependsOn compileSass
dependsOn compileJs
}
}
jar {
enabled false
}