forked from junit-team/junit5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
816 lines (703 loc) · 22.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
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
import java.time.OffsetDateTime
import java.time.format.DateTimeFormatter
buildscript {
repositories {
// mavenLocal()
maven { url 'https://plugins.gradle.org/m2/' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
dependencies {
classpath('com.diffplug.spotless:spotless-plugin-gradle:3.8.0')
classpath('com.github.ben-manes:gradle-versions-plugin:0.17.0')
classpath('org.ajoberstar:gradle-git-publish:0.3.2')
classpath('org.ajoberstar:gradle-git:1.7.2')
classpath('org.junit.platform:junit-platform-gradle-plugin:1.0.1')
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
}
}
plugins {
id 'com.gradle.build-scan' version '1.11'
id 'net.nemerosa.versioning' version '2.6.1'
}
buildScan {
licenseAgreementUrl = 'https://gradle.com/terms-of-service'
licenseAgree = 'yes'
}
def buildTimeAndDate = OffsetDateTime.now()
ext {
// Generate JAR manifest only if code was compiled or recompiled;
// otherwise the junitPlatformTest task will always be executed even if
// no code changes were made. The reason is that the generation of
// the buildDate and buildTime causes JAR manifests to be modified
// which triggers unnecessary rebuilding of the dependent JARs.
generateManifest = false
buildDate = DateTimeFormatter.ISO_LOCAL_DATE.format(buildTimeAndDate)
buildTime = DateTimeFormatter.ofPattern('HH:mm:ss.SSSZ').format(buildTimeAndDate)
buildRevision = versioning.info.commit
builtByValue = project.hasProperty('builtBy') ? project.builtBy : project.defaultBuiltBy
docsVersion = project.version.contains('SNAPSHOT') ? 'snapshot' : project.version
platformProjects = [
'junit-platform-commons',
'junit-platform-console',
'junit-platform-console-standalone',
'junit-platform-engine',
'junit-platform-gradle-plugin',
'junit-platform-launcher',
'junit-platform-runner',
'junit-platform-suite-api',
'junit-platform-surefire-provider'
]
jupiterProjects = [
'junit-jupiter-api',
'junit-jupiter-engine',
'junit-jupiter-migrationsupport',
'junit-jupiter-params'
]
vintageProjects = [
'junit-vintage-engine'
]
mavenizedProjects = platformProjects + jupiterProjects + vintageProjects
licenses = [
'EPL-2.0': [
name: 'Eclipse Public License v2.0',
url: 'http://www.eclipse.org/legal/epl-v20.html',
headerFile: 'eclipse-public-license-2.0.java'
],
'Apache-2.0': [
name: 'The Apache License, Version 2.0',
url: 'http://www.apache.org/licenses/LICENSE-2.0.txt',
headerFile: 'apache-license-2.0.java'
]
]
licenseOf = { project -> licenses[
project.name == 'junit-platform-surefire-provider'
? 'Apache-2.0'
: 'EPL-2.0'
]
}
cloverTestProjects = [
'junit-jupiter-engine',
'junit-jupiter-migrationsupport',
'junit-jupiter-params',
'junit-vintage-engine',
'junit-platform-surefire-provider',
'platform-tests'
]
jacocoTestProjects = cloverTestProjects << 'junit-platform-gradle-plugin'
jacocoCoveredProjects = mavenizedProjects - ['junit-platform-console-standalone']
jacocoClassesDir = "$buildDir/jacoco/classes"
}
allprojects { subproj ->
apply plugin: 'java-library'
apply plugin: 'groovy' // apply for all projects so rootProject sees groovy output dir
if (gradle.ext.kotlinIsSupported) apply plugin: 'kotlin'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'com.diffplug.gradle.spotless'
apply plugin: 'checkstyle'
apply plugin: 'com.github.ben-manes.versions' // gradle dependencyUpdates
apply from: "$rootDir/gradle/degraph.gradle"
if (project.hasProperty('enableJaCoCo')) {
apply plugin: "jacoco"
jacoco {
toolVersion = '0.8.0'
}
}
repositories {
// mavenLocal()
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
dependencies {
api("org.apiguardian:apiguardian-api:${apiGuardianVersion}")
}
tasks.withType(Test) { task ->
task.testLogging.exceptionFormat = 'full'
}
// Declare "javacRelease" as a global property to make it overridable by
// a sub-project.
ext.javacRelease = rootProject.javacRelease
subproj.afterEvaluate { evaluatedProject ->
evaluatedProject.tasks.withType(JavaCompile) {
sourceCompatibility = javacRelease // needed by clover
targetCompatibility = javacRelease // needed by clover/asm
options.compilerArgs += ['--release', javacRelease]
options.encoding = 'UTF-8'
}
}
// See: https://docs.oracle.com/javase/9/tools/javac.htm#JSWOR627
compileJava.options.compilerArgs += [
'-Xlint:cast',
'-Xlint:classfile',
'-Xlint:deprecation',
'-Xlint:dep-ann',
'-Xlint:divzero',
'-Xlint:empty',
'-Xlint:fallthrough',
'-Xlint:finally',
'-Xlint:overrides',
'-Xlint:path',
'-Xlint:processing',
'-Xlint:rawtypes',
'-Xlint:serial',
'-Xlint:static',
'-Xlint:try',
'-Xlint:unchecked',
'-Xlint:varargs',
'-Xlint:-options',
'-Werror'
]
// See: https://docs.oracle.com/javase/9/tools/javac.htm#JSWOR627
compileTestJava.options.compilerArgs += [
'-Xlint:cast',
'-Xlint:classfile',
'-Xlint:deprecation',
'-Xlint:dep-ann',
'-Xlint:divzero',
'-Xlint:empty',
'-Xlint:fallthrough',
'-Xlint:finally',
'-Xlint:path',
'-Xlint:processing',
'-Xlint:rawtypes',
'-Xlint:serial',
'-Xlint:static',
'-Xlint:try',
'-Xlint:unchecked',
'-Xlint:varargs',
'-Xlint:-options',
'-Xlint:-overrides'
]
compileTestJava {
options.encoding = 'UTF-8'
options.compilerArgs += '-parameters'
}
if (gradle.ext.kotlinIsSupported) tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
kotlinOptions {
jvmTarget = '1.8'
apiVersion = '1.1'
languageVersion = '1.1'
}
}
checkstyle {
toolVersion = '8.7'
configDir = rootProject.file('src/checkstyle')
}
checkstyleMain {
configFile = rootProject.file('src/checkstyle/checkstyleMain.xml')
}
checkstyleTest {
configFile = rootProject.file('src/checkstyle/checkstyleTest.xml')
}
if (project.hasProperty('enableClover')) {
configurations {
clover
}
dependencies {
clover('org.openclover:clover:4.2.0')
}
ext.cloverDir = file("$buildDir/clover")
ext.cloverInitstring = "$cloverDir/clover.db"
def instrumentedJavaSourcesDir = file("$cloverDir/instrumentedSources/java")
task cloverTaskdef {
ant.taskdef(resource:'cloverlib.xml', classpath: configurations.clover.asPath)
}
task cloverInstrumentJava(dependsOn: cloverTaskdef) {
outputs.dir cloverDir
onlyIf { sourceSets.main.allJava.any { it.exists() } }
doLast {
ant.'clover-instr'(
initstring: cloverInitstring,
recordTestResults: false,
destdir: instrumentedJavaSourcesDir,
encoding: 'UTF-8',
source: compileJava.sourceCompatibility) {
sourceSets.main.allJava.addToAntBuilder(ant, 'fileset', FileCollection.AntType.FileSet)
}
}
}
// Disable javac warnings when executing Clover
compileJava.options*.compilerArgs = ['-Xlint:none']
compileTestJava.options*.compilerArgs = ['-Xlint:none']
compileJava.source = instrumentedJavaSourcesDir
sourceSets.main.compileClasspath += configurations.clover
sourceSets.test.compileClasspath += configurations.clover
sourceSets.test.runtimeClasspath += configurations.clover
compileJava.dependsOn cloverInstrumentJava
}
}
subprojects { subproj ->
if (subproj.name in mavenizedProjects) {
apply plugin: 'maven'
apply plugin: 'signing'
if (subproj.name in platformProjects) {
subproj.group = platformGroup
subproj.version = platformVersion
subproj.baseline = platformBaseline
}
else if (subproj.name in vintageProjects) {
subproj.group = vintageGroup
subproj.version = vintageVersion
subproj.baseline = vintageBaseline
}
configurations {
base
}
dependencies {
base(group: subproj.group, name: subproj.name, version: subproj.baseline) {
force = true
transitive = false
}
}
task japicc(type: Exec, dependsOn: assemble) {
// Requires https://github.com/lvc/japi-compliance-checker to be installed
def reportPath = "$buildDir/reports/japicc-${subproj.name}.html"
inputs.file configurations.base[0]
inputs.file jar.archivePath
outputs.file reportPath
commandLine 'japi-compliance-checker', configurations.base[0], jar.archivePath, '-report-path', reportPath
ignoreExitValue = true
}
javadoc {
// Use external javadoc.options to inject unsupported options, like:
// options.addStringOption('-html5')
options.optionFiles(rootProject.file("src/javadoc/javadoc.options"))
options.memberLevel = JavadocMemberLevel.PROTECTED
options.author = true
options.header = project.name
options.use = true
options.addStringOption('Xdoclint:html,syntax', '-quiet')
options.addMultilineStringsOption('tag').setValue(['apiNote:a:API Note:', 'implSpec:a:Implementation Requirements:', 'implNote:a:Implementation Note:'])
options.encoding = 'UTF-8'
// Remove Kotlin classes from classpath due to "bad" class file: AssertionsKt$sam$Supplier$44378ebd.class
// see https://bugs.openjdk.java.net/browse/JDK-8187422
if (gradle.ext.kotlinIsSupported) classpath = classpath - files(compileKotlin.destinationDir)
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
artifacts {
archives sourcesJar
archives javadocJar
}
tasks.withType(Jar) {
from(project.projectDir) {
include 'LICENSE.md'
into 'META-INF'
}
from(project.rootDir) {
include 'LICENSE-notice.md'
into 'META-INF'
}
}
def isSnapshot = project.version.contains('SNAPSHOT')
def isContinuousIntegrationEnvironment = Boolean.parseBoolean(System.getenv("JITPACK"))
def signArtifacts = !(isSnapshot || isContinuousIntegrationEnvironment)
afterEvaluate {
if (signArtifacts && uploadArchives.enabled) {
signing {
sign configurations.archives
}
}
}
uploadArchives {
dependsOn check
repositories {
mavenDeployer {
if (signArtifacts) {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
}
def ossrhUsername = rootProject.hasProperty('ossrhUsername') ? rootProject.ossrhUsername : ''
def ossrhPassword = rootProject.hasProperty('ossrhPassword') ? rootProject.ossrhPassword : ''
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
def projectLicense = licenseOf(project)
pom.project {
name "${project.group}:${project.name}"
packaging 'jar'
description "Module \"${project.name}\" of JUnit 5."
url 'http://junit.org/junit5/'
scm {
connection 'scm:git:git://github.com/junit-team/junit5.git'
developerConnection 'scm:git:git://github.com/junit-team/junit5.git'
url 'https://github.com/junit-team/junit5'
}
licenses {
license {
name projectLicense['name']
url projectLicense['url']
}
}
developers {
developer {
id 'bechte'
name 'Stefan Bechtold'
email 'stefan.bechtold@me.com'
}
developer {
id 'jlink'
name 'Johannes Link'
email 'business@johanneslink.net'
}
developer {
id 'marcphilipp'
name 'Marc Philipp'
email 'mail@marcphilipp.de'
}
developer {
id 'mmerdes'
name 'Matthias Merdes'
email 'Matthias.Merdes@heidelberg-mobil.com'
}
developer {
id 'sbrannen'
name 'Sam Brannen'
email 'sam@sambrannen.com'
}
developer {
id 'sormuras'
name 'Christian Stein'
email 'sormuras@gmail.com'
}
}
}
pom.whenConfigured { p ->
p.dependencies = p.dependencies.findAll { dep -> dep.scope != 'test' }
}
}
}
}
} else {
jar.enabled = false
javadoc.enabled = false
uploadArchives.enabled = false
}
def normalizeVersion = { versionLiteral ->
try {
(versionLiteral =~ /(\d+)\.(\d+)\.(\d+).*/)[0][1..3].join('.')
} catch(x) {
throw new GradleException("Version '$versionLiteral' does not match version pattern, e.g. 5.0.0-QUALIFIER", x)
}
}
compileJava.doLast {
// Enable JAR manifest generation
generateManifest = true
}
eclipse {
if (project.name.endsWith('-java-9')) {
jdt {
// Note: this does not work with Gradle 4.3-rc-2, but hopefully it will
// in a later Gradle release. Thus, for now we still need the custom
// eclipseJdtPrepare task.
sourceCompatibility = 9
targetCompatibility = 9
}
} else {
jdt {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
classpath.containers "org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"
}
}
eclipse.classpath.file.whenMerged { classpath ->
if (!project.name.endsWith('-java-9')) {
classpath.entries.findAll { it.kind == 'con' && it.path.contains('JavaSE-9') }.each {
classpath.entries.remove(it)
}
}
}
task eclipseJdtPrepare(type: Copy) {
if (project.name.endsWith('-java-9')) {
from rootProject.file('src/eclipse/org.eclipse.jdt.core.prefs-jdk9')
into project.file('.settings/')
rename 'org.eclipse.jdt.core.prefs-jdk9', 'org.eclipse.jdt.core.prefs'
outputs.upToDateWhen { false }
}
}
tasks["eclipse"].dependsOn(eclipseJdtPrepare)
jar {
onlyIf {
project.generateManifest
}
manifest {
attributes(
'Created-By': "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})".toString(),
'Built-By': builtByValue,
'Build-Date': buildDate,
'Build-Time': buildTime,
'Build-Revision': buildRevision,
'Specification-Title': project.name,
'Specification-Version': normalizeVersion(project.version),
'Specification-Vendor': 'junit.org',
'Implementation-Title': project.name,
'Implementation-Version': project.version,
'Implementation-Vendor': 'junit.org'
)
}
// If available, compile and include classes for other Java versions.
['9'].each { version ->
def versionedName = project.name + '-java-' + version
def versionedProject = findProject(':' + versionedName)
if (versionedProject == null) {
return
}
if (project.hasProperty('enableClover')) {
println "Skip updating $archivePath with $versionedProject - Clover is enabled!"
return
}
// We're only interested in the compiled classes. So we depend
// on the classes task and change (-C) to the destination
// directory of the version-aware project later.
dependsOn = [versionedProject.classes]
doLast {
project.exec {
executable 'jar'
args = ['--version']
}
project.exec {
executable 'jar'
args = ['--update','--file', archivePath,
'--release', version,
'-C', versionedProject.compileJava.destinationDir,
'.'
]
}
}
}
}
spotless {
def headerFile = rootProject.file('src/spotless/' + licenseOf(project)['headerFile'])
def importOrderConfigFile = rootProject.file('src/eclipse/junit-eclipse.importorder')
def javaFormatterConfigFile = rootProject.file('src/eclipse/junit-eclipse-formatter-settings.xml')
def groovyFormatterConfigFile = rootProject.file('src/eclipse/junit-greclipse-formatter-settings.prefs')
java {
licenseHeaderFile headerFile, '(package|import|open|module) '
importOrderFile importOrderConfigFile
eclipse().configFile javaFormatterConfigFile
if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
removeUnusedImports()
}
trimTrailingWhitespace()
endWithNewline()
}
groovy {
target 'src/**/*.groovy'
licenseHeaderFile headerFile, "package "
importOrderFile importOrderConfigFile
greclipse().configFile javaFormatterConfigFile, groovyFormatterConfigFile
trimTrailingWhitespace()
endWithNewline()
replaceRegex 'Empty line between last method and class closure', /\n([\s]+)}\n}\n$/, '\n$1}\n\n}\n'
replaceRegex 'Remove line breaks between consecutive closing parentheses', /\)\n[\s]+\)\n/, '))\n'
}
kotlin {
ktlint("0.9.0")
licenseHeaderFile headerFile
trimTrailingWhitespace()
endWithNewline()
}
}
afterEvaluate {
if (project.hasProperty('enableJaCoCo')) {
if (subproj.name in jacocoTestProjects) {
jacoco {
applyTo subproj.tasks.matching { it.name == 'junitPlatformTest' }
}
}
if (subproj.name in jacocoCoveredProjects) {
def jarTask = subproj.tasks.findByName('shadowJar') ?: subproj.jar
task extractJar(type: Copy) {
from zipTree(jarTask.archivePath)
into jacocoClassesDir
include '**/*.class'
// don't report coverage for shadowed classes
exclude '**/shadow/**'
// don't version-specific classes of MR JARs
exclude 'META-INF/versions/**'
includeEmptyDirs = false
onlyIf { jarTask.enabled }
}
jarTask.finalizedBy(extractJar)
}
}
}
}
configure(rootProject) {
description = 'JUnit 5'
apply plugin: "org.ajoberstar.git-publish"
jar.enabled = false
uploadArchives.enabled = false
def ota4jDocVersion = ota4jVersion.contains('SNAPSHOT') ? 'snapshot' : ota4jVersion
def apiGuardianDocVersion = apiGuardianVersion.contains('SNAPSHOT') ? 'snapshot' : apiGuardianVersion
task aggregateJavadocs(type: Javadoc) {
group = "Documentation"
description = "Generates aggregated Javadocs"
title = "JUnit ${version} API"
setDependsOn subprojects.collect { it.tasks.getByName("jar") }
// Use external javadoc.options to inject unsupported options, like:
// options.addStringOption('-html5')
options.optionFiles(rootProject.file("src/javadoc/javadoc.options"))
options.memberLevel = JavadocMemberLevel.PROTECTED
options.author = true
options.header = rootProject.description
options.use = true
options.splitIndex = true
options.addStringOption('Xdoclint:none', '-quiet')
options.addMultilineStringsOption('tag').setValue(['apiNote:a:API Note:', 'implSpec:a:Implementation Requirements:', 'implNote:a:Implementation Note:'])
options.encoding = 'UTF-8'
options.jFlags '-Xmx1g'
options.links(
'https://docs.oracle.com/javase/8/docs/api/',
"https://ota4j-team.github.io/opentest4j/docs/${ota4jDocVersion}/api/",
"https://apiguardian-team.github.io/apiguardian/docs/${apiGuardianDocVersion}/api/"
)
options.stylesheetFile rootProject.file("src/javadoc/stylesheet.css")
options
.group("Jupiter", ["org.junit.jupiter.*"])
.group("Vintage", ["org.junit.vintage.*"])
.group("Platform", ["org.junit.platform.*"])
setSource subprojects.collect { it.sourceSets.main.allJava }
maxMemory = "1024m"
destinationDir = new File(buildDir, "docs/javadoc")
// Remove Kotlin classes from classpath due to "bad" class file
// see https://bugs.openjdk.java.net/browse/JDK-8187422
classpath = files(subprojects.collect { it.sourceSets.main.compileClasspath })
.filter { !it.path.contains('kotlin') }
}
spotless {
format 'misc', {
target '**/*.gradle', '**/*.gitignore'
indentWithTabs()
trimTrailingWhitespace()
endWithNewline()
}
format 'documentation', {
target '**/*.adoc', '**/*.md'
trimTrailingWhitespace()
endWithNewline()
}
}
if (project.hasProperty('enableClover')) {
def cloverAggregationFile = "$cloverDir/coverage.db"
task cloverAggregateDatabases(dependsOn: cloverTaskdef) {
outputs.file cloverAggregationFile
subprojects.findAll { it.name in cloverTestProjects }
.each { dependsOn it.tasks.withType(Test) }
doLast {
ant.'clover-merge'(initString: cloverAggregationFile) {
subprojects.each { project ->
def cloverDbFile = project.file(project.cloverInitstring)
if(cloverDbFile.exists()) {
cloverDb(initString: project.cloverInitstring)
}
}
}
}
}
task cloverHtmlReport(dependsOn: cloverAggregateDatabases) {
outputs.dir "$buildDir/reports/clover/html"
doLast {
ant."clover-report"(initString: cloverAggregationFile) {
current(outfile: "$buildDir/reports/clover/html", title: rootProject.description, homepage: 'overview') {
format(type: 'html')
}
}
}
}
task cloverXmlReport(dependsOn: cloverAggregateDatabases) {
outputs.file "$buildDir/reports/clover/clover.xml"
doLast {
ant."clover-report"(initString: cloverAggregationFile) {
current(outfile: "$buildDir/reports/clover/clover.xml") {
format(type: 'xml')
}
}
}
}
}
if (project.hasProperty('enableJaCoCo')) {
task jacocoMerge(type: JacocoMerge) {
subprojects.findAll { it.name in jacocoTestProjects }
.each { subproj ->
executionData fileTree(dir: "${subproj.buildDir}/jacoco", include: '*.exec')
dependsOn subproj.tasks.withType(Test)
}
}
task jacocoRootReport(type: JacocoReport, dependsOn: jacocoMerge) {
sourceDirectories = files(subprojects
.findAll { it.name in jacocoCoveredProjects }
.sourceSets.main.allSource.srcDirs)
classDirectories = files(jacocoClassesDir)
executionData jacocoMerge.destinationFile
reports {
html.enabled = true
xml.enabled = true
csv.enabled = false
}
}
}
def docsDir = new File(buildDir, 'ghpages-docs')
def replaceCurrentDocs = project.hasProperty('replaceCurrentDocs')
task prepareDocsForUploadToGhPages(dependsOn: [aggregateJavadocs, ":documentation:asciidoctor"], type: Copy) {
outputs.dir docsDir
from("${project(':documentation').buildDir}/asciidoc") {
include 'user-guide/**'
include 'release-notes/**'
}
from("$buildDir/docs") {
include 'javadoc/**'
filter { line ->
line.startsWith("<head>") ? line.replace("<head>", "<head><link rel=\"icon\" type=\"image/png\" href=\"http://junit.org/junit5/assets/img/junit5-logo.png\">") :
line
}
}
into "${docsDir}/${docsVersion}"
filesMatching('javadoc/**') { fileCopyDetails ->
fileCopyDetails.path = fileCopyDetails.path.replace('javadoc/', 'api/')
}
includeEmptyDirs = false
}
task createCurrentDocsFolder(dependsOn: prepareDocsForUploadToGhPages, type: Copy) {
outputs.dir "${docsDir}/current"
from "${docsDir}/${docsVersion}"
into "${docsDir}/current"
}
createCurrentDocsFolder.onlyIf { replaceCurrentDocs }
gitPublish {
repoUri = 'https://github.com/junit-team/junit5.git'
branch = 'gh-pages'
contents {
from docsDir
into "docs"
}
preserve {
include '**/*'
exclude "docs/${docsVersion}/**"
if (replaceCurrentDocs) {
exclude "docs/current/**"
}
}
}
gitPublishCommit.dependsOn(prepareDocsForUploadToGhPages)
gitPublishCommit.dependsOn(createCurrentDocsFolder)
}
task wrapper(type: Wrapper) {
description = 'Generates gradlew and gradlew.bat scripts'
gradleVersion = '4.5.1'
/*
* Reasoning for using BIN:
* https://github.com/junit-team/junit5/pull/1012#discussion_r132061924
*/
distributionType = Wrapper.DistributionType.BIN
}