forked from agorapulse/testing-libraries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
150 lines (124 loc) · 4.15 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
allprojects {
group 'com.agorapulse.testing'
repositories {
jcenter()
mavenCentral()
maven { url "https://dl.bintray.com/agorapulse/libs" }
maven { url "https://repo.spring.io/release" }
}
}
subprojects { Project subproject ->
apply plugin: 'groovy'
apply plugin: 'jacoco'
apply plugin: 'checkstyle'
apply plugin: 'codenarc'
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_1_8
test {
testLogging {
events "PASSED", "STARTED", "FAILED", "SKIPPED", "STANDARD_ERROR", "STANDARD_OUT"
showCauses = true
showExceptions = true
showStackTraces = true
showStandardStreams = false
exceptionFormat "full"
}
systemProperty 'TEST_RESOURCES_FOLDER', new File(subproject.projectDir, 'src/test/resources').canonicalPath
systemProperty 'user.timezone', 'UTC'
systemProperty 'user.language', 'en'
// see https://discuss.gradle.org/t/show-stderr-for-failed-tests/8463/7
List<String> out = []
List<String> err = []
beforeTest { TestDescriptor td ->
out.clear()
err.clear()
}
onOutput { TestDescriptor td, TestOutputEvent toe ->
String[] lines = toe.getMessage().split('(?m)$')
if (toe.destination == TestOutputEvent.Destination.StdErr) {
err.addAll(lines)
} else {
out.addAll(lines)
}
}
afterTest { TestDescriptor td, TestResult tr ->
if (tr.resultType == TestResult.ResultType.FAILURE && (out || err)) {
println("${td.className}.${td.name} failed!")
println()
println("\n=== OUT ===\n")
println()
out.each { print(it) }
println()
println("\n=== ERR ===\n")
println()
err.each { print(it) }
}
}
}
task cleanOut(type: Delete) {
delete file('out')
}
clean.dependsOn cleanOut
checkstyle {
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
toolVersion = '6.19'
}
codenarc {
configFile = rootProject.file('config/codenarc.xml')
toolVersion = '1.3'
}
}
// docs
apply plugin: 'org.ajoberstar.git-publish'
apply plugin: 'org.asciidoctor.convert'
apply plugin: 'com.palantir.jacoco-full-report'
apply plugin: 'com.github.kt3k.coveralls'
dependencies {
// https://mvnrepository.com/artifact/io.spring.asciidoctor/spring-asciidoctor-extensions
asciidoctor group: 'io.spring.asciidoctor', name: 'spring-asciidoctor-extensions', version: '0.1.3.RELEASE'
}
// asciidoctor publishing
asciidoctor {
sourceDir = file('docs')
resources {
from(sourceDir) {
include 'css/**', 'images/**'
}
}
attributes 'docinfo1': ['version': project.version],
'imagesdir': 'images',
'source-highlighter': 'highlight.js',
'stylesdir': 'css',
icons: 'font',
'toc': 'left',
'toclevels': '3',
version: project.version,
'projectUrl': 'https://github.com/agorapulse/testing-libraries'
}
gitPublish {
repoUri = 'git@github.com:agorapulse/testing-libraries.git'
branch = 'gh-pages'
contents {
from file(asciidoctor.outputDir.path + '/html5')
subprojects.each { Project subproject ->
from(subproject.javadoc.outputs.files) {
into "docs/javadoc/$subproject.name"
}
}
}
}
gitPublishCopy.dependsOn subprojects*.javadoc
gitPublishCopy.dependsOn asciidoctor
tasks.jacocoFullReport.dependsOn subprojects.collect { it.tasks.check }
gradle.taskGraph.whenReady {
coveralls {
sourceDirs = subprojects.sourceSets.main.allSource.srcDirs.flatten()
jacocoReportPath = "${buildDir}/reports/jacoco/jacocoFullReport/jacocoFullReport.xml"
}
}
tasks.coveralls {
group = 'Coverage reports'
description = 'Uploads the aggregated coverage report to Coveralls'
dependsOn jacocoFullReport
onlyIf { System.env.CI }
}