forked from thesaurus-linguae-aegyptiae/tla-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
317 lines (281 loc) · 9.18 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
plugins {
id 'war'
id 'java'
id 'jacoco'
id 'application'
id 'maven-publish'
id 'de.undercouch.download' version '5.6.0'
id 'com.adarshr.test-logger' version '4.0.0'
id 'org.springframework.boot' version '3.4.1'
id 'com.github.ben-manes.versions' version '0.51.0'
id 'com.github.dawnwords.jacoco.badge' version '0.2.4'
}
group = 'org.bbaw.aaew.tla'
version = '0.0.827-dev'
sourceCompatibility = '17'
ext {
fontawesomeVersion = '5.12.1'
bootstrapVersion = '4.6.0'
jqueryVersion = '3.6.4'
cookieJsVersion = '2.2.1'
cookieBannerVersion = '1.2.2'
fontawesomeSrc = "https://use.fontawesome.com/releases/v${fontawesomeVersion}/fontawesome-free-${fontawesomeVersion}-web.zip"
bootstrapSrc = "https://github.com/twbs/bootstrap/releases/download/v${bootstrapVersion}/bootstrap-${bootstrapVersion}-dist.zip"
jquerySrc = "https://code.jquery.com/jquery-${jqueryVersion}.min.js"
cookieJsSrc = "https://github.com/js-cookie/js-cookie/releases/download/v${cookieJsVersion}/js.cookie-${cookieJsVersion}.min.js"
cookieBannerSrc = "https://cdn.jsdelivr.net/gh/dobarkod/cookie-banner@${cookieBannerVersion}/dist/cookiebanner.min.js"
staticDir = 'src/main/resources/static'
vendorDir = "${staticDir}/vendor"
}
def assets = [
'cookieJs': [cookieJsSrc, 'js.cookie.min.js'],
'cookieBanner': [cookieBannerSrc, 'cookiebanner.min.js'],
'jquery': [jquerySrc, 'jquery.min.js'],
'headroomJs': ['https://unpkg.com/headroom.js@0.12.0/dist/headroom.min.js', 'headroom.min.js']
]
def frameworks = [
'bootstrap': [bootstrapSrc, "${staticDir}/vendor/bootstrap-${bootstrapVersion}-dist"],
'fontawesome': [fontawesomeSrc, "${staticDir}/vendor/fontawesome-free-${fontawesomeVersion}-web"]
]
publishing {
publications {
maven(MavenPublication) {
artifactId = 'tla-web'
pom {
name = 'TLA Web Frontend'
description = 'HTML frontend for the Thesaurus Linguae Aegyptiae web component'
}
from components.java
}
}
}
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url 'https://repo.spring.io/milestone' }
}
dependencies {
compileOnly 'org.projectlombok:lombok:1.18.36'
annotationProcessor 'org.projectlombok:lombok:1.18.36'
testCompileOnly 'org.projectlombok:lombok:1.18.36'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.36'
implementation 'org.modelmapper:modelmapper:3.2.2'
implementation 'org.jooq:jool:0.9.15'
implementation('org.springframework.boot:spring-boot-starter-jetty:3.4.1') {
exclude module: 'jetty-xml'
}
implementation('org.springframework.boot:spring-boot-starter-web:3.4.1') {
exclude module: 'spring-boot-starter-tomcat'
}
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf:3.4.1'
implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:3.3.0'
implementation 'org.apache.commons:commons-lang3:3.17.0'
implementation 'com.github.jkatzwinkel:tla-common:main-SNAPSHOT'
implementation('com.github.rosmord.jsesh:jsesh:release-7.6.1') {
exclude group: 'com.jgoodies', module: 'forms'
exclude group: 'com.lowagie', module: 'itext'
exclude group: 'bouncycastle'
}
testImplementation 'org.springframework.boot:spring-boot-starter-test:3.4.1'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.11.3'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.11.3'
}
task installAssets {
description = 'Download and install third-party JS/CSS frameworks and libraries'
dependsOn 'installFontRoboto'
outputs.files(
file("${vendorDir}/")
)
}
task updateAssets {
group = 'Init'
description = 'Removes and re-installs third-party ressources added with :installAssets.'
dependsOn 'cleanAssets'
dependsOn 'installAssets'
}
def createDownloadAssetTask(String name, String url, String destFile) {
return tasks.create("download${name.capitalize()}", Download) {
doFirst {
mkdir "${staticDir}/vendor"
}
description = "Download && install ${name}"
src "${url}"
dest file("${staticDir}/vendor/${destFile}")
onlyIfModified true
}
}
assets.each {
var task = createDownloadAssetTask(
it.key, it.value[0], it.value[1]
)
installAssets.dependsOn task
processResources.mustRunAfter task
}
frameworks.each {
var task = createInstallFrameworkTask(
it.key, it.value[0], it.value[1]
)
installAssets.dependsOn task
processResources.mustRunAfter task
}
task downloadFontRoboto(type: Download) {
group = 'Init'
description = 'Download Google Roboto font'
src 'https://gwfh.mranftl.com/api/fonts/roboto?download=zip&subsets=latin&variants=300,500,700,300italic,regular,italic,700italic&formats=woff2'
dest new File(buildDir, 'roboto.zip')
onlyIfModified true
}
def downloadFrameworkTask(String name, String url) {
return tasks.create("download${name.capitalize()}", Download) {
description = "Downloads ${name.capitalize()} distrubution into build directory."
src "${url}"
dest new File(buildDir, "${name}.zip")
onlyIfModified true
outputs.files(
new File(buildDir, "${name}.zip")
)
}
}
def createInstallFrameworkTask(String name, String url, String dir) {
return tasks.create("install${name.capitalize()}", Copy) {
inputs.files(
new File(buildDir, "${name}.zip")
)
group = 'Init'
description = "Installs ${name.capitalize()} distribution into assets directory."
dependsOn downloadFrameworkTask(name, url)
doFirst {
mkdir "${vendorDir}"
}
if (!file("${vendorDir}/${name}").exists()) {
from zipTree(
new File(buildDir, "${name}.zip")
)
into file("${vendorDir}")
doLast {
file("${dir}").renameTo(
file("${vendorDir}/${name}")
)
}
}
outputs.files(
file("${vendorDir}/${name}")
)
}
}
task installFontRoboto(dependsOn: downloadFontRoboto, type: Copy) {
group = 'Init'
description = 'Installs Google Roboto font'
from zipTree(downloadFontRoboto.dest)
into file("${staticDir}/font")
}
def checkStylesheetFileReference(String styleSheet, String ref) {
if (!new File(staticDir, ref).exists()) {
println """ \
file ${ref} referenced in CSS stylesheet could not be found. Actual contents of fonts dir:
""".stripIndent()
file("${staticDir}/font/").eachFile {
file -> println " ${file.name}"
}
throw new GradleException(
"""\
@font-face src out of date: CSS file ${styleSheet} points to missing resource ${staticDir}/${ref}!
Fix the issue by updating this reference before running again!
""".stripIndent()
)
}
}
task validateWebFontImports() {
dependsOn 'installFontRoboto'
group = 'Init'
description = 'Check stylesheet loading font files for dead references'
doFirst {
def stylesheet = 'src/main/resources/static/css/roboto.css'
(
file(stylesheet).text =~ /font\/\S*\.(eot|woff2?|ttf|svg)/
).findAll()*.first().each {
ref -> checkStylesheetFileReference(stylesheet, ref)
}
}
}
task install {
inputs.files(
file('.env')
)
group = 'Init'
description = 'Installs additional resources required for running the app'
dependsOn 'installAssets'
outputs.files(
file("${staticDir}/vendor/")
)
finalizedBy 'validateWebFontImports'
}
task cleanAssets(type: Delete) {
group = 'Init'
description = 'Delete files added with :installAssets'
dependsOn 'cleanInstallAssets'
frameworks.each {
entry -> cleanAssets.dependsOn "cleanDownload${entry.key.capitalize()}"
}
delete "${staticDir}/vendor/"
delete fileTree("${staticDir}/font") {
include "roboto*"
}
}
clean {
dependsOn 'cleanInstall'
}
processResources {
mustRunAfter 'installFontRoboto'
mustRunAfter 'installAssets'
}
springBoot {
buildInfo()
}
bootJar {
dependsOn 'install'
}
def installationReminder() {
if ( !file("${staticDir}/vendor/").exists() ) {
println ' ======================================'
println ' !!! Must run task :install first: !!!'
println ' !!! !!!'
println ' !!! ./gradlew.bat install !!!'
println ' ======================================'
throw new StopExecutionException()
}
}
bootRun {
systemProperty 'spring.profiles.active', 'dev'
doFirst {
installationReminder()
}
}
application {
mainClass = 'tla.web.App'
}
tasks.named("dependencyUpdates").configure {
rejectVersionIf {
it.candidate.group == 'com.github.rosmord.jsesh' && it.candidate.version == '7.3.1'
}
}
test {
useJUnitPlatform()
finalizedBy 'jacocoTestReport'
}
testlogger {
theme 'mocha'
slowThreshold 1500
showStandardStreams false
showFullStackTraces true
}
jacocoTestReport {
reports {
xml.required.set(true)
html.required.set(true)
}
finalizedBy 'generateJacocoBadge'
}
tasks.withType(JavaCompile) {
options.deprecation = true
}