-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
843 lines (743 loc) · 29.5 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
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
/*
* Copyright 2011-2024 The OTP authors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import org.cyclonedx.gradle.CycloneDxTask
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion"
classpath "org.grails.plugins:hibernate5:8.1.0"
classpath 'org.grails.plugins:database-migration:4.2.1'
}
}
plugins {
id "com.github.monosoul.markdown.page.generator" version "2.4.0.0"
id "org.openapi.generator" version "7.6.0"
id "com.github.node-gradle.node" version "7.0.2"
// plugin to calculate coverage
id 'jacoco'
// plugin to convert the jacoco report in the the cobertura format, needed by gitlab.com
// https://github.com/razvn/jacoco-to-cobertura-gradle-plugin
id "net.razvan.jacoco-to-cobertura" version "1.2.0"
// plugin to show total jacoco coverage on the console
// https://gitlab.com/barfuin/gradle-jacoco-log
id 'org.barfuin.gradle.jacocolog' version '3.1.0'
// plugin to handle static resources like js or css
// http://www.asset-pipeline.com/manual/#getting-started
// http://www.asset-pipeline.com/manual/#configuration
// plugins for less / sass available
id "com.bertramlabs.asset-pipeline" version "4.4.0"
// allow to create SBOM dependencies list as xml & json for gradle
// https://cyclonedx.org/tool-center/
// https://plugins.gradle.org/plugin/org.cyclonedx.bom
id 'org.cyclonedx.bom' version '1.8.2'
}
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
if (System.getenv('PUBLISH_SCAN') == '1') {
publishAlways()
String commitId = 'git rev-parse --verify HEAD'.execute().text.trim()
String gitlabUrl = "https://gitlab.com/one-touch-pipeline/otp"
value 'Git Commit ID', commitId
buildScan.link 'Source', "$gitlabUrl/-/commit/$commitId"
buildScanPublished { scan ->
file("$buildDir/scan-journal.log") << "${new Date()} - ${scan.buildScanId} - ${scan.buildScanUri}\n"
}
}
}
group "de.dkfz.tbi"
apply plugin: 'java'
apply plugin: "idea"
apply plugin: "war"
apply plugin: "org.grails.grails-web"
apply plugin: "org.grails.grails-gsp"
apply plugin: "codenarc"
sourceCompatibility = 17
compileGroovy.groovyOptions.configurationScript = file('gradle/config/groovyc.groovy')
repositories {
mavenLocal()
mavenCentral()
maven { url "https://repo.grails.org/grails/core" }
maven { url "https://jitpack.io" }
}
sourceSets {
testHelper {
groovy {
srcDirs {
"src/test-helper/groovy"
}
}
compileClasspath += main.runtimeClasspath
}
test {
compileClasspath += sourceSets.testHelper.output
runtimeClasspath += sourceSets.testHelper.output
}
workflowTest {
groovy {
srcDirs {
"src/workflow-test/groovy"
}
}
compileClasspath += main.runtimeClasspath + testHelper.output
runtimeClasspath += main.runtimeClasspath + testHelper.output
File r = new File(project.projectDir, "grails-app/conf")
resources.srcDir(r)
}
main {
resources {
srcDirs 'migrations', "$buildDir/version"
}
}
script {
groovy {
srcDirs {
"scripts"
}
}
compileClasspath += main.runtimeClasspath
}
}
def generatedSourcesDir = "$buildDir/generated/openapi"
task generateWes(type: GenerateTask) {
generatorName = "java"
library = "webclient"
inputSpec = "${sourceSets.main.resources.srcDirs[0]}/wes-api/workflow_execution_service.swagger.yaml"
configFile = "${sourceSets.main.resources.srcDirs[0]}/wes-api/workflow_execution_service.swagger.config.json"
outputDir = generatedSourcesDir
configOptions = [
dateLibrary : "java17",
openApiNullable: "false"
]
}
task generateOpenApi(dependsOn: ['generateWes'])
compileJava.dependsOn tasks.generateOpenApi
processResources.dependsOn tasks.generateOpenApi
sourceSets.main.java.srcDir "${generatedSourcesDir}/src/main/java"
sourceSets.main.resources.srcDir "${generatedSourcesDir}/src/main/resources"
Closure filterCoverage = { classDirectories ->
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
"**/*Controller*",
"**/*Command*",
"*Visitor*",
"*Rule*",
"io/swagger/client/wes/**",
])
}))
}
jacocoTestReport {
dependsOn test // tests are required to run before generating the report
doLast {
println "Coverage unit report is created in file://${project.projectDir}/build/reports/jacoco/test/html/index.html"
}
afterEvaluate {
filterCoverage(classDirectories)
}
}
task jacocoIntegrationTestReport(type: JacocoReport) {
dependsOn integrationTest // tests are required to run before generating the report
group = LifecycleBasePlugin.VERIFICATION_GROUP
executionData integrationTest
sourceSets sourceSets.main
shouldRunAfter "jacocoTestReport"
reports {
html.outputLocation = layout.buildDirectory.dir('reports/jacoco/integrationTest')
}
afterEvaluate {
filterCoverage(classDirectories)
}
doLast {
println "Coverage integration report is created in file://${project.projectDir}/build/reports/jacoco/integrationTest/index.html"
}
}
task jacocoAllTestReport(type: JacocoReport) {
dependsOn test, integrationTest // tests are required to run before generating the report
executionData test, integrationTest
group = LifecycleBasePlugin.VERIFICATION_GROUP
sourceSets sourceSets.main
reports {
xml.required = true
xml.outputLocation = file('build/reports/jacoco/allTest/jacoco.xml')
html.outputLocation = layout.buildDirectory.dir('reports/jacoco/allTest')
}
afterEvaluate {
filterCoverage(classDirectories)
}
doLast {
println "Coverage unit & integration report is created in file://${project.projectDir}/build/reports/jacoco/allTest/index.html"
}
}
jacocoToCobertura {
dependsOn jacocoAllTestReport
splitByPackage.set(true)
inputFile.set(layout.buildDirectory.file("reports/jacoco/allTest/jacoco.xml"))
outputFile.set(layout.buildDirectory.file("reports/jacocoToCobertura/cobertura.xml"))
sourceDirectories.from(
layout.projectDirectory.dir("src/main/groovy"),
layout.projectDirectory.dir("grails-app/controllers"),
layout.projectDirectory.dir("grails-app/services"),
layout.projectDirectory.dir("grails-app/domain"),
layout.projectDirectory.dir("grails-app/init"),
)
doFirst {
// Workaround for parse error: Download JaCoCo DTD to working directory
// see https://github.com/razvn/jacoco-to-cobertura-gradle-plugin/issues/11
File workingDir = new File(".").getAbsoluteFile().getParentFile()
File file = new File(workingDir, 'report.dtd')
if (!file.exists()) {
println "Create file ${file} from class loader"
def jacocoClasspathUrls = jacocoTestReport.jacocoClasspath.collect { it.toURI().toURL() }
def classloader = new URLClassLoader(jacocoClasspathUrls as URL[])
file.withWriter {
it << classloader.getResourceAsStream('org/jacoco/report/xml/report.dtd')
}
}
}
}
test {
useJUnitPlatform()
finalizedBy jacocoTestReport // report is always generated after tests run
}
check {
// Check should run all Test tasks including the workflow tests for example.
dependsOn(tasks.withType(Test).toArray())
}
mergeTestReports {
// Problem with grails-gradle-plugin which let integrationTest get finalized by mergeTestReports which depend on all Tasks of type Test.
// Thus all Tests are run after running integrationTest, which should not happen.
dependsOn.clear()
}
integrationTest() {
testLogging.events = ["SKIPPED", "FAILED", "STANDARD_ERROR"]
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
useJUnitPlatform()
shouldRunAfter test
finalizedBy jacocoIntegrationTestReport // report is always generated after tests run
String databaseForIntegrationTest = System.getenv('USE_POSTGRES')
boolean usePostgresDockerCI = "DOCKER_CI".equalsIgnoreCase(databaseForIntegrationTest)
boolean usePostgresDocker = "TRUE".equalsIgnoreCase(databaseForIntegrationTest)
systemProperty "databaseForIntegrationTest", usePostgresDockerCI ? 'DOCKER_CI' : usePostgresDocker ? 'DOCKER' : 'H2'
if (usePostgresDockerCI) {
doFirst {
println "use postgres docker ci"
}
} else if (usePostgresDocker) {
List<String> dcs = []
doFirst {
println "use postgres docker"
// Where is docker-compose?
String docker = '/usr/bin/which docker'.execute()?.text?.trim()
if (!docker) {
throw new IllegalStateException('Unable to find docker. Is it installed and available via PATH?')
}
String dockerCompose = "${docker} compose"
List<String> dockerPorts = (0..maxParallelForks - 1).collect {
// Setup the project name for use by the Continuous Integration server the prevent race conditions.
String projectName = "--project-name otptest-build-${System.getenv('BUILD_NUMBER') ?: 'DEFAULT'}-w-${it}".toLowerCase()
// Construct command string
String dc = "${dockerCompose} ${projectName} --file docker/integration-test-database/docker-compose.yml"
println "command: ${dc}"
dcs << dc
//cleanup in case the container still exist
"${dc} stop".execute().waitFor()
"${dc} rm -f".execute().waitFor()
// Start a fresh container
Process dockerStart = "${dc} up -d".execute()
StringBuffer dockerStartStdout = new StringBuffer()
StringBuffer dockerStartStderr = new StringBuffer()
dockerStart.waitForProcessOutput(dockerStartStdout, dockerStartStderr)
if (dockerStart.exitValue() != 0) {
println "exitCode: ${dockerStart.exitValue()}"
println "stdout: ${dockerStartStdout}"
println "stderr: ${dockerStartStderr}"
throw new IllegalStateException('Unable to start new database container.')
}
// Get the (dynamically assigned local) port
Process dockerProcess = "${dc} port integration-test 5432".execute()
StringBuffer dockerProcessStdout = new StringBuffer()
StringBuffer dockerProcessStderr = new StringBuffer()
dockerProcess.waitForProcessOutput(dockerProcessStdout, dockerProcessStderr)
// If we do not get a reply in time or the return code indicates a failure, fail.
if (dockerProcess.exitValue() != 0) {
println "exitCode: ${dockerProcess.exitValue()}"
println "stdout: ${dockerProcessStdout}"
println "stderr: ${dockerProcessStderr}"
throw new IllegalStateException('Unable to get port information from Docker. Is the test database container running?')
}
String dockerPort = dockerProcessStdout.toString().split(':').last().trim() // should work for IPv6 also
return dockerPort
}
systemProperty "maxParallelForks", maxParallelForks
systemProperty "dockerPorts", dockerPorts.join(',')
println "postgres docker prepared"
}
doLast {
println "shutdown postgres docker"
// Stop and destroy the container
dcs.each { dc ->
"${dc} stop".execute().waitFor()
"${dc} rm -f".execute().waitFor()
}
}
} else {
doFirst {
println "use h2 database"
}
}
}
task workflowTest(type: Test) {
useJUnitPlatform()
testLogging.events = ["FAILED", "STANDARD_ERROR"]
testClassesDirs = sourceSets.workflowTest.output.classesDirs
classpath = sourceSets.workflowTest.runtimeClasspath
reports.html.enabled = true
testLogging.showStandardStreams = true
group = LifecycleBasePlugin.VERIFICATION_GROUP
shouldRunAfter "integrationTest"
systemProperty "grails.env", "WORKFLOW_TEST" // change to TEST??
}
tasks.withType(GroovyCompile).configureEach {
options.incremental = true
}
configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
all {
exclude group: 'org.webjars', module: 'popper.js' // exclude popper.js, since the correct version is already imported within bootstrap.bundle
}
}
dependencies {
// Grails Defaults
developmentOnly("org.springframework.boot:spring-boot-devtools")
console "org.grails:grails-console"
implementation "org.springframework.boot:spring-boot-starter-logging"
implementation "org.springframework.boot:spring-boot-starter-validation"
implementation "org.springframework.boot:spring-boot-autoconfigure"
implementation "org.grails:grails-core"
implementation "org.springframework.boot:spring-boot-starter-actuator"
implementation "org.springframework.boot:spring-boot-starter-tomcat"
implementation "org.grails:grails-web-boot"
implementation "org.grails:grails-logging"
implementation "org.grails:grails-plugin-rest"
implementation "org.grails:grails-plugin-databinding"
implementation "org.grails:grails-plugin-i18n"
implementation "org.grails:grails-plugin-services"
implementation "org.grails:grails-plugin-url-mappings"
implementation "org.grails:grails-plugin-interceptors"
implementation "org.grails.plugins:cache"
implementation "org.grails.plugins:async"
implementation "org.grails.plugins:scaffolding"
implementation "org.grails.plugins:events"
implementation "org.grails.plugins:hibernate5:8.1.0"
implementation "org.hibernate:hibernate-core:5.4.33.Final"
implementation "org.grails.plugins:gsp"
implementation "javax.mail:javax.mail-api:1.6.2"
profile "org.grails.profiles:web"
runtimeOnly "com.h2database:h2"
runtimeOnly "org.apache.tomcat:tomcat-jdbc"
runtimeOnly "javax.xml.bind:jaxb-api:2.3.1"
testImplementation "org.grails:grails-gorm-testing-support:3.2.2"
testImplementation "org.grails:grails-web-testing-support:3.2.2"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:5.10.2"
workflowTestImplementation "org.grails:grails-gorm-testing-support:3.2.2"
workflowTestImplementation "org.grails:grails-web-testing-support:3.2.2"
workflowTestRuntimeOnly "org.junit.vintage:junit-vintage-engine:5.10.2"
//assets
// needed for gradle bootRun
runtimeOnly "com.bertramlabs.plugins:asset-pipeline-grails:4.3.0"
runtimeOnly "com.bertramlabs.plugins:less-asset-pipeline:4.4.0"
runtimeOnly "com.bertramlabs.plugins:sass-asset-pipeline:4.4.0"
// needed for assetCompile
assets "com.bertramlabs.plugins:less-asset-pipeline:4.4.0"
//assets "com.bertramlabs.plugins:sass-asset-pipeline:4.4.0" // will fail the assertCompile task
// JDBC
runtimeOnly 'org.postgresql:postgresql:42.7.3'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.security:spring-security-core:5.8.13'
implementation 'org.springframework.security:spring-security-oauth2-jose:5.8.13'
implementation 'org.springframework.security:spring-security-config:5.8.13'
implementation 'org.springframework.security:spring-security-web:5.8.13'
implementation 'org.springframework.security:spring-security-ldap:5.8.13'
implementation 'org.springframework.security:spring-security-oauth2-client:5.8.13'
implementation "org.openapitools:openapi-generator-gradle-plugin:7.6.0"
integrationTestImplementation sourceSets.testHelper.output
integrationTestRuntimeOnly sourceSets.testHelper.output
implementation "org.jadira.usertype:usertype.core:7.0.0.CR1"
implementation "com.opencsv:opencsv:5.9"
implementation "org.grails:grails-async-gpars:5.0.0"
// bioinformatics tools
implementation "com.gitlab.one-touch-pipeline:bedutils:0.0.8"
implementation "com.github.samtools:htsjdk:4.1.1"
// library for interacting with cluster job schedulers
implementation('com.github.theroddywms:BatchEuphoria:0.1.4')
// libraries for SSH and SFTP
implementation 'com.github.mwiede:jsch:0.2.18'
implementation 'com.github.robtimus:sftp-fs:3.3.1'
// library for easy HTML editing
implementation 'org.jsoup:jsoup:1.17.2'
implementation 'com.networknt:json-schema-validator:1.4.0'
implementation "org.grails.plugins:grails-console:2.1.1"
implementation "org.grails.plugins:mail:4.0.0"
implementation("org.grails.plugins:database-migration:4.2.1") {
exclude group: "org.grails", module: "grails-shell"
}
implementation 'org.liquibase:liquibase-core:4.19.0'
implementation 'org.codenarc:CodeNarc:3.4.0'
// JS and CSS libraries
implementation 'org.webjars:jquery:3.7.1'
implementation 'org.webjars:bootstrap:5.3.3'
implementation 'org.webjars.npm:bootstrap-icons:1.11.3'
implementation 'org.webjars.npm:ttskch__select2-bootstrap4-theme:1.5.2'
implementation 'org.webjars:select2:4.0.13'
implementation 'org.webjars:datatables:1.13.5'
implementation 'org.webjars:datatables-buttons:2.4.1'
implementation 'org.webjars:datatables-fixedcolumns:3.2.2'
implementation 'org.webjars:datatables-fixedheader:3.2.4'
implementation 'org.webjars.bowergithub.datatables:dist-datatables-scroller:2.2.0'
implementation 'org.webjars:datatables-plugins:1.13.6'
implementation 'org.webjars.npm:corejs-typeahead:1.3.1'
implementation 'org.webjars.npm:chartjs-plugin-datalabels:2.2.0'
implementation 'org.webjars.npm:chart.js:4.4.3'
}
task buildInfo {
def separator = System.getProperty('line.separator')
def tags = "git tag --points-at HEAD".execute().text.trim()
def branch = "git branch --show-current".execute().text.trim()
def commitId = "git log --pretty=format:'%h' -n 1".execute().text.trim()
mkdir "$buildDir/version"
def file = new File("$buildDir/version/version.properties")
file.delete()
file << "git.tags=$tags$separator"
file << "git.branch=$branch$separator"
file << "git.commit.id.abbrev=$commitId$separator"
}
classes.dependsOn buildInfo
bootRun {
ignoreExitValue true
jvmArgs(
'-Dspring.output.ansi.enabled=always',
'-XX:TieredStopAtLevel=1')
sourceResources sourceSets.main
String springProfilesActive = 'spring.profiles.active'
systemProperty springProfilesActive, System.getProperty(springProfilesActive)
}
// required for bootRun on Windows
grails {
pathingJar = true
}
tasks.withType(Test) {
maxParallelForks = System.getenv('MAX_PARALLEL_FORKS')?.isInteger() ? System.getenv('MAX_PARALLEL_FORKS') as int : 1
jvmArgs('-Xms1g', '-Xmx4g')
testLogging {
exceptionFormat = TestExceptionFormat.FULL
afterSuite { desc, result ->
if (!desc.parent)
println("${result.resultType} " +
"(${result.testCount} tests, " +
"${result.successfulTestCount} passed, " +
"${result.failedTestCount} failed, " +
"${result.skippedTestCount} skipped)")
}
}
}
assets {
minifyJs = true
//minify css creates an css, which is ignored by the browser
minifyCss = false
//create js maps
enableSourceMaps = true
//use multi threading
maxThreads = 8
//only provide files with digest
skipNonDigests = true
minifyOptions = [
optimizationLevel: 'SIMPLE',
angularPass : true, // Can use @ngInject annotation for Angular Apps
languageMode : 'ES6',
targetLanguage : 'ES5',
excludes : [
// do not minify files from the webjars
// files included via `//= require` in own files will still processed
'webjars/**/*'
]
]
excludes = [
'**/chart.js/**/*',
'**/chartjs-plugin-datalabels/**/*',
'**/datatables-fixedcolumns/*/css/fixedColumns.bootstrap4.scss',
'**/ttskch__select2-bootstrap4-theme/**/*.scss',
'**/datatables-plugins/**/*',
// diverse file formats existing in webjars, but not needed to be delivered as assert
'webjars/**/license',
'webjars/**/LICENSE',
'webjars/**/*.html',
'webjars/**/*.iml',
'webjars/**/*.json',
'webjars/**/*.md',
'webjars/**/*.mjs',
'webjars/**/*.nuspec',
'webjars/**/*.properties',
'webjars/**/*.psd',
'webjars/**/*.ts',
'webjars/**/*.txt',
'webjars/**/*.xml',
'webjars/**/*.yml',
// use instead css or include it via `//= require`, since some scss make problems
'webjars/**/*.scss',
]
}
codenarc {
toolVersion = '3.4.0'
configFile file('grails-app/conf/CodeNarcRuleSet.groovy')
maxPriority1Violations = 0
maxPriority2Violations = 107
maxPriority3Violations = 1237
}
task showCodenarcHTMLFile(type: Exec) {
commandLine 'echo', "File can be found under: file://${project.projectDir}/build/reports/codenarc/all.html"
}
task codenarcAll(type: CodeNarc) {
mustRunAfter clean
finalizedBy showCodenarcHTMLFile
reports {
text.enabled = true
html.enabled = true
}
sourceSets.each { SourceSet s ->
if (s.name != "script") {
source(s.allGroovy.srcDirs)
}
}
group = LifecycleBasePlugin.VERIFICATION_GROUP
}
tasks.withType(GroovyCompile) {
configure(groovyOptions) {
forkOptions.jvmArgs += ['-Xmx4096m', '-Dgroovy.antlr4=false']
}
}
tasks.withType(CodeNarc) {
sourceSets.each { SourceSet s ->
if (s.name != "script") {
// required for ast transformations -> too many dependencies, because of this line we have to set groovy dependency explicitly
codenarcClasspath += s.runtimeClasspath
// too many dependencies for codenarc tasks except all
compilationClasspath += s.runtimeClasspath
}
}
}
war {
// The dependance on groovy pages was removed in a grails gradle plugin version
dependsOn compileGroovyPages
archiveName = 'otp.war'
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
enabled = true
}
/* Documentation Tasks */
task ensureDocsBuildDirs {
doLast {
mkdir "$buildDir/docs/users"
mkdir "$buildDir/docs/images"
}
}
task copyCss(type: Copy) {
from "docs/css"
into "$buildDir/docs/css"
}
task copyHtml(type: Copy) {
from "docs/html/"
into "$buildDir/docs"
}
generateHtml {
dependsOn(ensureDocsBuildDirs)
dependsOn(copyHtml)
dependsOn(copyCss)
pegdownExtensions = "TABLES, TOC"
ext.encoding = "UTF-8"
recursiveInput = true
inputEncoding = ext.encoding
outputEncoding = ext.encoding
inputDirectory = new File("docs/md")
outputDirectory = new File(buildDir, "docs")
transformRelativeMarkdownLinks = true
headerHtmlFile = new File("docs/support/header.html")
footerHtmlFile = new File("docs/support/footer.html")
}
node {
version = '16.19.0'
// version v18.20.1 and newer are not compatible with centos7
// version '17.9.1' is incompatible with many dependencies
download = true
}
task esLint(type: NpmTask) {
dependsOn npmInstall
args = ['run', 'lint']
}
task esLintExport(type: NpmTask) {
dependsOn npmInstall
args = ['run', 'lint-export']
}
task esLintExportCi(type: NpmTask) {
dependsOn npmInstall
environment = ['CI': 'true']
args = ['run', 'lint-export']
}
task esLintAutoFix(type: NpmTask) {
dependsOn npmInstall
environment = ['CI': 'true']
args = ['run', 'lint-fix']
}
task runCypressTests(type: NpmTask) {
def specProperty = project.hasProperty('spec') ? project.spec : System.getProperty('spec') ?: System.getenv('spec')
doFirst {
println "Make sure that OTP is running, the connection is configured via environment variable CYPRESS_BASE_URL and credentials are set in cypress.env.json"
}
dependsOn npmInstall
environment = ['CI': 'true']
args = ['run', 'cy-run']
if (specProperty) {
args.add("--")
args.add("--spec=${specProperty}")
}
}
task runCypressTestsInWindow(type: NpmTask) {
doFirst {
println "Make sure that OTP is running, the connection is configured via environment variable CYPRESS_BASE_URL and credentials are set in cypress.env.json"
}
dependsOn npmInstall
args = ['run', 'cy-open']
}
/**
* redefine output directory for the cyclonedx task
*/
cyclonedxBom {
destination = file("${project.buildDir}/reports/cyclonedx")
}
/**
* creates a list of all configurations with description.
* Its shown on the console and written to $buildDir/reports/list/configurations.txt
*/
task listConfigurations {
group = "reporting"
description = "List all configurations, as needed for discerning development and production configurations by the SBOM tasks."
doLast {
String path = "$buildDir/reports/list"
mkdir path
String list = configurations.collect { Configuration c ->
"${c.name}: ${c.description}\n".toString()
}.sort().join()
println list
new File(path, "configurations.txt").text = list
}
}
/**
* creates a list of all plugins.
* Its shown on the console and written to $buildDir/reports/list/plugins.txt
*/
task listPlugins {
group = "reporting"
description = "List all plugin"
doLast {
String path = "$buildDir/reports/list"
mkdir path
String list = project.plugins.collect {
"${it.class.name}\n".toString()
}.sort().join()
println list
new File(path, "plugins.txt").text = list
}
}
/**
* group task to run all single configuration software inventory task
*/
task runAllConfigsGradleBom() {
// a grouping task to execute the CycloneDxTask for each configuration
group = "reporting"
}
/**
* creates for each configuration a software inventory task and add it to the runAllConfigsGradleBom task
*/
rootProject.configurations.each {
String name = it.name
task "${name}Bom"(type: CycloneDxTask) {
group = "reporting"
destination = file("${project.buildDir}/reports/softwareInventory/gradle")
description = "Creates a CycloneDX SBOM for the configuration ${name}."
outputName = "${name}"
includeConfigs = [name]
schemaVersion = "1.5"
outputFormat = "json"
includeLicenseText = false
projectType = "application"
}
runAllConfigsGradleBom.dependsOn tasks.getByName("${name}Bom")
}
/**
* task to create a software inventory for all configurations in one list
*/
task allConfigsGradleBom(type: CycloneDxTask) {
group = "reporting"
destination = file("${project.buildDir}/reports/softwareInventory/gradleAll")
description = "Creates a CycloneDX SBOM for all configuration."
outputName = "all"
includeConfigs = configurations*.name
schemaVersion = "1.5"
outputFormat = "json"
includeLicenseText = false
projectType = "application"
}
/**
* create directory for the npm software inventory task
*/
task ensureCyclonedxNpmBomDirExist {
doLast {
mkdir "$buildDir/reports/softwareInventory/npm"
}
}
/**
* adapt the the npm software inventory task to depend it on ensureCyclonedxNpmBomDirExist
*/
tasks.named('npm_run_cyclonedx-npm') {
dependsOn tasks.ensureCyclonedxNpmBomDirExist
}
/**
* group task to execute the other software inventory tasks:
* - runAllConfigsGradleBom
* - allConfigsGradleBom
* - npm_run_cyclonedx-npm
*/
task allBom() {
// a grouping task to execute all task with bom
group = "reporting"
dependsOn tasks.runAllConfigsGradleBom
dependsOn tasks.allConfigsGradleBom
dependsOn tasks.named('npm_run_cyclonedx-npm')
}