-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
build.gradle
746 lines (665 loc) · 23.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
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
apply plugin: "war"
apply plugin: "com.google.cloud.tools.appengine-appyaml"
apply plugin: "checkstyle"
apply plugin: "pmd"
apply plugin: "com.github.spotbugs"
apply plugin: "jacoco"
apply plugin: "cz.habarta.typescript-generator"
apply plugin: "org.liquibase.gradle"
def checkstyleVersion = "10.15.0"
def pmdVersion = "7.0.0"
def spotbugsVersion = "4.8.4"
def jacocoVersion = "0.8.12"
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.google.cloud.tools:appengine-gradle-plugin:2.8.0"
classpath "com.github.spotbugs.snom:spotbugs-gradle-plugin:6.0.12"
classpath("cz.habarta.typescript-generator:typescript-generator-gradle-plugin:3.2.1263") {
exclude group: "org.gradle"
}
classpath "com.google.guava:guava:33.1.0-jre"
classpath "org.liquibase:liquibase-gradle-plugin:2.2.1"
}
}
configurations {
staticAnalysis
liquibaseRuntime.extendsFrom testImplementation
}
// See https://github.com/checkstyle/checkstyle/issues/14211#issuecomment-1884129948
configurations.all {
resolutionStrategy.capabilitiesResolution.withCapability("com.google.collections:google-collections") {
select("com.google.guava:guava:0")
}
}
repositories {
mavenCentral()
}
def objectify = "com.googlecode.objectify:objectify:6.0.7"
def testng = "org.testng:testng:7.10.1"
dependencies {
staticAnalysis("com.puppycrawl.tools:checkstyle:${checkstyleVersion}")
staticAnalysis("net.sourceforge.pmd:pmd-java:${pmdVersion}")
staticAnalysis("com.github.spotbugs:spotbugs:${spotbugsVersion}")
staticAnalysis("org.jacoco:org.jacoco.build:${jacocoVersion}")
annotationProcessor(objectify)
implementation("com.google.auth:google-auth-library-oauth2-http:1.23.0")
implementation(platform("com.google.cloud:google-cloud-bom:0.218.0"))
implementation("com.google.cloud:google-cloud-datastore")
implementation("com.google.cloud:google-cloud-tasks")
implementation("com.google.cloud:google-cloud-logging")
implementation("com.google.code.gson:gson:2.10.1")
implementation("com.google.firebase:firebase-admin:9.2.0")
implementation("com.google.guava:guava:33.1.0-jre")
implementation(objectify)
implementation("com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:20240325.1")
implementation("com.helger:ph-commons:9.5.5") // necessary to add SpotBugs suppression
implementation("com.mailjet:mailjet-client:5.2.5")
implementation("com.sendgrid:sendgrid-java:4.10.2")
implementation("com.sun.jersey:jersey-client:1.19.4")
implementation("com.sun.jersey:jersey-core:1.19.4")
implementation("com.sun.jersey.contribs:jersey-multipart:1.19.4")
implementation("org.apache.solr:solr-solrj:8.11.3")
implementation(platform("org.eclipse.jetty:jetty-bom:11.0.20"))
implementation("org.eclipse.jetty:jetty-slf4j-impl")
implementation("org.eclipse.jetty:jetty-server")
implementation("org.eclipse.jetty:jetty-webapp")
implementation("org.eclipse.jetty:jetty-annotations")
implementation("org.jsoup:jsoup:1.17.2")
implementation("org.hibernate.orm:hibernate-core:6.4.4.Final")
implementation("org.postgresql:postgresql:42.7.3")
implementation("org.hibernate:hibernate-hikaricp:6.4.4.Final")
testAnnotationProcessor(testng)
testImplementation("com.tngtech.archunit:archunit:0.11.0")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.2")
testImplementation("org.seleniumhq.selenium:selenium-java:4.19.1")
testImplementation("com.deque.html.axe-core:selenium:4.9.0")
testImplementation(testng)
testImplementation("org.testcontainers:postgresql:1.19.7")
testImplementation("org.liquibase:liquibase-core:4.27.0")
testImplementation("org.mockito:mockito-core:5.11.0")
// For supporting authorization code flow locally
testImplementation("com.google.oauth-client:google-oauth-client-jetty:1.35.0")
// For using Gmail API
testImplementation("com.google.apis:google-api-services-gmail:v1-rev20231218-2.0.0")
// For using JMeter APIs
testImplementation("org.apache.jmeter:ApacheJMeter_core:5.6.2") {
exclude group: "org.apache.jmeter", module: "bom"
}
testImplementation("org.apache.jmeter:ApacheJMeter_http:5.6.2") {
exclude group: "org.apache.jmeter", module: "bom"
}
liquibaseRuntime("info.picocli:picocli:4.7.5")
liquibaseRuntime(sourceSets.main.output)
}
sourceSets {
main {
java {
srcDir "src/main/java"
include "**/*.java"
}
resources {
srcDir "src/main/resources"
exclude "**/*.java"
}
}
test {
java {
srcDir "src/test/java"
srcDir "src/e2e/java"
srcDir "src/lnp/java"
srcDir "src/it/java"
srcDir "src/client/java"
include "**/*.java"
}
resources {
srcDir "src/test/resources"
srcDir "src/e2e/resources"
srcDir "src/lnp/resources"
srcDir "src/it/resources"
srcDir "src/client/resources"
exclude "**/*.java"
}
}
}
if (!project.hasProperty("runList")) {
project.ext.set("runList", "main")
}
liquibase {
activities {
main {
searchPath "${projectDir}"
changeLogFile "src/main/resources/db/changelog/db.changelog-root.xml"
url project.properties['liquibaseDbUrl']
username project.properties['liquibaseUsername']
password project.properties['liquibasePassword']
}
snapshot {
url project.properties['liquibaseDbUrl']
username project.properties['liquibaseUsername']
password project.properties['liquibasePassword']
snapshotFormat "json"
outputFile "liquibase-snapshot.json"
}
diffMain {
searchPath "${projectDir}"
changeLogFile "src/main/resources/db/changelog/db.changelog-new.xml"
referenceUrl project.properties['liquibaseDbUrl']
referenceUsername project.properties['liquibaseUsername']
referencePassword project.properties['liquibasePassword']
url "offline:postgresql?snapshot=liquibase-snapshot.json"
}
}
runList = project.ext.runList
}
tasks.withType(cz.habarta.typescript.generator.gradle.GenerateTask) {
jsonLibrary = "jackson2"
optionalAnnotations = [
"jakarta.annotation.Nullable"
]
outputFileType = "implementationFile"
outputKind = "module"
indentString = " "
jackson2Configuration = [
fieldVisibility: "ANY",
getterVisibility: "NONE",
isGetterVisibility: "NONE",
setterVisibility: "NONE",
creatorVisibility: "NONE",
]
mapEnum = "asEnum"
nonConstEnums = true
noFileComment = true
}
task generateApiOutputFormat(type: cz.habarta.typescript.generator.gradle.GenerateTask) {
classPatterns = [
"teammates.ui.output.**",
"teammates.common.datatransfer.questions.**",
"teammates.common.datatransfer.logs.**",
]
removeTypeNameSuffix = "Data"
outputFile = "src/web/types/api-output.ts"
excludeClassPatterns = [
"teammates.ui.output.**Builder"
]
excludeClasses = [
"teammates.ui.output.SessionResultsData\$NameInfo"
]
}
task generateApiRequestFormat(type: cz.habarta.typescript.generator.gradle.GenerateTask) {
classPatterns = [
"teammates.ui.request.**",
"teammates.common.util.EmailType"
]
excludeClasses = [
"teammates.ui.request.InvalidHttpRequestBodyException"
]
outputFile = "src/web/types/api-request.ts"
}
task generateApiConstants(type: cz.habarta.typescript.generator.gradle.GenerateTask) {
classPatterns = [
"teammates.ui.constants.**"
]
jsonLibrary = 'jackson2'
outputFile = "src/web/types/api-const.ts"
}
generateApiOutputFormat.dependsOn classes
generateApiRequestFormat.dependsOn classes
generateApiConstants.dependsOn classes
task generateTypes {
dependsOn generateApiOutputFormat
dependsOn generateApiRequestFormat
dependsOn generateApiConstants
}
task execScript(type: JavaExec) {
description "Run user defined scripts specified by project variable - userScript"
classpath = sourceSets.test.runtimeClasspath
if (project.hasProperty("userScript")) {
mainClass = "teammates.client.scripts.${project.property('userScript')}"
}
}
// SETUP TASKS
task createConfigs {
description "Sets up the project by obtaining necessary files and configurations points."
group "Setup"
doLast {
def templatesToCopy = [
"gradle.template.properties",
"src/main/resources/build.template.properties",
"src/main/resources/build-dev.template.properties",
"src/web/environments/config.template.ts",
"src/test/resources/test.template.properties",
"src/lnp/resources/test.template.properties",
"src/e2e/resources/test.template.properties",
"src/client/resources/client.template.properties",
"src/main/appengine/app.template.yaml"
]
templatesToCopy.findAll {
!(new File(it.replace(".template", ""))).exists()
}.each {
filename -> copy {
from filename
into filename.startsWith("src/") ? new File(filename).getParent() : "${projectDir}"
rename '(.*).template(.*)', '$1$2'
}
}
}
}
task downloadDependencies {
doFirst {
configurations.compileClasspath.resolve()
}
}
task downloadTestDependencies {
doFirst {
configurations.testCompileClasspath.resolve()
}
}
task downloadLinters {
doFirst {
configurations.staticAnalysis.resolve()
}
}
// RUN SERVER TASKS
compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8"
processResources {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
processTestResources {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
task explodeWar(type: Sync) {
dependsOn war
into "${buildDir}/exploded-teammates"
from project.zipTree(war.archiveFile)
outputs.upToDateWhen { false }
}
task copyDistToExplodedWar {
doLast {
copy {
from "src/web/dist"
into explodeWar.destinationDir
}
copy {
from "src/web/webtools"
into explodeWar.destinationDir
}
}
mustRunAfter explodeWar
}
task serverRun(type: JavaExec) {
classpath "${explodeWar.destinationDir}/WEB-INF/lib/*", "${explodeWar.destinationDir}/WEB-INF/classes/."
mainClass = "teammates.main.Application"
jvmArgs "-ea", "-Djava.util.logging.config.file=${explodeWar.destinationDir}/WEB-INF/logging-dev.properties",
"-Djava.time.zone.DefaultZoneRulesProvider=teammates.common.util.TzdbResourceZoneRulesProvider"
dependsOn explodeWar, copyDistToExplodedWar
}
task runDatastoreEmulator(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
mainClass = "teammates.storage.api.DatastoreEmulatorRunner"
}
appengine {
tools {
if (project.properties['cloud.sdk.home'] != null) {
cloudSdkHome = project.properties['cloud.sdk.home']
}
}
deploy {
String buildPropertiesPath = "${projectDir}/src/main/resources/build.properties"
boolean propsExists = new File(buildPropertiesPath).exists()
Properties props = new Properties()
if (propsExists) {
file(buildPropertiesPath).withReader {
props.load(it)
}
}
projectId = propsExists ? props['app.id'] : null
version = propsExists ? props['app.version'] : null
stopPreviousVersion = false
promote = false
}
}
task removeWarFromStagedApp {
doLast {
delete "${buildDir}/staged-app/${war.archiveFileName}"
}
}
task copyExplodedWarToStagedApp {
doLast {
copy {
from explodeWar.destinationDir
into "${buildDir}/staged-app"
}
}
}
task copyDistToStagedApp {
doLast {
copy {
from "src/web/dist"
into "${buildDir}/staged-app/dist"
}
}
}
appengineStage {
if (project.hasProperty("flex")) {
dependsOn explodeWar
finalizedBy removeWarFromStagedApp, copyExplodedWarToStagedApp, copyDistToStagedApp
} else {
dependsOn explodeWar, copyDistToExplodedWar
finalizedBy removeWarFromStagedApp, copyExplodedWarToStagedApp
}
}
// STATIC ANALYSIS TASKS
def isWindows = System.getProperty("os.name").toLowerCase().contains("windows")
checkstyle {
toolVersion = checkstyleVersion
configFile = file("static-analysis/teammates-checkstyle.xml")
configProperties = [
suppressions: file("static-analysis/teammates-checkstyle-suppressions.xml")
]
}
pmd {
toolVersion = pmdVersion
consoleOutput = true
ruleSetFiles = files("static-analysis/teammates-pmd.xml", "static-analysis/teammates-pmdMain.xml")
ruleSets = []
}
spotbugs {
reportLevel = com.github.spotbugs.snom.Confidence.valueOf("LOW")
toolVersion = spotbugsVersion
includeFilter = file("$rootProject.projectDir/static-analysis/teammates-spotbugs.xml")
}
tasks.withType(com.github.spotbugs.snom.SpotBugsTask) {
reports {
xml.required = false
html.required = false
text.required = true
}
}
spotbugsMain {
finalizedBy "printSpotbugsMainViolations"
}
task printSpotbugsMainViolations {
onlyIf {
file("${buildDir}/reports/spotbugs/main.txt").exists()
}
doFirst {
print new File("${buildDir}/reports/spotbugs/main.txt").getText("UTF-8")
}
}
spotbugsTest {
finalizedBy "printSpotbugsTestViolations"
}
task printSpotbugsTestViolations {
onlyIf {
file("${buildDir}/reports/spotbugs/test.txt").exists()
}
doFirst {
print new File("${buildDir}/reports/spotbugs/test.txt").getText("UTF-8")
}
}
task lintMain {
dependsOn checkstyleMain, pmdMain, spotbugsMain
}
task lintTest {
dependsOn checkstyleTest, pmdTest, spotbugsTest
}
import org.gradle.internal.serialize.PlaceholderException
def checkTestNgFailureClosure = { descriptor, result ->
if (result.exception instanceof PlaceholderException
&& result.exception.toString().startsWith("org.gradle.api.internal.tasks.testing.TestSuiteExecutionException")) {
result.exception.printStackTrace()
throw new GradleException("Detected TestNG failure")
}
}
// Displays full exception; to be run after the test fails after the last retry
def afterTestClosure = { descriptor, result ->
if (result.resultType == TestResult.ResultType.FAILURE && result.exception != null && result.exception.getMessage() != null) {
println ""
def msg = result.exception.getMessage()
def shouldDisplayAsDiff = msg.indexOf("<<[expected>") != -1
if (shouldDisplayAsDiff) {
def expectedFileName = "expected-${descriptor.getClassName()}"
def actualFileName = "actual-${descriptor.getClassName()}"
file("${expectedFileName}").text = msg[(msg.indexOf("<<[expected>") + 12)..(msg.indexOf("</expected]>>") - 1)]
file("${actualFileName}").text = msg[(msg.indexOf("<<[actual>") + 10)..(msg.indexOf("</actual]>>") - 1)]
def diffCommand = isWindows ? "FC" : "diff"
def process = "${diffCommand} ${expectedFileName} ${actualFileName}".execute()
println process.getText()
process.waitFor()
delete expectedFileName
delete actualFileName
} else {
println "${result.exception.getClass().getName()}: ${result.exception.getMessage()}"
}
for (StackTraceElement ste : result.exception.getStackTrace()) {
if (ste.getClassName().contains("NativeMethodAccessorImpl")) {
// Everything after this line is the internal workings of TestNG, not important for us
println "\t..."
break
}
println "\tat ${ste.getClassName()}.${ste.getMethodName()}(${ste.getFileName()}:${ste.getLineNumber()})"
}
}
}
task architectureTest(type: Test) {
useTestNG()
options.suites "src/test/resources/testng-architecture.xml"
options.useDefaultListeners = true
ignoreFailures false
maxHeapSize = "1g"
reports.html.required = false
reports.junitXml.required = false
jvmArgs "-Xss2m", "-Dfile.encoding=UTF-8"
afterTest afterTestClosure
afterSuite checkTestNgFailureClosure
testLogging {
events "passed"
}
}
architectureTest.dependsOn testClasses
architectureTest.shouldRunAfter lintMain, lintTest
task lint {
description "Runs the entire static analysis tasks for back-end."
group "Static analysis"
dependsOn lintMain, lintTest, architectureTest
}
// TEST TASKS
def numOfTestRetries = 4
task lnpTests(type: Test) {
systemProperty "random.testing.seed", new Random().nextInt() // re-run tests even if they are up-to-date
useTestNG()
options.suites "src/lnp/resources/testng-lnp.xml"
options.useDefaultListeners = true
ignoreFailures false
maxHeapSize = "1g"
reports.html.required = false
reports.junitXml.required = false
jvmArgs "-Xss2m", "-Dfile.encoding=UTF-8"
afterTest afterTestClosure
afterSuite checkTestNgFailureClosure
testLogging {
events "passed", "failed", "skipped"
}
// Display the L&P test results in the build
def outputCache = new LinkedList<String>()
beforeTest { TestDescriptor td -> outputCache.clear() } // clear output cache before the test starts
onOutput { TestDescriptor td, TestOutputEvent toe -> // put output in the cache
outputCache.add(toe.getMessage())
while (outputCache.size() > 2) outputCache.remove() // keep only last 2 result lines
}
afterTest { TestDescriptor td ->
if (outputCache.size() > 0) {
println(" L&P results for ${td.className}:")
outputCache.each { print(" > $it") }
}
}
}
task unitTests(type: Test) {
description "Runs the full unit test suite."
group "Test"
useTestNG()
options.suites "src/test/resources/testng-component.xml"
options.useDefaultListeners = true
ignoreFailures false
maxHeapSize = "1g"
reports.html.required = false
reports.junitXml.required = false
jvmArgs "-ea", "-Xss2m", "-Dfile.encoding=UTF-8"
afterTest afterTestClosure
afterSuite checkTestNgFailureClosure
testLogging {
events "passed"
}
}
task integrationTests(type: Test) {
description "Runs the full integration test suite."
group "Test"
useTestNG()
options.suites "src/it/resources/testng-it.xml"
options.useDefaultListeners = true
ignoreFailures false
maxHeapSize = "1g"
reports.html.required = false
reports.junitXml.required = false
jvmArgs "-ea", "-Xss2m", "-Dfile.encoding=UTF-8"
afterTest afterTestClosure
afterSuite checkTestNgFailureClosure
testLogging {
events "passed"
}
}
task componentTests(type: Test) {
description "Runs the full unit and integration test suite."
group "Test"
dependsOn unitTests, integrationTests
}
task e2eTests {
description "Runs the E2E test suite and retries failed test up to ${numOfTestRetries} times."
group "Test"
}
(1..numOfTestRetries + 1).each { id ->
def isFirstTry = id == 1
def isLastRetry = id == numOfTestRetries + 1
def runUnstableTests = project.hasProperty('unstable')
def outputFileName = runUnstableTests ? "e2e-unstable-test-try-" : "e2e-test-try-"
task "e2eTestTry${id}"(type: Test) {
useTestNG()
options.suites isFirstTry
? (runUnstableTests ? "src/e2e/resources/testng-unstable-e2e.xml" : "src/e2e/resources/testng-e2e.xml")
: file("${buildDir}/reports/${outputFileName}${id - 1}/testng-failed.xml")
options.outputDirectory = file("${buildDir}/reports/${outputFileName}${id}")
options.useDefaultListeners = true
ignoreFailures = !isLastRetry
maxHeapSize = "1g"
reports.html.required = false
reports.junitXml.required = false
jvmArgs "-Xss2m", "-Dfile.encoding=UTF-8"
testLogging {
events "passed"
}
afterTest afterTestClosure
if (isFirstTry) {
afterSuite checkTestNgFailureClosure
} else {
mustRunAfter "e2eTestTry${id - 1}"
}
onlyIf {
isFirstTry || file("${buildDir}/reports/${outputFileName}${id - 1}/testng-failed.xml").exists()
}
}
e2eTests.dependsOn "e2eTestTry${id}"
}
task e2eTestsSql {
description "Runs the E2E SQL test suite and retries failed test up to ${numOfTestRetries} times."
group "Test"
}
(1..numOfTestRetries + 1).each { id ->
def isFirstTry = id == 1
def isLastRetry = id == numOfTestRetries + 1
def runUnstableTests = project.hasProperty('unstable')
def outputFileName = runUnstableTests ? "e2e-sql-unstable-test-try-" : "e2e-sql-test-try-"
task "e2eSqlTestTry${id}"(type: Test) {
useTestNG()
options.suites isFirstTry
? (runUnstableTests ? "src/e2e/resources/testng-unstable-e2e-sql.xml" : "src/e2e/resources/testng-e2e-sql.xml")
: file("${buildDir}/reports/${outputFileName}${id - 1}/testng-failed.xml")
options.outputDirectory = file("${buildDir}/reports/${outputFileName}${id}")
options.useDefaultListeners = true
ignoreFailures = !isLastRetry
maxHeapSize = "1g"
reports.html.required = false
reports.junitXml.required = false
jvmArgs "-Xss2m", "-Dfile.encoding=UTF-8"
testLogging {
events "passed"
}
afterTest afterTestClosure
if (isFirstTry) {
afterSuite checkTestNgFailureClosure
} else {
mustRunAfter "e2eSqlTestTry${id - 1}"
}
onlyIf {
isFirstTry || file("${buildDir}/reports/${outputFileName}${id - 1}/testng-failed.xml").exists()
}
}
e2eTestsSql.dependsOn "e2eSqlTestTry${id}"
}
task axeTests {
description "Runs the full accessibility test suite and retries failed tests once."
group "Test"
}
(1..2).each { id ->
def isFirstTry = id == 1
task "axeTestTry${id}"(type: Test) {
useTestNG()
options.suites isFirstTry ? "src/e2e/resources/testng-axe.xml" : file("${buildDir}/reports/axe-test-try-${id - 1}/testng-failed.xml")
options.outputDirectory = file("${buildDir}/reports/axe-test-try-${id}")
options.useDefaultListeners = true
ignoreFailures = isFirstTry
maxHeapSize = "1g"
reports.html.required = false
reports.junitXml.required = false
jvmArgs "-Xss2m", "-Dfile.encoding=UTF-8"
testLogging {
events "passed"
}
afterTest afterTestClosure
if (isFirstTry) {
afterSuite checkTestNgFailureClosure
} else {
mustRunAfter "axeTestTry${id - 1}"
}
onlyIf {
isFirstTry || file("${buildDir}/reports/axe-test-try-${id - 1}/testng-failed.xml").exists()
}
}
axeTests.dependsOn "axeTestTry${id}"
}
// COVERAGE TASKS
jacoco {
toolVersion = jacocoVersion
}
task jacocoReport(type: JacocoReport) {
description "Runs coverage session from available test run data."
group "Test"
sourceDirectories.from files(sourceSets.main.java.srcDirs)
classDirectories.from files(sourceSets.main.output)
executionData fileTree("${buildDir}/jacoco").files
reports {
xml.required = true
html.required = true
}
afterEvaluate {
classDirectories.from files(classDirectories.files.collect {
fileTree(dir: it, exclude: ["**/*.jar"])
})
}
}