mirror of
https://github.com/jlengrand/atrium.git
synced 2026-03-10 08:01:19 +00:00
474 lines
17 KiB
Groovy
474 lines
17 KiB
Groovy
buildscript {
|
|
rootProject.version = '0.9.0-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 = '0.3.1'
|
|
niok = { "ch.tutteli.niok:niok:$niok_version" }
|
|
kotlin_version = '1.3.50'
|
|
|
|
// test
|
|
jacoco_tool_version = '0.8.2'
|
|
junit_platform_version = '1.5.1'
|
|
jupiter_version = '5.5.1'
|
|
spek_version = '1.1.5'
|
|
spek2_version = '2.0.6'
|
|
spekExtensions = { 'ch.tutteli.spek:tutteli-spek-extensions:0.4.1' }
|
|
mockk_version = '1.9.3'
|
|
|
|
//TODO remove with 1.0.0
|
|
mockito_kotlin_version = '2.1.0'
|
|
mockito = { "com.nhaarman.mockitokotlin2:mockito-kotlin:$mockito_kotlin_version" }
|
|
|
|
//gh-pages.gradle
|
|
docProjects = subprojects.findAll {
|
|
!it.name.contains("robstoll") &&
|
|
it.name != "${rootProject.name}-spec" &&
|
|
!it.name.startsWith("${rootProject.name}-specs")
|
|
}
|
|
ghPages_version = rootProject.version
|
|
dokka_sourceMapping = 'tree/master'
|
|
srcKotlin = 'src/main/kotlin'
|
|
github_url = "https://github.com/robstoll/${rootProject.name}"
|
|
|
|
|
|
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.path.contains('examples')
|
|
},
|
|
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.name != "${rootProject.name}-bc-test" &&
|
|
!it.path.contains('examples') &&
|
|
//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()
|
|
}
|
|
|
|
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()
|
|
configureJsProjects()
|
|
configureJvmProjects()
|
|
configureAndroidProjects()
|
|
|
|
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'
|
|
compileKotlin {
|
|
kotlinOptions.languageVersion = '1.2'
|
|
}
|
|
}
|
|
|
|
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 = jsSamples
|
|
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'
|
|
|
|
compileKotlin {
|
|
kotlinOptions.allWarningsAsErrors = true
|
|
}
|
|
|
|
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'
|
|
|
|
configure(bundleSmokeTests) {
|
|
def bundleUnderTest = it.name.substring(0, it.name.indexOf('-smoke-test'))
|
|
Project bundle = bundleUnderTest.endsWith("-jdk8")
|
|
? project(":$bundleUnderTest")
|
|
: 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.PathAssertions'
|
|
])
|
|
}
|
|
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:
|
|
a) Temporary work around till https://youtrack.jetbrains.com/issue/KT-29069 is fixed:
|
|
export CI=true
|
|
b) gr clean publishToBintray
|
|
c) 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 `branch=vX.Y.Z` and replace it with `branch=master`
|
|
c) search for `branch/vX.Y.Z` and replace it with `branch/master`
|
|
d) search for `tree/vX.Y.Z` and replace it with `tree/master`
|
|
e) 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
|
|
*/
|