forked from serenity-bdd/serenity-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
460 lines (403 loc) · 14.2 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
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:0.6'
classpath 'org.ajoberstar:gradle-git:0.12.0'
classpath 'org.pegdown:pegdown:1.4.1'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.7'
}
}
import org.ajoberstar.grgit.*
import org.ajoberstar.gradle.git.release.opinion.Strategies
import org.pegdown.PegDownProcessor
import groovy.text.SimpleTemplateEngine
apply plugin: 'org.ajoberstar.release-base'
allprojects {
apply plugin: 'project-report'
apply plugin: 'com.github.ben-manes.versions'
configurations.all {
resolutionStrategy {
// fail fast on dependency convergence problems
failOnVersionConflict()
// force versions to fix dependency convergence problems
// when updating this list, update Serenity's declared deps if exists
// TODO make work for generated Maven POM...
// it's working for gradle build, but also had to exclude old transitives for generated POM
force 'asm:asm:3.3.1',
'com.fasterxml.jackson.core:jackson-annotations:2.4.3',
'com.google.code.gson:gson:2.3',
'com.google.guava:guava:18.0',
'com.google.inject.extensions:guice-multibindings:3.0',
'com.google.inject.extensions:guice-servlet:3.0',
'com.google.inject:guice:3.0',
'com.thoughtworks.xstream:xstream:1.4.1',
'commons-codec:commons-codec:1.9',
'commons-collections:commons-collections:3.2.1',
'commons-io:commons-io:2.4',
'commons-logging:commons-logging:1.1.3',
'joda-time:joda-time:2.2',
'org.apache.commons:commons-lang3:3.3.2',
'org.apache.httpcomponents:httpclient:4.3.4',
'org.apache.httpcomponents:httpmime:4.3.3',
'org.bouncycastle:bcprov-jdk15on:1.48',
'org.codehaus.groovy:groovy-all:2.3.6',
'org.codehaus.jackson:jackson-core-asl:1.7.1',
'org.codehaus.jackson:jackson-mapper-asl:1.7.1',
'org.eclipse.jetty:jetty-http:8.1.15.v20140411',
'org.freemarker:freemarker:2.3.21',
'org.objenesis:objenesis:2.1',
'org.seleniumhq.selenium:selenium-api:2.44.0',
'org.slf4j:slf4j-api:1.7.5',
'xalan:xalan:2.7.1',
'xml-apis:xml-apis:1.4.01'
}
}
}
release {
grgit = Grgit.open(project.file('.'))
versionStrategy Strategies.FINAL
versionStrategy Strategies.PRE_RELEASE
defaultVersionStrategy Strategies.SNAPSHOT
}
subprojects {
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
mavenLocal()
jcenter()
}
ext {
bintrayBaseUrl = 'https://api.bintray.com/maven'
bintrayRepository = 'maven'
bintrayPackage = 'serenity-core'
projectDescription = 'Serenity core libraries'
if (!project.hasProperty("bintrayUsername")) {
bintrayUsername = 'wakaleo'
}
if (!project.hasProperty("bintrayApiKey")) {
bintrayApiKey = ''
}
}
group = 'net.serenity-bdd'
version = rootProject.version
task wrapper(type: Wrapper) {
gradleVersion = '2.2.1'
}
test {
exclude '**/*$*'
exclude '**/integration/**'
exclude '**/samples/**'
exclude '**/*Sample*'
minHeapSize = "128m"
maxHeapSize = "512m"
jvmArgs '-XX:MaxPermSize=256m'
}
task integrationTests(type: Test) {
exclude '**/*$*'
exclude '**/samples/**'
exclude '**/*Sample*'
exclude '**/integration/browsers**'
include '**/integration/**'
reports.junitXml.destination = "${buildDir}/reports/integration-tests"
reports.html.destination = "${buildDir}/reports/integration-tests"
minHeapSize = "128m"
maxHeapSize = "2048m"
jvmArgs '-XX:MaxPermSize=256m'
}
test {
testLogging {
exceptionFormat = 'full'
}
}
integrationTests {
testLogging {
exceptionFormat = 'full'
}
}
task browserTests(type: Test) {
exclude '**/*$*'
exclude '**/samples/**'
exclude '**/*Sample*'
exclude '**/*Base'
include '**/integration/browsers/**'
}
task javadoc(type: Javadoc, overwrite:true) {
source = sourceSets.main.allJava
options.memberLevel = JavadocMemberLevel.PUBLIC
options.addStringOption('views')
options.addStringOption('all')
options.addStringOption('quiet')
options.addStringOption('qualify')
options.addStringOption('Xdoclint:none')
options.encoding = 'UTF-8'
classpath = configurations.compile
}
// integrationTests.dependsOn test
check.dependsOn -= integrationTests
dependencies {
compile "com.google.guava:guava:18.0"
compile "com.google.inject:guice:3.0"
compile "commons-codec:commons-codec:1.9"
compile "org.objenesis:objenesis:2.1"
compile "org.slf4j:slf4j-api:1.6.4"
compile "xml-apis:xml-apis:1.4.01"
testCompile "ch.qos.logback:logback-classic:1.0.13"
testCompile "junit:junit:4.11"
testCompile "org.hamcrest:hamcrest-integration:1.3"
testCompile "org.hamcrest:hamcrest-library:1.3"
testCompile "org.hamcrest:hamcrest-core:1.3"
testCompile('org.mockito:mockito-all:1.10.8') {
exclude group: "org.hamcrest"
}
testCompile("org.spockframework:spock-core:0.7-groovy-2.0") {
exclude group: "junit"
}
testCompile("com.github.goldin:spock-extensions:0.1.4") {
exclude module: "spock-core"
}
testCompile("org.codehaus.groovy:groovy-all:2.3.6")
testCompile("org.easytesting:fest-assert:1.4")
}
bintray {
user = bintrayUsername //this usually comes form gradle.properties file in ~/.gradle
key = bintrayApiKey //this usually comes form gradle.properties file in ~/.gradle
publications = ['mavenJava'] // see publications closure
pkg {
repo = 'maven'
userOrg = 'serenity'
name = 'serenity-core'
desc = 'Serenity core libraries'
licenses = ['Apache-2.0']
labels = ['serenity','bdd']
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar, javadocJar
}
publishing {
publications {
mavenJava(MavenPublication) {
println "Publishing $project.name:$project.group:$project.version"
from components.java
artifact sourcesJar {
classifier "sources"
}
artifact javadocJar {
classifier "javadoc"
}
pom.withXml {
asNode().children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST
name "$project.name"
description "$projectDescription"
url 'https://github.com/serenity-bdd/serenity-core'
scm {
url 'scm:git:[email protected]:serenity-bdd/serenity-core.git'
connection 'scm:git:[email protected]:serenity-bdd/serenity-core.git'
developerConnection 'scm:git:[email protected]:serenity-bdd/serenity-core.git'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/license/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'johnsmart'
name 'John Ferguson Smart'
email '[email protected]'
}
}
}
// Preserve compile-scope dependencies
asNode().dependencies.'*'.findAll() {
it.scope.text() == 'runtime' && project.configurations.compile.allDependencies.find { dep ->
dep.name == it.artifactId.text()
}
}.each() {
it.scope*.value = 'compile'
}
}
}
}
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:-options"
}
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
}
// Supporting methods to generate the release notes from the Git commits
// TODO: Make this into a plugin
/*
String LAST_LEGACY_TAG = "v1.0.23"
String RELEASE_NOTES_FILE = 'release-notes.md'
task publishReleaseNotes() {
println "Generating Release Notes"
def writeLegacyReleaseNotes = false
def releaseNotes = new File(RELEASE_NOTES_FILE)
releaseNotes.delete()
def tags = readTags()
writeTableOfContents(releaseNotes, tags)
def moreRecentTag = null
tags.findAll { !it.isEmpty() }.each {tag ->
if (tag == LAST_LEGACY_TAG) {
writeLegacyReleaseNotes = true
}
if (!moreRecentTag) {
writeReleaseTitle(releaseNotes, 'Upcoming')
writeToReleaseNotes(changesBetween(tag, null), releaseNotes, writeLegacyReleaseNotes)
}
else {
writeReleaseTitle(releaseNotes, moreRecentTag)
writeToReleaseNotes(changesBetween(tag, moreRecentTag), releaseNotes, writeLegacyReleaseNotes)
}
moreRecentTag = tag
}
writeReleaseTitle(releaseNotes, moreRecentTag)
writeToReleaseNotes(changesBetween(null, moreRecentTag), releaseNotes, writeLegacyReleaseNotes)
releaseNotes << "\n"
}
private void writeTableOfContents(releaseNotes, List<String> tags) {
releaseNotes << '# Releases\n'
tags.findAll { !it.isEmpty() }.each { tag ->
releaseNotes << "- [$tag](#$tag)\n"
}
}
private File writeReleaseTitle(releaseNotes, title) {
releaseNotes << "# $title<a name='$title'></a>\n"
}
private File writeSubtitleitle(releaseNotes, title) {
releaseNotes << "## $title\n"
}
private Iterable<CommitMessage> writeToReleaseNotes(List<CommitMessage> changes, releaseNotes, legacyMode) {
boolean typesShown = false
MessageType.values().each {
def changesOfThisType = changesOfType(it, changes)
if (changesOfThisType) {
typesShown = true
writeSubtitleitle(releaseNotes, it.label)
changesOfThisType.each { change ->
if (change.isIncludedInReleaseNotes()) {
releaseNotes << "$change\n"
}
}
}
}
if (legacyMode) {
def miscChanges = changesOfType(null, changes)
if (miscChanges) {
if (typesShown) writeSubtitleitle(releaseNotes, 'Miscellaneous')
miscChanges.each {
releaseNotes << "$it\n"
}
}
}
}
def readTags() {
def lines = []
def proc = 'git for-each-ref --format=%(*committerdate:iso8601)-%(refname) refs/tags'.execute()
proc.in.eachLine {
line -> lines += line
}
lines = lines.sort().reverse();
return lines.collect { String line -> line.length() > 36 ? line.substring(36) : ""}
}
List<CommitMessage> changesBetween(String prevTag, String tag) {
def command = "git log $prevTag..$tag --format=%x20-%x20%s%+b"
if (prevTag == null) {
command = "git log $tag --format=%x20-%x20%s%+b"
} else if (tag == null) {
command = "git log $prevTag..HEAD --format=%x20-%x20%s%+b"
}
def proc = command.execute()
def changes = []
def subject = null
def body = []
proc.in.eachLine {
if (it.startsWith(" - ")) {
if (subject) {
changes += new CommitMessage(subject, body)
body = []
}
subject = it.substring(3)
} else {
body += it
}
}
if (subject) {
changes += new CommitMessage(subject, body)
}
return changes
}
enum MessageType {
feat("Features"),
fix("Bug Fixes"),
docs("Documentation"),
style("Style"),
refactor("Refactoring"),
perf("Performance"),
test("Tests"),
chore("Chores")
def label
MessageType(label) {
this.label = label
}
}
class CommitMessage {
MessageType type;
String subject;
List<String> body;
CommitMessage(String subjectText, List<String> body) {
if (declaredType(subjectText)) {
this.type = declaredType(subjectText)
this.subject = subjectText.replace("$type:","")
} else {
this.subject = subjectText
}
this.body = body
}
def declaredType(String subject) {
return MessageType.values().find {
String typeName = it.toString().toLowerCase()
subject.toLowerCase().startsWith("$typeName:")
}
}
def isIncludedInReleaseNotes() { type != null }
@Override
public String toString() {
def rendered = " - $subject";
body.each {
rendered += "\n" + it
}
rendered
}
}
List<CommitMessage> changesOfType(MessageType messageType, List<CommitMessage> commitMessages) {
commitMessages.findAll { it.type == messageType}
}
*/