forked from robstoll/atrium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
519 lines (455 loc) · 19.5 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
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
buildscript {
rootProject.version = '0.9.0-beta-SNAPSHOT'
rootProject.group = 'ch.tutteli.atrium'
def translationProjects = subprojects.findAll { it.projectDir.path.contains("translations") }
def jsSampleProjects = subprojects.findAll {
it.projectDir.parent.endsWith('samples/js') || it.projectDir.parent.endsWith('samples\\js')
}
ext {
// main
kbox_version = '0.13.0'
kbox = { "ch.tutteli.kbox:kbox:$kbox_version" }
niok_version = '1.2.0'
niok = { "ch.tutteli.niok:niok:$niok_version" }
kotlin_version = '1.3.50'
// test
jacoco_tool_version = '0.8.5'
junit_platform_version = '1.5.2'
jupiter_version = '5.5.2'
spek_version = '1.1.5'
spek2_version = '2.0.7'
spekExtensions_version = '0.5.0'
spekExtensions = { "ch.tutteli.spek:tutteli-spek-extensions:$spekExtensions_version" }
mockk_version = '1.9.3'
//TODO remove with 1.0.0
mockito_kotlin_version = '2.2.0'
mockito = { "com.nhaarman.mockitokotlin2:mockito-kotlin:$mockito_kotlin_version" }
//gh-pages.gradle
docProjects = subprojects.findAll {
!it.name.endsWith("-js") &&
!it.name.endsWith("-android") &&
!it.name.contains("robstoll") &&
it.name != "${rootProject.name}-spec" &&
!it.name.startsWith("${rootProject.name}-specs") &&
!(it.projectDir.path.contains("/samples/") || it.projectDir.path.contains("\\samples\\")) &&
!(it.projectDir.path.contains("/misc/tools/") || it.projectDir.path.contains("\\misc\\tools\\"))
}
ghPages_version = rootProject.version
srcKotlin = 'src/main/kotlin'
github_url = "https://github.com/robstoll/${rootProject.name}"
dokka_sourceMapping = "tree/master"
jsSamples = jsSampleProjects
//jacoco-multi-project.gradle
def deprecatedProjects = subprojects.findAll { it.name.endsWith("-deprecated") }
jacocoMulti = [
sourceProjects:
(subprojects - deprecatedProjects).findAll {
!it.name.endsWith("-js") &&
!it.name.endsWith("-android") &&
// would have two classes with the same name if we add it as project as well,
// (clashes with "${project.name}-translations-en_GB-jvm"
it.name != "${rootProject.name}-translations-de_CH-jvm" &&
// does not make sense to listen specs in coverage
it.name != "${rootProject.name}-spec" &&
!it.name.startsWith("${rootProject.name}-specs") &&
!(it.projectDir.path.contains("/samples/") || it.projectDir.path.contains("\\samples\\")) &&
!(it.projectDir.path.contains("/misc/tools/") || it.projectDir.path.contains("\\misc\\tools\\"))
},
jacocoProjects:
(subprojects - deprecatedProjects - translationProjects - jsSampleProjects).findAll {
!it.name.endsWith("-common") &&
!it.name.endsWith("-js") &&
!it.name.endsWith("-android") &&
it.name != "${rootProject.name}-domain-api-jvm" &&
it.name != "${rootProject.name}-domain-robstoll-jvm" &&
it.name != "${rootProject.name}-core-robstoll-jvm" &&
it.name != "${rootProject.name}-spec" &&
!it.name.startsWith("${rootProject.name}-specs") &&
!(it.projectDir.path.contains("/samples/") || it.projectDir.path.contains("\\samples\\")) &&
!(it.projectDir.path.contains("/misc/tools/") || it.projectDir.path.contains("\\misc\\tools\\")) &&
//TODO remove with 1.0.0
it.name != "${rootProject.name}-assertions" &&
it.name != "${rootProject.name}-core-api-deprecated" &&
it.name != "${rootProject.name}-core-robstoll-deprecated" &&
it.name != "${rootProject.name}-domain-api-deprecated"
}
]
srcAndResourcesFromJvmProject = { Project project ->
def nameWithoutSuffix = project.name.substring(project.name.indexOf('-') + 1, project.name.lastIndexOf('-'))
def jvmProject = prefixedProject(nameWithoutSuffix + '-jvm')
project.sourceSets {
main {
kotlin.srcDirs += "${jvmProject.projectDir}/src/main/kotlin"
resources.srcDirs += "${jvmProject.projectDir}/src/main/resources"
}
test {
java.srcDirs += "${jvmProject.projectDir}/src/test/java"
kotlin.srcDirs += ["${jvmProject.projectDir}/src/test/kotlin", "${jvmProject.projectDir}/src/test/java"]
resources.srcDirs += "${jvmProject.projectDir}/src/test/resources"
}
}
}
}
repositories {
mavenCentral()
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "ch.tutteli:tutteli-gradle-dokka:$gradle.ext.tutteli_plugins_version"
classpath "ch.tutteli:tutteli-gradle-kotlin-module-info:$gradle.ext.tutteli_plugins_version"
classpath "ch.tutteli:tutteli-gradle-kotlin-utils:$gradle.ext.tutteli_plugins_version"
classpath "ch.tutteli:tutteli-gradle-project-utils:$gradle.ext.tutteli_plugins_version"
classpath "ch.tutteli:tutteli-gradle-publish:$gradle.ext.tutteli_plugins_version"
classpath "ch.tutteli:tutteli-gradle-spek:$gradle.ext.tutteli_plugins_version"
classpath 'com.moowork.gradle:gradle-node-plugin:1.3.1'
}
}
apply plugin: "ch.tutteli.project.utils"
apply plugin: 'ch.tutteli.kotlin.utils'
kotlinutils.kotlinVersion = kotlin_version
repositories {
mavenCentral()
jcenter()
}
configurations{
dependabot
}
dependencies {
// helps dependabot to recognise versions which it should update
dependabot "org.jacoco:org.jacoco.core:$jacoco_tool_version"
dependabot "org.junit.jupiter:junit-jupiter-engine:$jupiter_version"
dependabot "org.junit.platform:junit-platform-console:$junit_platform_version"
dependabot "ch.tutteli.spek:tutteli-spek-extensions:$spekExtensions_version"
dependabot "ch.tutteli.niok:niok:$niok_version"
dependabot "ch.tutteli.kbox:kbox:$kbox_version"
//TODO remove with 1.0.0
dependabot "com.nhaarman.mockitokotlin2:mockito-kotlin:$mockito_kotlin_version"
}
subprojects {
repositories {
mavenCentral()
jcenter()
maven {
url 'https://dl.bintray.com/spekframework/spek'
content {
includeGroupByRegex 'org\\.spekframework(\\..*)?'
}
}
maven {
url "https://dl.bintray.com/spekframework/spek-dev"
content {
includeGroupByRegex 'org\\.spekframework(\\..*)?'
}
}
maven {
url "https://dl.bintray.com/robstoll/tutteli-jars"
content {
includeGroupByRegex 'ch\\.tutteli(\\..*)?'
}
}
}
}
def commonProjects = getCommonProjects()
def jsProjects = getJsProjects()
def jvmProjects = getJvmProjects()
def multiplatformProjects = commonProjects + jsProjects + jvmProjects
configureCommonProjects()
configureAndroidProjects()
configureJsProjects()
configureJvmProjects()
configure(subprojects - multiplatformProjects - jsSamples) {
apply plugin: 'kotlin'
dependencies {
implementation kotlinStdlib()
}
}
configure(commonProjects) {
compileKotlinCommon {
kotlinOptions.languageVersion = '1.2'
}
compileTestKotlinCommon {
//TODO activate as soon as https://youtrack.jetbrains.com/issue/KT-30580 is fixed
kotlinOptions.allWarningsAsErrors = false
}
}
configure(jsProjects) { subProject ->
compileKotlin2Js {
kotlinOptions {
if (subProject.name.startsWith("atrium-translations")) {
//necessary as the module name is then also called atrium-translations-js and can be shared (the name) by the other translation modules
outputFile = "$buildDir/classes/kotlin/main/atrium-translations-js.js"
}
languageVersion = '1.2'
}
}
compileTestKotlin2Js {
//TODO activate as soon as https://youtrack.jetbrains.com/issue/KT-21348 is fixed
kotlinOptions.allWarningsAsErrors = false
}
}
configure(subprojects - commonProjects - jsProjects - jsSamples) {
apply plugin: 'ch.tutteli.dokka'
apply plugin: 'ch.tutteli.kotlin.module.info'
dokka {
logging.setLevel(LogLevel.QUIET)
}
compileKotlin {
kotlinOptions {
languageVersion = '1.2'
//TODO activate as soon as https://youtrack.jetbrains.com/issue/KT-34257 is fixed
allWarningsAsErrors = false
}
}
}
//allow kotlin 1.3 for kotlin_1_3 modules
configure(subprojects.findAll { it.name.endsWith('-kotlin_1_3-common')}){
compileKotlinCommon.kotlinOptions.languageVersion = '1.3'
}
configure(subprojects.findAll { it.name.endsWith('-kotlin_1_3-android')}){
compileKotlin.kotlinOptions.languageVersion = '1.3'
}
configure(subprojects.findAll { it.name.endsWith('-kotlin_1_3-js')}){
compileKotlin2Js.kotlinOptions.languageVersion = '1.3'
}
configure(subprojects.findAll { it.name.endsWith('-kotlin_1_3-jvm')}){
compileKotlin.kotlinOptions.languageVersion = '1.3'
}
def apiProjects = subprojects.findAll { it.name.startsWith("${rootProject.name}-api") && it.name.endsWith("-jvm") }
configure(apiProjects) { apiProject ->
createTestJarTask(apiProject)
createTestSourcesJarTask(apiProject)
}
def bundleSmokeTests = subprojects.findAll { it.name.endsWith('smoke-test') }
def sampleProjects = subprojects.findAll {
it.projectDir.path.contains('/samples/') || it.projectDir.path.contains('\\samples\\')
}
configure(subprojects - bundleSmokeTests - sampleProjects) { subproject ->
apply plugin: 'ch.tutteli.publish'
tutteliPublish {
resetLicenses 'EUPL-1.2'
}
}
configure(jacocoMulti.jacocoProjects + getAndroidProjects()) {
apply plugin: 'ch.tutteli.spek'
spek.version = '1.1.5'
dependencies {
testImplementation mockito(), excludeKotlin
}
afterEvaluate {
junitjacoco {
jacoco {
toolVersion = jacoco_tool_version
}
jacocoReport {
if (project.hasProperty('jacoco_additional')) {
project.jacoco_additional.each { otherProject ->
sourceSets otherProject.sourceSets.main
}
}
reports {
html.enabled = true
}
}
}
}
test {
//TODO remove once all specs are migrated to spek2
options {
if (project.name != 'atrium-spec') {
includeEngines 'spek2'
}
if (!project.name.startsWith('atrium-specs')) {
includeEngines 'spek'
}
}
}
}
apply from: 'gradle/scripts/gh-pages.gradle'
apply from: 'gradle/scripts/jacoco-multi-project.gradle'
configure(bundleSmokeTests) {
def bundleUnderTest = it.name.substring(0, it.name.indexOf('-smoke-test'))
Project bundle = project(":$bundleUnderTest-jvm")
description = "Represents a JDK >= 9 smoke test for $bundleUnderTest"
sourceCompatibility = JavaVersion.current()
targetCompatibility = JavaVersion.current()
ext.jacoco_additional = [bundle]
sourceSets {
//we are reusing the source from the bundle, so that we do not have to re-invent the spec
test { kotlin { srcDirs += ["${bundle.projectDir}/src/test/kotlin"] } }
}
dependencies {
//I don't see how to set up compileTestKotlin with --patch-module, so we have put the module-info.java directly in src/test/kotlin instead
testImplementation bundle
testImplementation prefixedProject('verbs-jvm')
}
}
import java.util.function.Function
def createRegisterJsServicesTask(String projectName, String packageName, Function<String, Boolean> filter) {
Project project = prefixedProject(projectName)
configure(project) {
def registerJsServices = project.tasks.create(name: 'generateJsRegisterServices', group: 'build') {
def jvm = "${getProjectNameWithoutSuffix(project)}-jvm"
def servicesDir = project.file("../$jvm/src/main/resources/META-INF/services/")
def services = project.file("$srcKotlin/${packageName.replace('.', '/')}/registerServices.kt")
inputs.dir servicesDir
inputs.file services
outputs.file services
doLast {
services.write("""\
@file:Suppress("DEPRECATION")
package $packageName
import ch.tutteli.atrium.core.polyfills.registerService
@Suppress("unused" /* here in order that the code is executed when module is loaded */)
private val register = run {
""".stripIndent())
def sortedMap = new TreeMap<String, String>()
servicesDir.traverse {
if (it.isFile() && filter.apply(it.name)) {
sortedMap.put(it.name, it.withReader { it.readLine() })
}
}
sortedMap.each { entry ->
services.append("\n registerService<")
services.append(entry.key)
services.append("> { ")
services.append(entry.value)
services.append("() }")
}
services.append("\n}\n")
}
}
compileKotlin2Js.dependsOn registerJsServices
}
}
createRegisterJsServicesTask('core-robstoll-js', 'ch.tutteli.atrium.core.robstoll') { true }
createRegisterJsServicesTask('domain-robstoll-js', 'ch.tutteli.atrium.domain.robstoll') {
!(it in [
'ch.tutteli.atrium.domain.creating.BigDecimalAssertions',
'ch.tutteli.atrium.domain.creating.OptionalAssertions',
'ch.tutteli.atrium.domain.creating.PathAssertions',
'ch.tutteli.atrium.domain.creating.LocalDateAssertions',
'ch.tutteli.atrium.domain.creating.LocalDateTimeAssertions',
'ch.tutteli.atrium.domain.creating.ZonedDateTimeAssertions'
])
}
createRegisterJsServicesTask('domain-builders-js', 'ch.tutteli.atrium.domain.builders') { true }
createRegisterJsServicesTask('verbs-internal-js', 'ch.tutteli.atrium.verbs.internal') { true }
List<Project> projectNamesToProject(String[] names) {
names.collect { projectName -> prefixedProject(projectName) }
}
def createJsTestTask(String... subprojectNames) {
configure(projectNamesToProject(subprojectNames)) {
apply plugin: 'com.moowork.node'
compileTestKotlin2Js.configure {
kotlinOptions.moduleKind = "commonjs"
kotlinOptions.sourceMap = true
kotlinOptions.sourceMapEmbedSources = "always"
}
task populateNodeModules(type: Copy, dependsOn: compileKotlin2Js) {
from compileKotlin2Js.destinationDir
prefixedProject('verbs-internal-js').afterEvaluate {
configurations.testRuntimeClasspath.each {
from zipTree(it.absolutePath).matching { include '*.js', '*.js.map' }
}
}
into "${buildDir}/node_modules"
}
def nodeModulesParentDir = file("$rootProject.projectDir/gradle/")
node {
download = true
npmVersion = '6.4.1'
workDir = file("$rootProject.projectDir/.gradle/nodejs")
npmWorkDir = file("$rootProject.projectDir/.gradle/npm")
nodeModulesDir = nodeModulesParentDir
}
task installMocha(type: NpmTask) {
args = ['install', 'mocha', '--prefer-offline']
}
task prepareMocha(dependsOn: [compileTestKotlin2Js, populateNodeModules, installMocha])
task runMocha(type: NodeTask, dependsOn: [prepareMocha, test]) {
script = file("$nodeModulesParentDir/node_modules/mocha/bin/mocha")
args = [compileTestKotlin2Js.outputFile]
}
check.dependsOn runMocha
}
}
createJsTestTask(
'core-api-js',
'core-robstoll-lib-js',
'fluent-en_GB-js',
//TODO remove with 1.0.0
'cc-de_CH-robstoll-js',
'cc-en_GB-robstoll-js',
'cc-infix-en_GB-robstoll-js',
)
def useJupiter(String... projectNames) {
configure(projectNamesToProject(projectNames)) {
dependencies {
testRuntime "org.junit.jupiter:junit-jupiter-engine:$jupiter_version"
}
test {
options {
includeEngines 'junit-jupiter'
}
}
}
}
useJupiter(
'core-api-jvm',
'cc-de_CH-robstoll-jvm',
'cc-en_GB-robstoll-jvm',
'cc-infix-en_GB-robstoll-jvm',
)
//TODO merge with above as soon as https://youtrack.jetbrains.com/issue/KT-29069 is fixed
if (System.getenv('CI')) {
useJupiter(
'core-api-android',
'cc-de_CH-robstoll-android',
'cc-en_GB-robstoll-android',
'cc-infix-en_GB-robstoll-android',
)
}
def jvmBuild = task('jvmBuild', group: build, description: 'builds all JVM modules')
jvmBuild.dependsOn(jacocoMulti.jacocoProjects.collect { it.build })
/*
Release & deploy a commit
--------------------------------
1. change rootProject.version in build.gradle to X.Y.Z
2. update master:
a) point to the tag
1) search for old version and replace with new (gradle, maven and section own assertion verb in README.md)
2) search for branch/master and replace with branch/vX.Y.Z (build status and coverage in README.md)
3) adjust branch=master manually, use tag=vX.Y.Z except for travis where you need to use branch=vX.Y.Z
4) search for `tree/master` and replace it with `tree/vX.Y.Z` (README.md)
5) search for `latest#/doc` and replace with `X.Y.Z/doc` (README.md and differences.md)
6) Remove the warning in README.md about taking a sneak peak (copy it, well be added afterwards)
b) Update README -> Use own Assertion Verbs -> link to atriumVerbs if it changed
c) commit & push (modified build.gradle, README.md and differences.md)
3. update github pages:
a) gr ghPages
b) change version number in atrium-gh-pages/latest/index.html
c) add new version to atrium-gh-pages/README.md
d) commit & push changes
4. deploy to bintray:
// export CI=true is a temporary work around till https://youtrack.jetbrains.com/issue/KT-29069 is fixed:
a) java -version 2>&1 | grep "version \"9" && CI=true ./gr clean publishToBintray
b) Log in to bintray, check and publish new jars
5. create release on github
a) git tag vX.Y.Z
b) git push origin vX.Y.Z
c) Log in to github and create release
Prepare next dev cycle
-----------------------
1. change rootProject.version in build.gradle to X.Y.Z-SNAPSHOT
2. point to master
a) search for `tag=vX.Y.Z` and replace it with `branch=master`
b) search for `tree/vX.Y.Z` and replace it with `tree/master`
c) search for `X.Y.Z/doc` and replace with `latest#/doc`
3. update README
a) place the warning about taking a sneak peek back into README
b) update version in the warning to X.Y.Z and update the link as well
4. commit & push changes
5. establish backward compatibility tests for the previous version
*/