forked from ls1intum/Artemis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
677 lines (573 loc) · 28.7 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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
import com.diffplug.spotless.FormatterFunc
import com.diffplug.spotless.FormatterStep
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import static com.diffplug.spotless.Formatter.NO_FILE_SENTINEL
plugins {
id "checkstyle"
id "java"
id "maven-publish"
id "idea"
id "jacoco"
id "org.springframework.boot" version "${spring_boot_version}"
id "io.spring.dependency-management" version "1.1.7"
id "com.google.cloud.tools.jib" version "3.4.4"
id "com.github.node-gradle.node" version "${gradle_node_plugin_version}"
id "com.diffplug.spotless" version "6.25.0"
// this allows us to find outdated dependencies via ./gradlew dependencyUpdates
id "com.github.ben-manes.versions" version "0.51.0"
id "com.github.andygoossens.modernizer" version "${modernizer_plugin_version}"
id "com.gorylenko.gradle-git-properties" version "2.4.2"
id "org.owasp.dependencycheck" version "11.1.1"
id "com.adarshr.test-logger" version "4.0.0"
}
group = "de.tum.cit.aet.artemis"
version = "7.8.1"
description = "Interactive Learning with Individual Feedback"
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
//this enables us to invoke ./gradlew liquibaseDiffChangelog
apply from: "gradle/liquibase.gradle"
if (project.hasProperty("prod")) {
apply from: "gradle/profile_prod.gradle"
} else {
apply from: "gradle/profile_dev.gradle"
}
if (project.hasProperty("war")) {
apply from: "gradle/war.gradle"
}
apply plugin: "jacoco"
idea {
module {
excludeDirs += files("node_modules")
}
}
spotless {
// allows to execute the code formatting commands ./gradlew spotlessApply and ./gradlew spotlessCheck
java {
target {
fileTree(rootDir) {
include (
"src/main/java/**/*.java",
"src/test/java/**/*.java",
)
exclude(
"**/src/test/resources/test-data/repository-export/EncodingISO_8559_1.java",
"**/node_modules/**",
"**/out/**",
"**/repos/**",
"**/repos-download/**",
"**/build/**",
"**/src/main/generated/**",
"**/src/main/resources/templates/**",
"/docker/**",
"checked-out-repos/**",
"supporting_scripts/**"
)
}
}
importOrderFile "artemis-spotless.importorder"
eclipse("4.33").configFile "artemis-spotless-style.xml"
removeUnusedImports()
trimTrailingWhitespace()
// Wildcard imports cannot be resolved by spotless itself.
// This will require the developer themselves to adhere to best practices.
addStep(FormatterStep.createNeverUpToDate("Refuse wildcard imports", new FormatterFunc() {
@Override
String apply(String s) throws Exception {
apply(s, NO_FILE_SENTINEL)
}
@Override
String apply(String s, File file) throws Exception {
if (s =~ /\nimport .*\*;/) {
throw new IllegalArgumentException("Do not use wildcard imports. spotlessApply cannot resolve this issue.\n" +
"The following file violates this rule: " + file.getName())
}
return s // Ensure a value is returned after processing
}
}))
}
}
defaultTasks "bootRun"
springBoot {
mainClass = "de.tum.cit.aet.artemis.ArtemisApp"
}
modernizer {
failOnViolations = false
includeTestClasses = true
// Copy the rule name as defined in https://github.com/gaul/modernizer-maven-plugin/blob/master/modernizer-maven-plugin/src/main/resources/modernizer.xml to exclude it
exclusions = ["java/util/Optional.get:()Ljava/lang/Object;"]
}
// Execute the test cases: ./gradlew test
// Execute only architecture tests: ./gradlew test -DincludeTags="ArchitectureTest"
test {
if (System.getProperty("includeTags")) {
useJUnitPlatform {
includeTags System.getProperty("includeTags")
}
} else {
useJUnitPlatform()
exclude "**/*IT*", "**/*IntTest*"
}
testLogging {
events "FAILED", "SKIPPED"
}
testLogging.showStandardStreams = true
reports.html.required = false
minHeapSize = "2g" // initial heap size
maxHeapSize = "8g" // maximum heap size
}
tasks.register("testReport", TestReport) {
destinationDirectory = layout.buildDirectory.file("reports/tests").get().asFile
testResults.from(test)
}
jacoco {
toolVersion = "0.8.12"
}
jar {
enabled = false
}
private excludedClassFilesForReport(classDirectories) {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it,
exclude: [
"**/de/tum/cit/aet/artemis/**/domain/**/*_*",
"**/de/tum/cit/aet/artemis/core/config/migration/entries/**",
"**/gradle-wrapper.jar/**"
]
)
}))
}
jacocoTestReport {
reports {
xml.required = true
}
// we want to ignore some generated files in the domain folders
afterEvaluate {
excludedClassFilesForReport(classDirectories)
}
}
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
counter = "INSTRUCTION"
value = "COVEREDRATIO"
// TODO: in the future the following value should become higher than 0.92
minimum = 0.892
}
limit {
counter = "CLASS"
value = "MISSEDCOUNT"
// TODO: in the future the following value should become less than 10
maximum = 65
}
}
}
// we want to ignore some generated files in the domain folders
afterEvaluate {
excludedClassFilesForReport(classDirectories)
}
}
check.dependsOn jacocoTestCoverageVerification
configurations {
providedRuntime
}
repositories {
mavenLocal()
mavenCentral()
// required for org.gradle:gradle-tooling-api dependency
maven {
url "https://repo.gradle.org/gradle/libs-releases"
}
// required for org.opensaml:* dependencies
maven {
url "https://build.shibboleth.net/maven/releases"
}
}
dependencies {
// Note: jenkins-client is not well maintained and includes dependencies to libraries with critical security issues (e.g. CVE-2020-10683 for [email protected])
// implementation "com.offbytwo.jenkins:jenkins-client:0.3.8"
implementation files("libs/jenkins-client-0.4.1.jar")
// The following 4 dependencies are explicitly integrated as transitive dependencies of jenkins-client-0.4.0.jar
implementation "org.apache.httpcomponents.client5:httpclient5:5.4.1"
implementation "org.apache.httpcomponents.core5:httpcore5:5.3.1"
implementation "org.apache.httpcomponents:httpmime:4.5.14"
implementation("org.dom4j:dom4j:2.1.4") {
// Note: avoid org.xml.sax.SAXNotRecognizedException: unrecognized feature http://xml.org/sax/features/external-general-entities
// also see https://github.com/dom4j/dom4j/issues/99
exclude module: "pull-parser"
exclude module: "jaxen"
exclude module: "xpp3"
exclude module: "xsdlib"
exclude module: "stax-api"
exclude module: "jaxb-api"
}
implementation "org.gitlab4j:gitlab4j-api:6.0.0-rc.7"
implementation "de.jplag:jplag:${jplag_version}"
implementation "de.jplag:c:${jplag_version}"
implementation "de.jplag:cpp:${jplag_version}"
implementation "de.jplag:csharp:${jplag_version}"
implementation "de.jplag:golang:${jplag_version}"
implementation "de.jplag:java:${jplag_version}"
implementation "de.jplag:javascript:${jplag_version}"
implementation "de.jplag:kotlin:${jplag_version}"
implementation "de.jplag:python-3:${jplag_version}"
implementation "de.jplag:rlang:${jplag_version}"
implementation "de.jplag:rust:${jplag_version}"
implementation "de.jplag:swift:${jplag_version}"
implementation "de.jplag:text:${jplag_version}"
implementation "de.jplag:typescript:${jplag_version}"
// those are transitive dependencies of JPlag Text --> Stanford NLP
// Note: ideally we would exclude them, but for some reason this does not work
implementation "org.apache.lucene:lucene-queryparser:${lucene_version}"
implementation "org.apache.lucene:lucene-core:${lucene_version}"
implementation "org.apache.lucene:lucene-analyzers-common:${lucene_version}"
implementation "com.google.protobuf:protobuf-java:4.29.2"
// we have to override those values to use the latest version
implementation "org.slf4j:jcl-over-slf4j:${slf4j_version}"
implementation "org.slf4j:jul-to-slf4j:${slf4j_version}"
implementation("org.slf4j:slf4j-api") {
version {
strictly "${slf4j_version}"
}
}
implementation "org.apache.logging.log4j:log4j-to-slf4j:2.24.3"
// Note: spring-security-lti13 does not work with jakarta yet, so we built our own custom version and declare its transitive dependencies below
// implementation "uk.ac.ox.ctl:spring-security-lti13:0.1.11"
implementation files("libs/spring-security-lti13-0.1.13.jar")
// https://search.maven.org/artifact/org.eclipse.jgit/org.eclipse.jgit
implementation "org.eclipse.jgit:org.eclipse.jgit:${jgit_version}"
implementation "org.eclipse.jgit:org.eclipse.jgit.ssh.apache:${jgit_version}"
// Note: jgit.htt.server is not compatible with jakarta yet and neither is there a timeline. Hence, we had to add the source files to our repository.
// Once the compatibility is given, we can switch back to the maven dependency.
implementation "org.eclipse.jgit:org.eclipse.jgit.http.server:${jgit_version}"
// apache ssh enabled the ssh git operations in LocalVC together with JGit
implementation "org.apache.sshd:sshd-core:${sshd_version}"
implementation "org.apache.sshd:sshd-git:${sshd_version}"
implementation "org.apache.sshd:sshd-osgi:${sshd_version}"
implementation "org.apache.sshd:sshd-sftp:${sshd_version}"
// https://mvnrepository.com/artifact/net.sourceforge.plantuml/plantuml
implementation "net.sourceforge.plantuml:plantuml:1.2024.8"
implementation "org.jasypt:jasypt:1.9.3"
implementation "me.xdrop:fuzzywuzzy:1.4.0"
implementation("org.yaml:snakeyaml") {
version {
strictly "2.3"
// needed to reduce the number of vulnerabilities, also see https://mvnrepository.com/artifact/org.yaml/snakeyaml
}
}
implementation "com.thoughtworks.qdox:qdox:2.2.0"
implementation "io.sentry:sentry-logback:${sentry_version}"
implementation "io.sentry:sentry-spring-boot-starter-jakarta:${sentry_version}"
// NOTE: the following six dependencies use the newer versions explicitly to avoid other dependencies to use older versions
implementation "ch.qos.logback:logback-classic:${logback_version}"
implementation "ch.qos.logback:logback-core:${logback_version}"
// required by eureka client
implementation "com.thoughtworks.xstream:xstream:1.4.21"
// required by JPlag
implementation "xerces:xercesImpl:2.12.2"
// required by JPlag
implementation "xalan:xalan:2.7.3"
// required by JPlag
implementation "xalan:serializer:2.7.3"
// required by Saml2
implementation "org.apache.santuario:xmlsec:4.0.3"
implementation "org.jsoup:jsoup:1.18.3"
implementation "commons-codec:commons-codec:1.17.1" // needed for spring security saml2
// use the latest version to avoid security vulnerabilities
implementation "org.springframework:spring-webmvc:${spring_framework_version}"
implementation "com.vdurmont:semver4j:3.1.0"
implementation "com.github.docker-java:docker-java-core:${docker_java_version}"
// Note: we explicitly use docker-java-transport-zerodep, because docker-java-transport-httpclient5 uses an outdated http5 version which is not compatible with Spring Boot >= 3.4.0
implementation "com.github.docker-java:docker-java-transport-zerodep:${docker_java_version}"
// use newest version of commons-compress to avoid security issues through outdated dependencies
implementation "org.apache.commons:commons-compress:1.27.1"
// import JHipster dependencies BOM
implementation platform("tech.jhipster:jhipster-dependencies:${jhipster_dependencies_version}")
implementation "tech.jhipster:jhipster-framework:${jhipster_dependencies_version}"
implementation "org.springframework.boot:spring-boot-starter-cache:${spring_boot_version}"
implementation "io.micrometer:micrometer-registry-prometheus:1.14.2"
implementation "net.logstash.logback:logstash-logback-encoder:8.0"
// Defines low-level streaming API, and includes JSON-specific implementations
implementation "com.fasterxml.jackson.core:jackson-core:${fasterxml_version}"
// Contains standard Jackson annotations
implementation "com.fasterxml.jackson.core:jackson-annotations:${fasterxml_version}"
// Implements data-binding (and object serialization) support
implementation "com.fasterxml.jackson.core:jackson-databind:${fasterxml_version}"
// Support for "Java 8 Dates"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${fasterxml_version}"
// Support JSON serialization and deserialization of Hibernate (https://hibernate.org) specific data types and properties; especially lazy-loading aspects
implementation "com.fasterxml.jackson.datatype:jackson-datatype-hibernate6:${fasterxml_version}"
// Support XML serialization and deserialization
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${fasterxml_version}"
// Support YML serialization and deserialization
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${fasterxml_version}"
implementation "com.hazelcast:hazelcast:${hazelcast_version}"
implementation "com.hazelcast:hazelcast-spring:${hazelcast_version}"
implementation "com.hazelcast:hazelcast-hibernate53:5.2.0"
implementation "javax.cache:cache-api:1.1.1"
implementation "org.hibernate.orm:hibernate-core:${hibernate_version}"
implementation "com.zaxxer:HikariCP:6.2.1"
implementation "org.apache.commons:commons-text:1.13.0"
implementation "org.apache.commons:commons-math3:3.6.1"
implementation "javax.transaction:javax.transaction-api:1.3"
implementation "org.liquibase:liquibase-core:${liquibase_version}"
implementation "org.springframework.boot:spring-boot-starter-validation:${spring_boot_version}"
implementation "org.springframework.boot:spring-boot-loader-tools:${spring_boot_version}"
implementation "org.springframework.boot:spring-boot-starter-mail:${spring_boot_version}"
implementation "org.springframework.boot:spring-boot-starter-logging:${spring_boot_version}"
implementation "org.springframework.boot:spring-boot-starter-actuator:${spring_boot_version}"
implementation "org.springframework.boot:spring-boot-starter-aop:${spring_boot_version}"
implementation "org.springframework.boot:spring-boot-starter-data-jpa:${spring_boot_version}"
implementation "org.springframework.boot:spring-boot-starter-security:${spring_boot_version}"
implementation("org.springframework.boot:spring-boot-starter-web:${spring_boot_version}") {
exclude module: "spring-boot-starter-undertow"
}
implementation "org.springframework.boot:spring-boot-starter-tomcat:${spring_boot_version}"
// Avoid security issues in Tomcat 10.1.33
implementation "org.apache.tomcat.embed:tomcat-embed-core:${tomcat_version}"
implementation "org.apache.tomcat.embed:tomcat-embed-el:${tomcat_version}"
implementation "org.apache.tomcat.embed:tomcat-embed-websocket:${tomcat_version}"
implementation "org.apache.tomcat:tomcat-annotations-api:${tomcat_version}"
implementation "org.springframework.boot:spring-boot-starter-websocket:${spring_boot_version}"
implementation "org.springframework.boot:spring-boot-starter-thymeleaf:${spring_boot_version}"
implementation "org.springframework.boot:spring-boot-starter-oauth2-resource-server:${spring_boot_version}"
implementation "org.springframework.boot:spring-boot-starter-oauth2-client:${spring_boot_version}"
implementation "org.springframework.ldap:spring-ldap-core:3.2.10"
implementation "org.springframework.data:spring-data-ldap:3.4.1"
implementation("org.springframework.cloud:spring-cloud-starter-netflix-eureka-client:${spring_cloud_version}") {
// NOTE: these modules contain security vulnerabilities and are not needed
exclude module: "commons-jxpath"
exclude module: "woodstox-core"
}
implementation "org.springframework.cloud:spring-cloud-starter-config:${spring_cloud_version}"
implementation "org.springframework.cloud:spring-cloud-commons:${spring_cloud_version}"
implementation "io.netty:netty-all:4.1.116.Final"
implementation "io.projectreactor.netty:reactor-netty:1.2.1"
implementation "org.springframework:spring-messaging:${spring_framework_version}"
implementation "org.springframework.retry:spring-retry:2.0.11"
implementation "org.springframework.security:spring-security-config:${spring_security_version}"
implementation "org.springframework.security:spring-security-data:${spring_security_version}"
implementation "org.springframework.security:spring-security-core:${spring_security_version}"
implementation "org.springframework.security:spring-security-oauth2-core:${spring_security_version}"
implementation "org.springframework.security:spring-security-oauth2-client:${spring_security_version}"
// use newest version of nimbus-jose-jwt to avoid security issues through outdated dependencies
implementation "com.nimbusds:nimbus-jose-jwt:9.48"
implementation "org.springframework.security:spring-security-oauth2-jose:${spring_security_version}"
implementation "org.springframework.security:spring-security-crypto:${spring_security_version}"
implementation "org.springframework.security:spring-security-web:${spring_security_version}"
implementation "org.springframework.security:spring-security-messaging:${spring_security_version}"
implementation "org.springframework.security:spring-security-ldap:${spring_security_version}"
implementation "org.springframework.security:spring-security-saml2-service-provider:${spring_security_version}"
implementation "org.opensaml:opensaml-security-api:${opensaml_version}"
implementation "org.opensaml:opensaml-core:${opensaml_version}"
implementation "org.opensaml:opensaml-saml-impl:${opensaml_version}"
implementation "org.opensaml:opensaml-saml-api:${opensaml_version}"
implementation "io.jsonwebtoken:jjwt-api:${jwt_version}"
runtimeOnly "io.jsonwebtoken:jjwt-impl:${jwt_version}"
runtimeOnly "io.jsonwebtoken:jjwt-jackson:${jwt_version}"
implementation "org.bouncycastle:bcpkix-jdk18on:1.79"
implementation "org.bouncycastle:bcprov-jdk18on:1.79"
implementation "com.mysql:mysql-connector-j:9.1.0"
implementation "org.postgresql:postgresql:42.7.4"
implementation "org.zalando:problem-spring-web:0.29.1"
implementation "org.zalando:jackson-datatype-problem:0.27.1"
implementation "com.ibm.icu:icu4j-charset:76.1"
implementation "com.github.seancfoley:ipaddress:5.5.1"
implementation "org.apache.maven:maven-model:3.9.9"
implementation "org.apache.pdfbox:pdfbox:3.0.3"
implementation "org.apache.commons:commons-csv:1.12.0"
implementation "org.commonmark:commonmark:0.24.0"
implementation "commons-fileupload:commons-fileupload:1.5"
implementation "net.lingala.zip4j:zip4j:2.11.5"
implementation "org.jgrapht:jgrapht-core:1.5.2"
// use the latest version explicitly to avoid security vulnerabilities (currently Artemis and JPlag rely on jgrapht 1.5.2 which relies on apfloat)
implementation "org.apfloat:apfloat:1.14.0"
// use newest version of guava to avoid security issues through outdated dependencies
implementation "com.google.guava:guava:33.4.0-jre"
implementation "com.sun.activation:jakarta.activation:2.0.1"
// use newest version of gson to avoid security issues through outdated dependencies
implementation "com.google.code.gson:gson:2.11.0"
implementation "com.google.errorprone:error_prone_annotations:2.36.0"
// NOTE: we want to keep the same unique version for all configurations, implementation and annotationProcessor
implementation("net.bytebuddy:byte-buddy") {
version {
strictly byte_buddy_version
}
}
annotationProcessor("net.bytebuddy:byte-buddy") {
version {
strictly byte_buddy_version
}
}
liquibase("net.bytebuddy:byte-buddy") {
version {
strictly byte_buddy_version
}
}
implementation("net.bytebuddy:byte-buddy-agent") {
version {
strictly byte_buddy_version
}
}
annotationProcessor("net.bytebuddy:byte-buddy-agent") {
version {
strictly byte_buddy_version
}
}
liquibase("net.bytebuddy:byte-buddy-agent") {
version {
strictly byte_buddy_version
}
}
annotationProcessor "org.hibernate:hibernate-jpamodelgen:${hibernate_version}"
annotationProcessor("org.glassfish.jaxb:jaxb-runtime:${jaxb_runtime_version}") {
exclude group: "jakarta.ws.rs", module: "jsr311-api"
}
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor:${spring_boot_version}") {
exclude group: "com.vaadin.external.google", module: "android-json"
}
// ---- CHECKSTYLE DEPENDENCIES ----
// use newest version of plexus to avoid security issues through outdated dependencies
checkstyle "org.codehaus.plexus:plexus-container-default:2.1.1"
checkstyle "org.codehaus.plexus:plexus-classworlds:2.8.0"
checkstyle "com.puppycrawl.tools:checkstyle:${checkstyle_version}"
// ---- TEST DEPENDENCIES ----
testImplementation("org.springframework.boot:spring-boot-starter-test:${spring_boot_version}") {
exclude group: "org.junit.vintage", module: "junit-vintage-engine"
exclude group: "com.vaadin.external.google", module: "android-json"
exclude group: "org.xmlunit", module: "xmlunit-core"
}
testImplementation "org.springframework.security:spring-security-test:${spring_security_version}"
testImplementation "org.springframework.boot:spring-boot-test:${spring_boot_version}"
testImplementation "org.assertj:assertj-core:3.27.0"
testImplementation "org.mockito:mockito-core:${mockito_version}"
testImplementation "org.mockito:mockito-junit-jupiter:${mockito_version}"
testImplementation "io.github.classgraph:classgraph:4.8.179"
testImplementation "org.awaitility:awaitility:4.2.2"
testImplementation "org.apache.maven.shared:maven-invoker:3.3.0"
testImplementation "org.gradle:gradle-tooling-api:8.12"
testImplementation "org.apache.maven.surefire:surefire-report-parser:3.5.2"
testImplementation "com.opencsv:opencsv:5.9"
testImplementation("io.zonky.test:embedded-database-spring-test:2.6.0") {
exclude group: "org.testcontainers", module: "mariadb"
exclude group: "org.testcontainers", module: "mssqlserver"
}
testImplementation "com.tngtech.archunit:archunit:1.3.0"
testImplementation("org.skyscreamer:jsonassert:1.5.3") {
exclude module: "android-json"
}
// NOTE: cannot update due to "Syntax error in SQL statement "WITH ids_to_delete" --> should be resolved when we collapse the changelogs again for Artemis 8.0
// testImplementation "com.h2database:h2:2.3.232"
testImplementation "com.h2database:h2:2.2.224"
// Lightweight JSON library needed for the internals of the MockRestServiceServer
testImplementation "org.json:json:20240303"
// NOTE: make sure this corresponds to the version used for JUnit in the testImplementation
testRuntimeOnly "org.junit.platform:junit-platform-launcher:${junit_platform_version}"
}
dependencyManagement {
imports {
mavenBom "io.zonky.test.postgres:embedded-postgres-binaries-bom:17.2.0"
}
}
tasks.register("cleanResources", Delete) {
delete "build/resources"
}
tasks.withType(JavaCompile).configureEach {
options.compilerArgs << "-Xlint:deprecation"
}
// Taken from here: https://stackoverflow.com/questions/3963708/gradle-how-to-display-test-results-in-the-console-in-real-time
tasks.withType(Test).configureEach {
// a collection to track failedTests
ext.failedTests = []
testLogging {
// set options for log level LIFECYCLE
events TestLogEvent.FAILED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED
exceptionFormat TestExceptionFormat.FULL
showExceptions true
showCauses true
showStackTraces true
info.events = debug.events
info.exceptionFormat = debug.exceptionFormat
}
afterTest { descriptor, result ->
if (result.resultType == TestResult.ResultType.FAILURE) {
var failedTest = "${descriptor.className}::${descriptor.name}"
logger.debug("Adding " + failedTest + " to failedTests...")
failedTests << [failedTest]
}
}
afterSuite { suite, result ->
if (!suite.parent) { // will match the outermost suite
def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
def startItem = "| ", endItem = " |"
def repeatLength = startItem.length() + output.length() + endItem.length()
println("\n" + ("-" * repeatLength) + "\n" + startItem + output + endItem + "\n" + ("-" * repeatLength))
// logs each failed test
if (!failedTests.empty) {
logger.lifecycle("Failed tests:")
failedTests.each { failedTest ->
println("${failedTest}")
}
}
}
}
}
wrapper {
gradleVersion = "8.12"
}
tasks.register("stage") {
dependsOn "bootWar"
}
node {
download = true
version = "${node_version}"
npmVersion = "${npm_version}"
}
// Set the npm cache (used in the Dockerfile)
tasks.register("npmSetCacheDockerfile", NpmTask) {
args = ["set", "cache", "/opt/artemis/.npm"]
}
// Command to execute the JavaDoc checkstyle verification ./gradlew checkstyleMain
checkstyle {
toolVersion "${checkstyle_version}"
configFile file("checkstyle.xml")
checkstyleTest.enabled = false
maxErrors = 0
}
def isNonStable = { String version ->
def stableKeyword = ["RELEASE", "FINAL", "GA"].any { it -> version.toUpperCase().contains(it) }
def regex = /^[0-9,.v-]+(-r)?$/
return !stableKeyword && !(version ==~ regex)
}
tasks.named("dependencyUpdates").configure {
rejectVersionIf {
isNonStable(it.candidate.version)
}
rejectVersionIf {
isNonStable(it.candidate.version) && !isNonStable(it.currentVersion)
}
}
// Available commands:
//
// 1) Build production: ./gradlew -Pprod -Pwar clean bootWar
// 2) Execute tests with coverage report: ./gradlew test jacocoTestReport -x webapp
// 2a) Execute tests without coverage report: ./gradlew test -x webapp
// 2b) Run a single test: ./gradlew test --tests ExamIntegrationTest -x webapp or ./gradlew test --tests ExamIntegrationTest.testGetExamScore -x webapp
// 2c) Execute tests with Postgres container: SPRING_PROFILES_INCLUDE=postgres ./gradlew test -x webapp
// 2d) Execute tests with MySQL container: SPRING_PROFILES_INCLUDE=mysql ./gradlew test -x webapp
// 3) Verify code coverage (after tests): ./gradlew jacocoTestCoverageVerification
// 4) Check Java code format: ./gradlew spotlessCheck -x webapp
// 5) Apply Java code formatter: ./gradlew spotlessApply -x webapp
// 6) Find dependency updates: ./gradlew dependencyUpdates -Drevision=release
// 7) Check JavaDoc: ./gradlew checkstyleMain -x webapp
// 8) Detects uses of legacy code: ./gradlew modernizer -x webapp
// 9) Check for vulnerabilities in dependencies ./gradlew dependencyCheckAnalyze -x webapp
// 10) Clear Liquibase checksums: ./gradlew liquibaseClearChecksums
// 11) Create changelog between Java and DB ./gradlew liquibaseDiffChangeLog (make sure to set the correct username and password in liquibase.gradle)
// 12) Generate initial schema from DB ./gradlew liquibaseGenerateChangelog (make sure to set the correct username and password in liquibase.gradle)