forked from spockframework/spock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
executable file
·368 lines (322 loc) · 11.1 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
import java.text.SimpleDateFormat
plugins {
id 'com.gradle.build-scan' version '1.9'
id "base"
id "org.asciidoctor.convert" version "1.5.6"
id "jacoco"
id "net.nemerosa.versioning" version "2.6.1"
}
description = "Spock Framework"
ext {
baseVersion = "1.2"
snapshotVersion = true
releaseCandidate = 0
variants = [2.4, 2.5]
variant = System.getProperty("variant") as BigDecimal ?: variants.first()
if (variant == 2.4) {
groovyVersion = "2.4.15"
minGroovyVersion = "2.4.0"
groovyDependency = ["org.codehaus.groovy:groovy-all:${groovyVersion}"]
groovyConsoleExtraDependency = [] //bundled in groovy-all
} else if (variant == 2.5) {
groovyVersion = "2.5.2"
minGroovyVersion = "2.5.2"
groovyDependency = [
"org.codehaus.groovy:groovy:${groovyVersion}",
"org.codehaus.groovy:groovy-json:${groovyVersion}",
"org.codehaus.groovy:groovy-nio:${groovyVersion}",
"org.codehaus.groovy:groovy-macro:${groovyVersion}",
"org.codehaus.groovy:groovy-templates:${groovyVersion}",
"org.codehaus.groovy:groovy-test:${groovyVersion}",
"org.codehaus.groovy:groovy-sql:${groovyVersion}",
"org.codehaus.groovy:groovy-xml:${groovyVersion}",
]
groovyConsoleExtraDependency = [
"org.codehaus.groovy:groovy-groovysh:${groovyVersion}"
]
} else {
throw new InvalidUserDataException("Unknown variant: $variant. Choose one of: $variants")
}
maxGroovyVersion = snapshotVersion ? "3.9.99" : "2.9.99" // TODO lock these down once Groovy 3 gets close to RC stage
if (System.getProperty("groovyVersion")) {
groovyVersion = System.getProperty("groovyVersion")
}
fullVersion = baseVersion + ((!snapshotVersion && releaseCandidate) ? "-RC$releaseCandidate" : "") + "-groovy-$variant" + (snapshotVersion ? "-SNAPSHOT" : '')
variantLessVersion = baseVersion + (snapshotVersion ? "-SNAPSHOT" : (releaseCandidate ? "-RC$releaseCandidate" : ""))
javaVersions = [1.7, 1.8, 9, 10] // ensure that latest version is actually build on travis, otherwise no docs get published
javaVersion = System.getProperty("java.specification.version") as BigDecimal
if (javaVersion >= 9) {
groovyDependency += ["javax.xml.bind:jaxb-api:2.3.0"]
}
libs = [
jetbrainsAnnotations: "org.jetbrains:annotations:13.0",
ant: "org.apache.ant:ant:1.9.7",
asm: "org.ow2.asm:asm:6.2",
bytebuddy: "net.bytebuddy:byte-buddy:1.8.21",
cglib: "cglib:cglib-nodep:3.2.7",
groovy: groovyDependency,
h2database: "com.h2database:h2:1.3.176",
junit: "junit:junit:4.12",
log4j: "log4j:log4j:1.2.17",
objenesis: "org.objenesis:objenesis:2.6"
]
Date buildTimeAndDate = new Date()
buildDate = new SimpleDateFormat('yyyy-MM-dd').format(buildTimeAndDate)
buildTime = new SimpleDateFormat('HH:mm:ss.SSSZ').format(buildTimeAndDate)
}
allprojects {
ext.displayName = null
group = "org.spockframework"
version = fullVersion
apply from: script("common")
if (javaVersion == 1.8) {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
options.noTimestamp()
}
} else if (javaVersion >= 9){
tasks.withType(JavaCompile) {
sourceCompatibility = javaVersions.min()
targetCompatibility = javaVersions.min()
options.compilerArgs += ['--release', '8']
options.encoding = 'UTF-8'
}
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
options.noTimestamp()
}
}
}
apply from: script("ide")
subprojects {
apply plugin: "groovy"
apply plugin: "jacoco"
apply plugin: "signing"
sourceCompatibility = javaVersions.min()
targetCompatibility = javaVersions.min()
sourceSets.all { ss ->
for (v in variants.findAll { it <= variant } ) {
java {
srcDir "src/$ss.name$v/java"
}
groovy {
srcDir "src/$ss.name$v/groovy"
}
}
}
sourceSets.all { ss ->
for (jv in javaVersions.findAll { it <= javaVersion } ) {
java {
srcDir "src/${ss.name}.java$jv/java"
}
groovy {
srcDir "src/${ss.name}.java$jv/groovy"
}
}
}
repositories {
mavenCentral()
maven { url "https://oss.jfrog.org/oss-snapshot-local/" }
}
configurations {
all*.exclude module: "junit-dep"
}
dependencies {
compile(project.name == "spock-gradle" ? [] : libs.groovy)
}
signing {
required { gradle.taskGraph.hasTask(':uploadArchives') }
sign configurations.archives
}
signArchives {
onlyIf { gradle.taskGraph.hasTask(':uploadArchives') }
}
ext."signing.keyId" = "2EA0A67F"
if (System.getenv("SIGNING_PASSWORD")) {
// if the password property is set, even if its null null, the SigningExtension will try to load the key
ext."signing.password" = System.getenv("SIGNING_PASSWORD")
}
ext."signing.secretKeyRingFile" = "$rootDir/config/code-signing-secring.gpg"
configureJavadoc(javadoc)
configureGroovydoc(groovydoc)
task sourcesJar(type: Jar) {
classifier "sources"
from sourceSets.main.allSource
}
task javadocJar(type: Jar) {
classifier "javadoc"
from javadoc
}
artifacts {
archives sourcesJar, javadocJar
}
tasks.withType(Test) {
def taskName = name
reports {
junitXml {
destination = file("$destination/$taskName-$variant")
}
html {
destination = file("$destination/$taskName-$variant")
}
}
//Required for building on Travis' container-based infrastructure to not be killed with
//'exit code 137' - https://github.com/travis-ci/travis-ci/issues/5582
jvmArgs '-Xmx512m'
}
jacoco {
toolVersion = '0.8.2'
}
}
task codeCoverageReport (type: JacocoReport, group: 'Coverage reports') {
description = "Creates an aggregate coverage for the whole project."
def reportingProjects = subprojects.findAll()
dependsOn(reportingProjects.tasks.collectMany{it.withType(Test)})
onlyIf = { true } // required to circumvent a wrong check in the jacoco report plugin (v2.13)
sourceDirectories = files() //must be set
classDirectories = files() //must be set
additionalSourceDirs files(reportingProjects.sourceSets.main.allSource.srcDirs)
additionalClassDirs files(reportingProjects.sourceSets.main.output)
executionData = files(reportingProjects.jacocoTestReport.executionData)
doFirst {
// find all *.exec files
executionData = fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")
}
reports {
html.enabled = true
xml.enabled = true
xml.destination file("${buildDir}/reports/jacoco/report.xml") // report must be here for codecov to pick it up
csv.enabled = false
}
}
if (gradle.startParameter.taskNames == ["travisCiBuild"]) {
gradle.startParameter.taskNames = ["build", "codeCoverageReport"]
subprojects {
tasks.withType(Test) {
maxParallelForks = 2
}
}
if (System.getenv("TRAVIS_PULL_REQUEST") == "false" && System.getenv("TRAVIS_BRANCH") == "master") {
if (javaVersion == javaVersions.min()) {
gradle.startParameter.taskNames += ["uploadArchives"]
if (!snapshotVersion) {
gradle.startParameter.taskNames += ["tagRelease"]
}
}
if (javaVersion == javaVersions.max()) {
if (variant == variants.max()) {
gradle.startParameter.taskNames += ["publishJavadoc", "publishDocs"]
}
}
}
}
if (gradle.startParameter.taskNames == ["shippableCiBuild"]) {
gradle.startParameter.taskNames = ["clean", "build"] // use clean because whole minion is cached
task aggregateTestResults(type: Sync) {
from { subprojects.test.reports.junitXml.destination }
into "shippable/testresults"
include "**/TEST-*.xml"
}
subprojects {
tasks.withType(Test) {
it.finalizedBy(aggregateTestResults)
}
}
}
if (gradle.startParameter.taskNames == ["appveyorCiBuild"]) {
gradle.startParameter.taskNames = ["build"]
}
task publishJavadoc(type: Exec) {
dependsOn "javadoc"
commandLine "sh", "-c",
"""
git config user.email "dev@forum.spockframework.org"
git config user.name "Spock Framework Robot"
git fetch origin +gh-pages:gh-pages
git checkout gh-pages
rm -rf javadoc/$variantLessVersion
mkdir -p javadoc/$variantLessVersion
cp -r build/javadoc/$variantLessVersion javadoc/
git add javadoc
git commit -qm "Publish javadoc/$variantLessVersion"
git push "https://\$GITHUB_TOKEN@github.com/spockframework/spock.git" gh-pages 2>&1 | sed "s/\$GITHUB_TOKEN/xxx/g"
git checkout master
"""
}
task publishDocs(type: Exec) {
dependsOn "asciidoctor"
commandLine "sh", "-c",
"""
git config user.email "dev@forum.spockframework.org"
git config user.name "Spock Framework Robot"
git fetch origin +gh-pages:gh-pages
git checkout gh-pages
rm -rf docs/$variantLessVersion
mkdir -p docs/$variantLessVersion
cp -r build/asciidoc/html5/* docs/$variantLessVersion
git add docs
git commit -qm "Publish docs/$variantLessVersion"
git push "https://\$GITHUB_TOKEN@github.com/spockframework/spock.git" gh-pages 2>&1 | sed "s/\$GITHUB_TOKEN/xxx/g"
git checkout master
"""
}
task tagRelease(type: Exec) {
commandLine "sh", "-c",
"""
git config user.email "dev@forum.spockframework.org"
git config user.name "Spock Framework Robot"
git checkout master
git tag -f spock-$variantLessVersion
git push "https://\$GITHUB_TOKEN@github.com/spockframework/spock.git" spock-$variantLessVersion 2>&1 | sed "s/\$GITHUB_TOKEN/xxx/g"
"""
}
task javadoc(type: Javadoc) {
title "Spock Framework API Documentation ($variantLessVersion)"
destinationDir file("build/javadoc/$variantLessVersion")
source subprojects.javadoc.source
classpath = files(subprojects.javadoc.classpath)
}
configureJavadoc(javadoc)
task groovydoc(type: Groovydoc) {
docTitle "Spock Framework API Documentation ($variantLessVersion)"
windowTitle "Spock Framework API Documentation ($variantLessVersion)"
destinationDir file("build/groovydoc/$variantLessVersion")
source subprojects.groovydoc.source
classpath = files(subprojects.groovydoc.classpath)
groovyClasspath = project(":spock-core").groovydoc.groovyClasspath
}
configureGroovydoc(groovydoc)
asciidoctor {
sourceDir = file("docs")
logDocuments = true
attributes "source-highlighter": "coderay", "linkcss": true, "sectanchors": true, "revnumber": variantLessVersion
// also treats the included specs as inputs
inputs.dir file("spock-specs/src/test/groovy/org/spockframework/docs")
inputs.dir file("spock-spring/src/test/groovy/org/spockframework/docs")
inputs.dir file("spock-spring/src/test/resources/org/spockframework/docs")
inputs.dir file("spock-spring/boot/test/src/test/groovy/org/spockframework/boot")
}
File script(String name) {
project.file("gradle/${name}.gradle")
}
def configureJavadoc(task) {
configure(task) {
include "spock/**"
configure(options) {
options.addStringOption('source', '1.8')
links "http://docs.oracle.com/javase/8/docs/api/"
links "http://docs.groovy-lang.org/docs/groovy-$groovyVersion/html/gapi/"
links "http://junit.org/junit4/javadoc/latest/"
links "http://hamcrest.org/JavaHamcrest/javadoc/1.3/"
}
}
}
def configureGroovydoc(task) {
configure(task) {
include "spock/**"
}
}
buildScan {
licenseAgreementUrl = 'https://gradle.com/terms-of-service'
licenseAgree = 'yes'
}