forked from spockframework/spock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
executable file
·289 lines (252 loc) · 7.6 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
buildscript {
repositories {
maven { url "http://dl.bintray.com/content/aalmiray/asciidoctor" }
jcenter()
}
dependencies {
classpath "org.asciidoctor:asciidoctor-gradle-plugin:1.5.2"
}
}
apply plugin: "base"
apply plugin: "org.asciidoctor.convert"
description = "Spock Framework"
ext {
variants = [2.0, 2.3, 2.4]
variant = System.getProperty("variant") as BigDecimal ?: variants.first()
if (variant == 2.0) {
groovyVersion = "2.0.8"
minGroovyVersion = "2.0.0"
maxGroovyVersion = "2.2.99"
} else if (variant == 2.3) {
groovyVersion = "2.3.11"
minGroovyVersion = "2.3.0"
maxGroovyVersion = "2.3.99"
} else if (variant == 2.4) {
groovyVersion = "2.4.5"
minGroovyVersion = "2.4.0"
maxGroovyVersion = "2.9.99"
} else {
throw new InvalidUserDataException("Unknown variant: $variant. Choose one of: $variants")
}
javaVersions = [1.6, 1.7, 1.8]
javaVersion = System.getProperty("java.specification.version") as BigDecimal
baseVersion = "1.1"
snapshotVersion = true
fullVersion = "$baseVersion-groovy-$variant" + (snapshotVersion ? "-SNAPSHOT" : "")
variantLessVersion = baseVersion + (snapshotVersion ? "-SNAPSHOT" : "")
libs = [
jetbrainsAnnotations: "org.jetbrains:annotations:13.0",
ant: "org.apache.ant:ant:1.9.4",
asm: "org.ow2.asm:asm:5.0.3",
cglib: "cglib:cglib-nodep:3.2.0",
groovy: "org.codehaus.groovy:groovy-all:$groovyVersion",
h2database: "com.h2database:h2:1.3.174",
junit: "junit:junit:4.12",
log4j: "log4j:log4j:1.2.17",
objenesis: "org.objenesis:objenesis:2.1"
]
}
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')
}
}
}
apply from: script("ide")
subprojects {
apply plugin: "groovy"
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"
}
}
}
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 {
sign configurations.archives
}
signArchives {
onlyIf { gradle.taskGraph.hasTask(uploadArchives) }
}
ext."signing.keyId" = "2EA0A67F"
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) {
reports {
junitXml {
destination = file("$destination/$variant")
}
html {
destination = file("$destination/$variant")
}
}
}
}
if (gradle.startParameter.taskNames == ["travisCiBuild"]) {
gradle.startParameter.taskNames = ["build"]
subprojects {
tasks.withType(Test) {
maxParallelForks = 2
}
}
if (System.getenv("TRAVIS_PULL_REQUEST") == "false") {
if (javaVersion == javaVersions.min()) {
gradle.startParameter.taskNames += ["uploadArchives"]
}
if (javaVersion == javaVersions.max()) {
if (variant == variants.max()) {
gradle.startParameter.taskNames += ["publishJavadoc", "publishDocs"]
if (!snapshotVersion) {
gradle.startParameter.taskNames += ["tagRelease"]
}
}
}
}
}
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 (System.getenv("PULL_REQUEST") == "false") {
if (javaVersion == javaVersions.min()) {
gradle.startParameter.taskNames += ["uploadArchives"]
}
if (javaVersion == javaVersions.max()) {
if (variant == variants.max()) {
gradle.startParameter.taskNames += ["publishJavadoc", "publishDocs"]
if (!snapshotVersion) {
gradle.startParameter.taskNames += ["tagRelease"]
}
}
}
}
}
if (gradle.startParameter.taskNames == ["appveyorCiBuild"]) {
gradle.startParameter.taskNames = ["build"]
}
task publishJavadoc(type: Exec) {
dependsOn "javadoc"
commandLine "sh", "-c",
"""
git config user.email "[email protected]"
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 -q "https://${System.getenv("GITHUB_TOKEN")}@github.com/spockframework/spock.git" gh-pages > /dev/null 2>&1
git checkout master
"""
}
task publishDocs(type: Exec) {
dependsOn "asciidoctor"
commandLine "sh", "-c",
"""
git config user.email "[email protected]"
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 -q "https://${System.getenv("GITHUB_TOKEN")}@github.com/spockframework/spock.git" gh-pages > /dev/null 2>&1
git checkout master
"""
}
task tagRelease(type: Exec) {
commandLine "sh", "-c",
"""
git config user.email "[email protected]"
git config user.name "Spock Framework Robot"
git checkout master
git tag spock-$baseVersion
git push -q "https://${System.getenv("GITHUB_TOKEN")}@github.com/spockframework/spock.git" spock-$baseVersion > /dev/null 2>&1
"""
}
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
}
File script(String name) {
project.file("gradle/${name}.gradle")
}
def configureJavadoc(task) {
configure(task) {
include "spock/**"
configure(options) {
links "http://docs.oracle.com/javase/6/docs/api/"
links "http://docs.groovy-lang.org/docs/groovy-$groovyVersion/html/gapi/"
links "http://junit.org/javadoc/latest/"
links "http://hamcrest.org/JavaHamcrest/javadoc/1.3/"
}
}
}
def configureGroovydoc(task) {
configure(task) {
include "spock/**"
}
}