forked from TNG/JGiven
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
352 lines (301 loc) · 11.3 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
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.6.3'
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.3'
}
}
plugins {
id "com.gradle.build-scan" version "1.2"
id 'com.github.ben-manes.versions' version '0.13.0'
id "org.sonarqube" version "2.0.1"
id "ru.vyarus.animalsniffer" version "1.2.0"
}
apply plugin: 'com.github.kt3k.coveralls'
apply plugin: 'org.asciidoctor.convert'
description = 'JGiven - BDD in plain Java'
task wrapper(type: Wrapper) {
gradleVersion = '3.1'
}
allprojects {
group = 'com.tngtech.jgiven'
version = version
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
ext.isCI = System.env.CI == "true"
apply plugin: 'jacoco'
repositories {
mavenCentral()
}
}
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
asciidoctor {
sourceDir = file('docs')
attributes 'version': version
}
subprojects{
ext {
junitDataproviderVersion = '1.11.0'
// set default junit version if not set via command line
junitVersion = rootProject.hasProperty('junitVersion') ? rootProject.junitVersion : '4.12'
junitParamsVersion = '1.0.5'
testngVersion = '6.9.12'
assertjVersion = '2.5.0'
slf4jVersion = '1.7.21'
cglibVersion = '3.2.4'
bytebuddyVersion = '1.4.33'
paranamerVersion = '2.8'
jansiVersion = '1.13'
gsonVersion = '2.7'
guavaVersion = '19.0'
springVersion = '4.3.2.RELEASE'
checkstyleVersion = '2.12.1'
jacocoVersion = '0.7.2.201409121644'
quickcheckVersion = '0.6'
}
}
configure(subprojects.findAll {!it.name.contains("android")}) {
apply plugin: 'checkstyle'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'org.asciidoctor.convert'
apply plugin: 'ru.vyarus.animalsniffer'
apply plugin: 'maven-publish'
description "${rootProject.description} - Module ${project.name}"
sourceCompatibility = targetCompatibility = 1.6
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
ext {
junitDataproviderVersion = '1.11.0'
// set default junit version if not set via command line
junitVersion = rootProject.hasProperty('junitVersion') ? rootProject.junitVersion : '4.12'
junitParamsVersion = '1.0.5'
testngVersion = '6.9.12'
assertjVersion = '2.5.0'
slf4jVersion = '1.7.21'
bytebuddyVersion = '1.5.1'
paranamerVersion = '2.8'
jansiVersion = '1.13'
gsonVersion = '2.7'
guavaVersion = '19.0'
springVersion = '4.3.2.RELEASE'
checkstyleVersion = '2.12.1'
jacocoVersion = '0.7.2.201409121644'
quickcheckVersion = '0.6'
}
dependencies {
compile group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
testCompile group: 'org.slf4j', name: 'jcl-over-slf4j', version: slf4jVersion
testCompile group: 'org.slf4j', name: 'slf4j-simple', version: slf4jVersion
testCompile group: 'junit', name: 'junit', version: junitVersion
testCompile group: 'org.assertj', name: 'assertj-core', version: assertjVersion
testCompile group: 'com.tngtech.java', name: 'junit-dataprovider', version: junitDataproviderVersion
testCompile group: 'net.java.quickcheck', name: 'quickcheck', version: quickcheckVersion
signature 'org.codehaus.mojo.signature:java16:1.1@signature'
}
tasks.withType(JavaCompile) {
// needed for DeSzenarioTest.java as it has Umlauts in the code
options.encoding = 'UTF-8'
}
tasks.withType(Jar) {
def now = new Date()
manifest = project.manifest().attributes(
'Built-By': "Gradle ${gradle.gradleVersion}",
'Build-Date': now.format('yyyy-MM-dd HH:mm:ss.S'), // TODO destroys incremental build feature, but maybe date without time is ok as well?
'Copyright': "2013-" + now.format('yyyy') + " TNG Technology Consulting GmbH",
'Implementation-Title': project.name,
'Implementation-Version': project.version,
'Implementation-Vendor': 'TNG Technology Consulting GmbH',
'License': 'Apache License v2.0, January 2004',
'Specification-Title': project.name,
'Specification-Version': project.version,
'Specification-Vendor': 'TNG Technology Consulting GmbH',
)
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives jar
archives javadocJar
archives sourcesJar
}
sonarqube {
properties {
property "sonar.jacoco.reportPath", "${rootProject.projectDir}/build/jacoco/jacocoTest.exec"
}
}
jacocoTestReport {
reports {
xml.enabled = true // coveralls plugin depends on xml format report
}
}
test {
systemProperty 'jgiven.report.dir', 'build/reports/jgiven/json'
systemProperty 'jgiven.report.text', 'false'
systemProperty 'org.slf4j.simpleLogger.defaultLogLevel', 'warn'
jacoco {
destinationFile = file("${rootProject.projectDir}/build/jacoco/jacocoTest.exec")
classDumpFile = file("${rootProject.projectDir}/build/jacoco/classpathdumps")
}
testLogging {
showStandardStreams = true
}
}
javadoc {
exclude '**/impl/**'
}
checkstyle {
configFile = file("${rootProject.projectDir}/develop/checkstyle-rules.xml")
showViolations = false
ignoreFailures = true
}
task jgivenHtml5Report(type: JavaExec) {
main = 'com.tngtech.jgiven.report.ReportGenerator'
args '--sourceDir=build/reports/jgiven/json',
'--targetDir=build/reports/jgiven/html5',
'--format=html5',
'--exclude-empty-scenarios=true',
'--customcss=build/resources/test/jgiven/custom.css'
classpath = configurations.testCompile
}
task jgivenAsciiDocReport(type: JavaExec) {
main = 'com.tngtech.jgiven.report.ReportGenerator'
args '--sourceDir=build/reports/jgiven/json',
'--targetDir=build/reports/jgiven/asciidoc',
'--format=asciidoc'
classpath = configurations.testCompile
}
asciidoctor {
sourceDir = new File('build/reports/jgiven/asciidoc')
outputDir = new File('build/reports/jgiven/htmladoc')
attributes toc: ''
}
task copyAsciiDoc(type: Copy, dependsOn: jgivenAsciiDocReport) {
from 'src/asciidoc'
into 'build/reports/jgiven/asciidoc'
}
copyAsciiDoc.finalizedBy(asciidoctor)
// -- build and publish artifacts -------------------------------------------------------------------------------------
signing {
// requires gradle.properties, see http://www.gradle.org/docs/current/userguide/signing_plugin.html
required {
isReleaseVersion && gradle.taskGraph.hasTask('uploadArchives')
}
sign configurations.archives
}
ext {
sonatypeUsername = (rootProject.hasProperty('sonatypeUsername')) ?
rootProject.sonatypeUsername :
"$System.env.SONATYPE_USERNAME"
sonatypePassword = (rootProject.hasProperty('sonatypePassword')) ?
rootProject.sonatypePassword :
"$System.env.SONATYPE_PASSWORD"
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { deployment ->
signing.signPom(deployment)
}
repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') {
// username and password from gradle.properties
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/') {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
pom {
project {
name project.name
url 'http://jgiven.org'
scm {
url 'scm:git@github.com:TNG/jgiven.git'
connection 'scm:git@github.com:TNG/jgiven.git'
developerConnection 'scm:git@github.com:TNG/jgiven.git'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'janschaefer'
name 'Jan Schäfer'
}
}
}
whenConfigured { pom ->
pom.dependencies.find { dep -> dep.groupId == 'junit' && dep.artifactId == 'junit' }.with {
version = '[4.9,4.12]'
scope = 'provided'
}
pom.dependencies.removeAll(pom.dependencies.findAll { dep -> dep.scope in ['test'] })
}
}
}
}
}
// to be able use project.description which may be overridden in later executed build.gradle of subproject
project.afterEvaluate {
uploadArchives.repositories {
mavenDeployer.pom.project {
description = project.description
}
}
}
uploadArchives.onlyIf {
!(isCI && isReleaseVersion)
}
uploadArchives.doFirst {
if (!isCI && isReleaseVersion && !JavaVersion.current().isJava8Compatible()) {
throw new GradleException("Releases have to be done with Java 8");
}
}
javadoc.onlyIf {
JavaVersion.current().isJava8Compatible()
}
}
task overallJacocoReport(type: JacocoReport) {
executionData = files("build/jacoco/jacocoTest.exec")
sourceDirectories = files("jgiven-core/src/main/java")
classDirectories = files("jgiven-core/build/classes/main")
reports {
xml.enabled = true // coveralls plugin depends on xml format report
html.enabled = true
}
}
overallJacocoReport.dependsOn {
subprojects*.test
}
coveralls.jacocoReportPath = 'build/reports/jacoco/overallJacocoReport/overallJacocoReport.xml'
coveralls.sourceDirs = ["jgiven-core/src/main/java"]
coveralls.saveAsFile = true
buildScan {
licenseAgreementUrl = 'https://gradle.com/terms-of-service'
licenseAgree = 'yes'
}