migrate atrium-core to the new MPP plugin

This commit is contained in:
Robert Stoll
2021-04-19 23:47:23 +02:00
parent 33062265bc
commit f21b2a0f81
37 changed files with 412 additions and 141 deletions

View File

@@ -1,4 +1,4 @@
description = 'A fluent assertion function API in en_GB with a focus on code completion as common module.'
description = "A fluent assertion function API in en_GB with a focus on code completion as common module."
dependencies {
api prefixedProject('logic-common')

View File

@@ -3,7 +3,7 @@ description = 'A fluent assertion function API in en_GB with a focus on code com
ext.jacoco_additional = [
prefixedProject('translations-en_GB-jvm'),
prefixedProject('logic-jvm'),
prefixedProject('core-jvm'),
prefixedProject("core"),
]
dependencies {

View File

@@ -3,7 +3,7 @@ description = 'An infix API in en_GB with a focus on code completion for JVM.'
ext.jacoco_additional = [
prefixedProject('translations-de_CH-jvm'),
prefixedProject('logic-jvm'),
prefixedProject('core-jvm'),
prefixedProject("core"),
]
dependencies {

View File

@@ -0,0 +1,42 @@
description = "Core module of Atrium, containing all contracts/interfaces and default implementations"
val kboxVersion: String by rootProject.extra
kotlin {
sourceSets {
val commonMain by getting {
dependencies {
apiWithExclude("ch.tutteli.kbox:kbox-common:$kboxVersion")
}
}
val commonTest by getting {
dependencies {
implementation(prefixedProject("api-infix-en_GB-common"))
implementation(prefixedProject("specs-common"))
}
}
val jvmMain by getting {
dependencies {
apiWithExclude("ch.tutteli.kbox:kbox:$kboxVersion")
}
}
val jvmTest by getting {
dependencies {
implementation(prefixedProject("api-infix-en_GB-jvm"))
implementation(prefixedProject("specs-jvm"))
}
}
//TODO 0.17.0 activate again as soon as api-infix has a js module
// val jsMain by getting {
// dependencies {
// apiWithExclude("ch.tutteli.kbox:kbox-js:$kboxVersion")
// }
// }
// val jsTest by getting {
// dependencies {
// implementation(prefixedProject("api-infix-en_GB-js"))
// implementation(prefixedProject("specs-js"))
// }
// }
}
}

View File

@@ -6,13 +6,13 @@ buildscript {
// project setup
tutteli_plugins_version = '0.33.1'
kotlin_version = '1.3.72'
kotlinVersion = '1.3.72'
}
repositories {
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "ch.tutteli:tutteli-gradle-spek:$tutteli_plugins_version"
}
}

View File

@@ -7,30 +7,33 @@ buildscript {
}
ext {
// main
kbox_version = '0.15.1'
kbox = { "ch.tutteli.kbox:kbox:$kbox_version" }
kboxVersion = '0.15.1'
kbox = { "ch.tutteli.kbox:kbox:$kboxVersion" }
niokVersion = '1.4.1'
niok = { "ch.tutteli.niok:niok:$niokVersion" }
kotlin_version = '1.3.72'
kotlinVersion = '1.3.72'
// test
jacocoToolVersion = '0.8.6'
junitPlatformVersion = '1.7.1'
jupiterVersion = '5.7.1'
spek2Version = '2.0.12'
spekVersion = '2.0.12'
spekExtensionsVersion = '1.2.1'
spekExtensions = { "ch.tutteli.spek:tutteli-spek-extensions:$spekExtensionsVersion" }
mockkVersion = '1.10.0'
//TODO remove with 1.0.0
mockito_kotlin_version = '2.2.0'
mockito = { "com.nhaarman.mockitokotlin2:mockito-kotlin:$mockito_kotlin_version" }
mockitoKotlinVersion = '2.2.0'
mockito = { "com.nhaarman.mockitokotlin2:mockito-kotlin:$mockitoKotlinVersion" }
// project setup
tutteli_plugins_version = '0.33.1'
node_plugin_version = '2.2.0'
d8_version = '1.6.84'
//TODO 0.17.0 add all modules and remove this afterwards
newMultiplatformProjectNames = ["core"]
// gh-pages.gradle
docProjects = (subprojects - toolProjectsFun).findAll {
!it.name.endsWith("-js") &&
@@ -90,7 +93,7 @@ buildscript {
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "ch.tutteli:tutteli-gradle-dokka:$tutteli_plugins_version"
classpath "ch.tutteli:tutteli-gradle-kotlin-module-info:$tutteli_plugins_version"
classpath "ch.tutteli:tutteli-gradle-kotlin-utils:$tutteli_plugins_version"
@@ -103,7 +106,7 @@ buildscript {
apply plugin: "ch.tutteli.project.utils"
apply plugin: 'ch.tutteli.kotlin.utils'
kotlinutils.kotlinVersion = kotlin_version
kotlinutils.kotlinVersion = kotlinVersion
repositories {
mavenCentral()
@@ -121,10 +124,10 @@ dependencies {
dependabot "org.junit.platform:junit-platform-console:$junitPlatformVersion"
dependabot "ch.tutteli.spek:tutteli-spek-extensions:$spekExtensionsVersion"
dependabot "ch.tutteli.niok:niok:$niokVersion"
dependabot "ch.tutteli.kbox:kbox:$kbox_version"
dependabot "ch.tutteli.kbox:kbox:$kboxVersion"
//TODO remove with 1.0.0
dependabot "com.nhaarman.mockitokotlin2:mockito-kotlin:$mockito_kotlin_version"
dependabot "com.nhaarman.mockitokotlin2:mockito-kotlin:$mockitoKotlinVersion"
}
@@ -139,17 +142,191 @@ subprojects {
def commonProjects = getCommonProjects()
def jsProjects = getJsProjects()
def jvmProjects = getJvmProjects()
def multiplatformProjects = commonProjects + jsProjects + jvmProjects
def oldMultiplatformProjects = commonProjects + jsProjects + jvmProjects
def newMultiplatformProjects = newMultiplatformProjectNames.collect { prefixedProject(it) }
configure(newMultiplatformProjects) { subproject ->
apply plugin: "kotlin-multiplatform"
//TODO 0.17.0 move sources to default path once all modules have been migrated
def oldParent = "../${subproject.name.substring("atrium-".length())}"
def oldCommon = "$oldParent/${subproject.name}-common"
def oldJvm = "$oldParent/${subproject.name}-jvm"
def oldJs = "$oldParent/${subproject.name}-js"
kotlin {
jvm {
compilations.main.kotlinOptions {
//TODO 0.18.0 activate once we drop support for jdk 1.6
// jvmTarget = "1.8"
}
//for module-info.java
withJava()
def testProvider = testRuns["test"].executionTask
testProvider.configure {
useJUnitPlatform {
includeEngines("spek2", "junit-jupiter")
}
}
}
//TODO 0.17.0 activate as soon as all modules have been transitioned to new MPP
// js {
// nodejs()
// }
targets.all {
compilations.all {
kotlinOptions.allWarningsAsErrors = true
}
}
sourceSets {
commonMain {
dependencies {
//TODO remove once we update to kotlin 1.4 where this should be included automatically
//TODO switch to stdlib-jdk8 with 0.18.0
api(kotlin("stdlib-common"))
api(kotlin("reflect"))
}
}
commonTest {
dependencies {
implementation kotlin('test-common')
implementation kotlin('test-annotations-common')
}
}
jvmTest {
dependencies {
implementation kotlin('test-junit')
runtimeOnly "org.junit.jupiter:junit-jupiter-engine:$jupiterVersion"
implementation("org.spekframework.spek2:spek-dsl-jvm:$spekVersion") {
exclude group: 'org.jetbrains.kotlin'
}
runtimeOnly("org.spekframework.spek2:spek-runner-junit5:$spekVersion") {
exclude group: 'org.jetbrains.kotlin'
}
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
runtimeOnly "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion" //spek requires reflect
}
}
jsTest {
dependencies {
implementation kotlin('test-js')
}
}
all {
languageSettings {
languageVersion = '1.2'
apiVersion = '1.2'
useExperimentalAnnotation('kotlin.Experimental')
}
}
configureEach {
if (it.name.endsWith("Test")) {
languageSettings {
languageVersion = '1.3'
apiVersion = '1.3'
}
}
}
//TODo v0.17.0 switch to default folder layout once everything is migrated
commonMain {
kotlin.srcDir("$oldCommon/src/main/kotlin")
resources.srcDir("$oldCommon/src/main/resources")
}
commonTest {
kotlin.srcDir("$oldCommon/src/test/kotlin")
resources.srcDir("$oldCommon/src/test/resources")
}
jvmMain {
kotlin.srcDir("$oldJvm/src/main/kotlin")
resources.srcDir("$oldJvm/src/main/resources")
}
jvmTest {
kotlin.srcDir("$oldJvm/src/test/kotlin")
resources.srcDir("$oldJvm/src/test/resources")
}
jsMain {
kotlin.srcDir("$oldJs/src/main/kotlin")
resources.srcDir("$oldJs/src/main/resources")
}
jsTest {
kotlin.srcDir("$oldJs/src/test/kotlin")
resources.srcDir("$oldJs/src/test/resources")
}
}
}
//calling the Kotlin extension function in buildSrc
ConfigureTestTasksKt.configureTestTasks(subproject)
//TODO 0.17.0 or 0.18.0 source out to gradle-tutteli-plugins again
if (JavaVersion.current() >= JavaVersion.VERSION_1_9) {
if (subproject.components.findByName('java') == null) throw new IllegalStateException("""\
Could not find the java component.
Did you forget to apply the kotlin plugin? Make sure it is applied before this plugin.
""".stripIndent()
)
sourceCompatibility = 8
targetCompatibility = 8
//TODO 0.17.0 remove oldJvm once we move files to the default folder of jvmMain
def srcModule = "$oldJvm/src/module"
def moduleInfo = subproject.file("$srcModule/module-info.java")
if (moduleInfo.exists()) {
//TODO simplify to the following (or similar) once we drop support for jdk8
// compileJava {
// options.compilerArgs = [
// "--patch-module", "ch.tutteli.atrium.core.api=${subproject.sourceSets.main.output.asPath}"
// ]
// }
subproject.sourceSets {
module {
java {
srcDirs = [srcModule]
compileClasspath = main.compileClasspath
}
}
main {
kotlin { srcDirs += [srcModule] }
}
}
subproject.compileModuleJava.configure {
dependsOn subproject.jvmMainClasses
//TODO 0.17.0 use this as soon as sources are in default folder for jvmMain
destinationDir = subproject.kotlin.jvm().compilations.main.output.classesDirs.getFiles().findAll { it.getPath().contains("kotlin") }[0]
// destinationDir = project.compileKotlin.destinationDir
sourceCompatibility = 9
targetCompatibility = 9
doFirst {
options.compilerArgs = ['--module-path', classpath.asPath]
classpath = subproject.files()
}
}
subproject.tasks.getByName('jvmJar').dependsOn subproject.compileModuleJava
}
}
}
//TODO 0.17.0 cleanup this file once we have transitioned all modules to the new MPP plugin
configureCommonProjects()
configureAndroidProjects()
configureJsProjects()
configureJvmProjects()
configure(subprojects.findAll {
def parentName = it.projectDir.parentFile.name
it.name != "bc-tests" && parentName != "old" && parentName != "bc-tests"
} - multiplatformProjects) {
} - oldMultiplatformProjects - newMultiplatformProjects) {
apply plugin: 'kotlin'
dependencies {
implementation kotlinStdlib()
@@ -183,7 +360,10 @@ configure(jsProjects) { subProject ->
}
def nonCommonAndJsProjects = subprojects - commonProjects - jsProjects
configure(nonCommonAndJsProjects - toolProjects) { Project subproject ->
//TODO 0.17.0 configure dokka plugins again also for newMultiplatformProjects
configure(nonCommonAndJsProjects - toolProjects - newMultiplatformProjects) { Project subproject ->
apply plugin: 'ch.tutteli.dokka'
apply plugin: 'ch.tutteli.kotlin.module.info'
@@ -222,7 +402,7 @@ def apiProjects = subprojects.findAll {
it.name.startsWith("${rootProject.name}-api") &&
(it.name.endsWith("-jvm") ||
(it.name.endsWith("-common") && (it.name.contains("api-fluent-") || it.name.contains("api-infix-")))
)
)
}
//testJar and testSourcesJar for bc-tests
configure(apiProjects) { apiProject ->
@@ -232,7 +412,8 @@ configure(apiProjects) { apiProject ->
def bundleSmokeTests = subprojects.findAll { it.name.contains('-smoke-test') }
configure(subprojects - bundleSmokeTests - toolProjects) { subproject ->
//TODO 0.17.0 newMultiPlatformProject have to be published differently
configure(subprojects - bundleSmokeTests - toolProjects - newMultiplatformProjects - jsProjects) { subproject ->
apply plugin: 'ch.tutteli.publish'
tutteliPublish {
@@ -240,9 +421,10 @@ configure(subprojects - bundleSmokeTests - toolProjects) { subproject ->
}
}
configure(jacocoMulti.jacocoProjects + getAndroidProjects()) {
//TODO 0.17.0 spek is used in another way, see above, but we have not yet applied the jacoco plugin
configure(jacocoMulti.jacocoProjects + getAndroidProjects() - newMultiplatformProjects) {
apply plugin: 'ch.tutteli.spek'
spek.version = spek2Version
spek.version = spekVersion
dependencies {
testImplementation mockito(), excludeKotlin
@@ -269,7 +451,9 @@ configure(jacocoMulti.jacocoProjects + getAndroidProjects()) {
}
}
configure(subprojects - toolProjects) {
//this is already configured for newMultiplatformProjects further above, thus the substraction
configure(subprojects - toolProjects - newMultiplatformProjects) {
sourceSets {
all {
languageSettings {
@@ -364,13 +548,15 @@ def createJsTestTask(String... subprojectNames) {
}
}
createJsTestTask(
'core-js',
'api-fluent-en_GB-js',
'api-infix-en_GB-js',
'fluent-en_GB-js',
'infix-en_GB-js'
)
//TODO 0.17.0 this setup should no longer be necessary with the new js plugin, check once you re-activate JS target
// if this is true, then remove the definition below including createJsTestTask above
//createJsTestTask(
// 'core-js',
// 'api-fluent-en_GB-js',
// 'api-infix-en_GB-js',
// 'fluent-en_GB-js',
// 'infix-en_GB-js'
//)
def useJupiter(String... projectNames) {
configure(projectNamesToProject(projectNames)) {
@@ -386,7 +572,8 @@ def useJupiter(String... projectNames) {
}
useJupiter(
'core-jvm',
//TODO setup jupiter tests in a different way for new MPP
// 'core-jvm',
'api-fluent-en_GB-jvm',
'api-infix-en_GB-jvm',
)

10
buildSrc/build.gradle.kts Normal file
View File

@@ -0,0 +1,10 @@
plugins {
`kotlin-dsl`
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin")
}

View File

@@ -0,0 +1,63 @@
import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.gradle.api.tasks.testing.TestListener
import org.gradle.api.tasks.testing.*
import org.gradle.api.tasks.testing.Test
import org.gradle.kotlin.dsl.*
// TODO 0.17.0 or 0.18.0 move to tutteli-gradle-plugin
fun Project.configureTestTasks() {
fun memoizeTestFile(testTask: Test) =
project.file("${project.buildDir}/test-results/memoize-previous-state-${testTask.name}.txt")
tasks.withType<Test> {
testLogging {
events(
TestLogEvent.FAILED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_OUT,
TestLogEvent.STANDARD_ERROR
)
exceptionFormat = TestExceptionFormat.FULL
showExceptions = true
showCauses = true
showStackTraces = true
}
val testTask = this
addTestListener(object : TestListener {
override fun beforeSuite(suite: TestDescriptor) {}
override fun beforeTest(testDescriptor: TestDescriptor) {}
override fun afterTest(testDescriptor: TestDescriptor, result: TestResult) {}
override fun afterSuite(suite: TestDescriptor, result: TestResult) {
if (suite.parent == null) {
if (result.testCount == 0L) {
throw GradleException("No tests executed, most likely the discovery failed.")
}
println("Result: ${result.resultType} (${result.successfulTestCount} succeeded, ${result.failedTestCount} failed, ${result.skippedTestCount} skipped)")
memoizeTestFile(testTask).writeText(result.resultType.toString())
}
}
})
}
tasks.withType<Test>().forEach { testTask ->
val failIfTestFailedLastTime =
tasks.register("fail-if-${testTask.name}-failed-last-time") {
doLast {
if (!testTask.didWork) {
val memoizeTestFile = memoizeTestFile(testTask)
if (memoizeTestFile.exists() && memoizeTestFile.readText() == TestResult.ResultType.FAILURE.toString()) {
val allTests = tasks.getByName("allTests") as TestReport
throw GradleException(
"test failed in last run, execute clean${testTask.name} to force its execution\n" +
"See the following report for more information:\nfile://${allTests.destinationDir}/index.html"
)
}
}
}
}
testTask.finalizedBy(failIfTestFailedLastTime)
}
}

View File

@@ -0,0 +1,14 @@
import org.gradle.api.Project
import org.gradle.api.artifacts.ExternalModuleDependency
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
fun Project.prefixedProject(name: String): Project = project(":${rootProject.name}-$name")
fun KotlinDependencyHandler.apiWithExclude(dep: String) = api(dep) { defaultExclude() }
fun KotlinDependencyHandler.implementationWithExclude(dep: String) = implementation(dep) { defaultExclude() }
fun KotlinDependencyHandler.runtimeOnlyWithExclude(dep: String) = runtimeOnly(dep) { defaultExclude() }
fun ExternalModuleDependency.defaultExclude() {
exclude(mapOf("group" to "org.jetbrains.kotlin"))
exclude(mapOf("group" to "ch.tutteli.kbox"))
}

View File

@@ -4,7 +4,7 @@ ext.jacoco_additional = [
prefixedProject('verbs-jvm'),
prefixedProject('translations-en_GB-jvm'),
prefixedProject('logic-jvm'),
prefixedProject('core-jvm'),
prefixedProject("core"),
]
dependencies {

View File

@@ -4,5 +4,5 @@ dependencies {
api prefixedProject('verbs-common')
api prefixedProject('api-infix-en_GB-common')
api prefixedProject('translations-en_GB-common')
api prefixedProject('core-common')
api prefixedProject("core")
}

View File

@@ -4,5 +4,5 @@ dependencies {
api prefixedProject('verbs-js')
api prefixedProject('api-infix-en_GB-js')
api prefixedProject('translations-en_GB-js')
api prefixedProject('core-js')
api prefixedProject("core")
}

View File

@@ -4,12 +4,12 @@ ext.jacoco_additional = [
prefixedProject('verbs-jvm'),
prefixedProject('translations-en_GB-jvm'),
prefixedProject('logic-jvm'),
prefixedProject('core-jvm'),
prefixedProject("core"),
]
dependencies {
api prefixedProject('verbs-jvm')
api prefixedProject('api-infix-en_GB-jvm')
api prefixedProject('translations-en_GB-jvm')
api prefixedProject('core-jvm')
api prefixedProject("core")
}

View File

@@ -14,7 +14,11 @@ def dexerProjects = getJvmProjects().findAll {
configure(dexerProjects) { subproject ->
configurations {
r8
d8
d8 {
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_RUNTIME))
}
}
}
repositories {
google()

View File

@@ -15,7 +15,7 @@ task copyIndex(type: Copy) {
task copyCSS(type: Copy) {
from "$ghPagesPathWithoutVersion/style.css"
into ghPagesPath
into ghPagesPath
}
task removeGhPages {
@@ -24,8 +24,12 @@ task removeGhPages {
}
}
//TODO 0.17.0 configure dokka differently
def newMultiplatformProjects = newMultiplatformProjectNames.collect { prefixedProject(it) }
def projectsToConsider = docProjects - newMultiplatformProjects
task ghPages {
docProjects.forEach { subProject ->
projectsToConsider.forEach { subProject ->
def jar = subProject.tasks.findByName("jar")
dependsOn jar
dokka.mustRunAfter jar
@@ -56,10 +60,10 @@ dokka {
suffix = '#L'
}
samples = findSamples(docProjects)
samples = findSamples(projectsToConsider)
sourceDirs = docProjects.collect { subProject -> file("${subProject.projectDir}/$srcKotlin") }
rootProject.configure(docProjects) { subProject ->
sourceDirs = projectsToConsider.collect { subProject -> file("${subProject.projectDir}/$srcKotlin") }
rootProject.configure(projectsToConsider) { subProject ->
subProject.afterEvaluate {
classpath += kotlin.target.compilations.getByName("main").compileDependencyFiles.files.collect { file -> file }
}

View File

@@ -1,7 +1,7 @@
description = 'The domain logic of Atrium as common module.'
dependencies {
api prefixedProject('core-common')
api prefixedProject("core")
// it is up to the consumer which atrium-translations module is used at runtime
compileOnly prefixedProject('translations-en_GB-common')

View File

@@ -1,7 +1,7 @@
description = 'The domain logic of Atrium for the JS platform.'
dependencies {
api prefixedProject('core-js')
api prefixedProject("core")
// it is up to the consumer which atrium-translations module is used at runtime
compileOnly prefixedProject('translations-en_GB-js')

View File

@@ -1,7 +1,7 @@
description = 'The domain logic of Atrium for the JVM platform.'
dependencies {
api prefixedProject('core-jvm')
api prefixedProject("core")
implementation niok()

View File

@@ -2,7 +2,7 @@ description = 'Provides specifications of Atrium (as common module) which can be
'APIs and logic/core implementations of Atrium, to verify that they fulfill the specification.'
dependencies {
api prefixedProject('core-common')
api prefixedProject("core")
// exclude this dependency in case you want to use another translation
api prefixedProject('translations-en_GB-common')
api prefixedProject('verbs-internal-common')
@@ -12,7 +12,7 @@ dependencies {
}
dependencies {
api "org.spekframework.spek2:spek-dsl-metadata:$spek2Version"
api "org.spekframework.spek2:spek-dsl-metadata:$spekVersion"
}
compileKotlinCommon.kotlinOptions.languageVersion = '1.3'

View File

@@ -2,7 +2,7 @@ description = 'Provides specifications of Atrium (for the JS platforms) which ca
'APIs and logic/core implementations of Atrium, to verify that they fulfill the specification.'
dependencies {
api prefixedProject('core-js')
api prefixedProject("core")
// exclude this dependency in case you want to use another translation
api prefixedProject('translations-en_GB-js')
api prefixedProject('verbs-internal-js')
@@ -12,7 +12,7 @@ dependencies {
}
dependencies {
api "org.spekframework.spek2:spek-dsl-js:$spek2Version"
api "org.spekframework.spek2:spek-dsl-js:$spekVersion"
}
compileKotlin2Js.kotlinOptions.languageVersion = '1.3'

View File

@@ -2,7 +2,7 @@ description = 'Provides specifications of Atrium (for the JVM platform) which ca
'APIs and logic/core implementations of Atrium, to verify that they fulfill the specification.'
dependencies {
api prefixedProject('core-jvm')
api prefixedProject("core")
// exclude this dependency in case you want to use another translation
api prefixedProject('translations-en_GB-jvm')
api prefixedProject('verbs-internal-jvm')
@@ -14,11 +14,11 @@ dependencies {
dependencies {
//spek2 requires stdlib-jdk8 and kotlin-reflect
runtimeOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
runtimeOnly "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
runtimeOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
runtimeOnly "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
api "org.spekframework.spek2:spek-dsl-jvm:$spek2Version", excludeKotlin
runtimeOnly "org.spekframework.spek2:spek-runner-junit5:$spek2Version", excludeKotlin
api "org.spekframework.spek2:spek-dsl-jvm:$spekVersion", excludeKotlin
runtimeOnly "org.spekframework.spek2:spek-runner-junit5:$spekVersion", excludeKotlin
api mockito(), excludeKotlin
api niok(), excludeKotlin

View File

@@ -30,7 +30,7 @@ val niokVersion: String by rootProject.extra
val jupiterVersion: String by rootProject.extra
val mockkVersion: String by rootProject.extra
val junitPlatformVersion: String by rootProject.extra
val spek2Version: String by rootProject.extra
val spekVersion: String by rootProject.extra
val jacocoToolVersion: String by rootProject.extra
description =
@@ -168,7 +168,7 @@ bcConfigs.forEach { (oldVersion, apis, pair) ->
configure(listOf(project(":bc-tests:$oldVersion-specs"))) {
the<KotlinMultiplatformExtension>().apply {
jvm()
// TODO 0.16.0 reactivate once we have transitioned everything to the new MPP plugin
// TODO 0.17.0 reactivate once we have transitioned everything to the new MPP plugin
// js().nodejs {}
sourceSets {
val commonMain by getting {
@@ -176,7 +176,7 @@ bcConfigs.forEach { (oldVersion, apis, pair) ->
api(kotlin("stdlib-common"))
api(kotlin("reflect"))
api("io.mockk:mockk-common:$mockkVersion")
api("org.spekframework.spek2:spek-dsl-metadata:$spek2Version")
api("org.spekframework.spek2:spek-dsl-metadata:$spekVersion")
api(project(":atrium-verbs-internal-common"))
@@ -188,7 +188,7 @@ bcConfigs.forEach { (oldVersion, apis, pair) ->
val jvmMain by getting {
dependencies {
api("io.mockk:mockk:$mockkVersion")
api("org.spekframework.spek2:spek-dsl-jvm:$spek2Version")
api("org.spekframework.spek2:spek-dsl-jvm:$spekVersion")
api("ch.tutteli.spek:tutteli-spek-extensions:$spekExtensionsVersion")
api("ch.tutteli.niok:niok:$niokVersion")
@@ -199,11 +199,11 @@ bcConfigs.forEach { (oldVersion, apis, pair) ->
implementation(project(":atrium-fluent-en_GB-jvm"))
}
}
// TODO 0.16.0 reactivate once we have transitioned everything to the new MPP plugin
// TODO 0.17.0 reactivate once we have transitioned everything to the new MPP plugin
// val jsMain by getting {
// dependencies {
// api("io.mockk:mockk-dsl-js:$mockkVersion")
// api("org.spekframework.spek2:spek-dsl-js:$spek2Version")
// api("org.spekframework.spek2:spek-dsl-js:$spekVersion")
//
// api(project(":atrium-verbs-internal-js"))
//
@@ -346,7 +346,7 @@ bcConfigs.forEach { (oldVersion, apis, pair) ->
the<KotlinMultiplatformExtension>().apply {
// TODO 0.16.0 reactivate once we have transitioned everything to the new MPP plugin
// TODO 0.17.0 reactivate once we have transitioned everything to the new MPP plugin
// js().nodejs {}
jvm {
@@ -366,7 +366,7 @@ bcConfigs.forEach { (oldVersion, apis, pair) ->
// we want to run the samples as well
dependsOn(tasks.named("build"))
}
//TODO 0.16.0 not yet sure if it makes more sense to include it into :check as well
//TODO 0.17.0 not yet sure if it makes more sense to include it into :check as well
// tasks.named("check").configure {
// dependsOn(bcTest)
// }
@@ -408,7 +408,7 @@ bcConfigs.forEach { (oldVersion, apis, pair) ->
}
}
// TODO 0.16.0 reactivate once we have transitioned everything to the new MPP plugin
// TODO 0.17.0 reactivate once we have transitioned everything to the new MPP plugin
// val jsTest by getting {
// dependencies {
// implementation(project(":atrium-api-$apiName-js"))
@@ -471,7 +471,7 @@ fun Project.createJacocoReportTask(
else -> throw IllegalStateException("re-adjust jacoco task")
}
projects.forEach {
//TODO 0.16.0 simplify once all project use new MPP plugin
//TODO 0.17.0 simplify once all project use new MPP plugin
val sourceSetContainer = it.extensions.findByType<SourceSetContainer>()
if (sourceSetContainer != null) {
sourceSets(sourceSetContainer["main"])
@@ -504,61 +504,6 @@ fun Project.createJacocoReportTask(
return jacocoReport
}
fun Project.configureTestTasks() {
fun memoizeTestFile(testTask: Test) =
project.file("${project.buildDir}/test-results/memoize-previous-state-${testTask.name}.txt")
tasks.withType<Test> {
testLogging {
events(
TestLogEvent.FAILED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_OUT,
TestLogEvent.STANDARD_ERROR
)
exceptionFormat = TestExceptionFormat.FULL
showExceptions = true
showCauses = true
showStackTraces = true
}
val testTask = this
addTestListener(object : TestListener {
override fun beforeSuite(suite: TestDescriptor) {}
override fun beforeTest(testDescriptor: TestDescriptor) {}
override fun afterTest(testDescriptor: TestDescriptor, result: TestResult) {}
override fun afterSuite(suite: TestDescriptor, result: TestResult) {
if (suite.parent == null) {
if (result.testCount == 0L) {
throw GradleException("No tests executed, most likely the discovery failed.")
}
println("Result: ${result.resultType} (${result.successfulTestCount} succeeded, ${result.failedTestCount} failed, ${result.skippedTestCount} skipped)")
memoizeTestFile(testTask).writeText(result.resultType.toString())
}
}
})
}
tasks.withType<Test>().forEach { testTask ->
val failIfTestFailedLastTime =
tasks.register("fail-if-${testTask.name}-failed-last-time") {
doLast {
if (!testTask.didWork) {
val memoizeTestFile = memoizeTestFile(testTask)
if (memoizeTestFile.exists() && memoizeTestFile.readText() == TestResult.ResultType.FAILURE.toString()) {
val allTests = tasks.getByName("allTests") as TestReport
throw GradleException(
"test failed in last run, execute clean${testTask.name} to force its execution\n" +
"See the following report for more information:\nfile://${allTests.destinationDir}/index.html"
)
}
}
}
}
testTask.finalizedBy(failIfTestFailedLastTime)
}
}
fun Project.rewriteFile(filePath: String, f: (String) -> String) {
val file = file(filePath)
file.writeText(f(file.readText()))

View File

@@ -3,7 +3,7 @@
// are included -> alternatively, you can remove the `if` in settings.gradle.kts (search for System.getenv("BC"))
val junitPlatformVersion: String by rootProject.extra
val spek2Version: String by rootProject.extra
val spekVersion: String by rootProject.extra
kotlin {
jvm()
@@ -11,9 +11,9 @@ kotlin {
val jvmMain by getting {
dependencies {
api("org.junit.platform:junit-platform-console-standalone:$junitPlatformVersion")
api("org.spekframework.spek2:spek-dsl-jvm:$spek2Version")
api("org.spekframework.spek2:spek-runner-junit5:$spek2Version")
api("org.spekframework.spek2:spek-runtime-jvm:$spek2Version")
api("org.spekframework.spek2:spek-dsl-jvm:$spekVersion")
api("org.spekframework.spek2:spek-runner-junit5:$spekVersion")
api("org.spekframework.spek2:spek-runtime-jvm:$spekVersion")
api(kotlin("reflect"))
}
}

View File

@@ -7,10 +7,10 @@ repositories {
apply plugin: 'kotlin'
dependencies {
implementation "org.junit.platform:junit-platform-console-standalone:$junitPlatformVersion"
implementation "org.spekframework.spek2:spek-dsl-jvm:$spek2Version"
implementation "org.spekframework.spek2:spek-runner-junit5:$spek2Version"
implementation "org.spekframework.spek2:spek-runtime-jvm:$spek2Version"
runtimeOnly "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation "org.spekframework.spek2:spek-dsl-jvm:$spekVersion"
implementation "org.spekframework.spek2:spek-runner-junit5:$spekVersion"
implementation "org.spekframework.spek2:spek-runtime-jvm:$spekVersion"
runtimeOnly "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
implementation kotlinStdlib()
implementation prefixedProject('fluent-en_GB-jvm')

View File

@@ -1,7 +1,7 @@
description = 'Specifies the internally used assertion verbs as common module'
dependencies {
api prefixedProject('core-common')
api prefixedProject("core")
api prefixedProject('logic-common')
testImplementation prefixedProject('specs-common')

View File

@@ -1,7 +1,7 @@
description = 'Specifies the internally used assertion verbs for the JS platform'
dependencies {
api prefixedProject('core-js')
api prefixedProject("core")
api prefixedProject('logic-js')
testImplementation prefixedProject('specs-js')

View File

@@ -1,7 +1,7 @@
description = 'Specifies the internally used assertion verbs'
dependencies {
api prefixedProject('core-jvm')
api prefixedProject("core")
api prefixedProject('logic-jvm')
testImplementation prefixedProject('specs-jvm')

View File

@@ -2,7 +2,7 @@ description = 'Assertion verbs for Atrium as common module.'
dependencies {
api prefixedProject('logic-common')
api prefixedProject('core-common')
api prefixedProject("core")
testImplementation prefixedProject('specs-common')
}

View File

@@ -2,7 +2,7 @@ description = 'Assertion verbs for Atrium for the JS platform.'
dependencies {
api prefixedProject('logic-js')
api prefixedProject('core-js')
api prefixedProject("core")
testImplementation prefixedProject('specs-js')
}

View File

@@ -2,7 +2,7 @@ description = 'Assertion verbs for Atrium for the JVM platform.'
dependencies {
api prefixedProject('logic-jvm')
api prefixedProject('core-jvm')
api prefixedProject("core")
testImplementation prefixedProject('specs-jvm')
}

View File

@@ -196,7 +196,7 @@ if (System.getenv("BC") != null) {
}
includeBundleAndApisWithExtensionsAndSmokeTest("fluent-en_GB", "infix-en_GB")
includeKotlinJvmJs("core", "atrium-core")
include("", "atrium-core")
includeKotlinJvmJsWithExtensions("logic", "atrium-logic")
@@ -227,8 +227,10 @@ fun Settings_gradle.includeBundleAndApisWithExtensionsAndSmokeTest(vararg apiNam
fun Settings_gradle.includeKotlinJvmJs(subPath: String, module: String) {
include(subPath, "$module-common")
include(subPath, "$module-js")
include(subPath, "$module-jvm")
//TODO 0.17.0 commented out because js makes trouble in migrating to new MPP
// in the end, when all modules use the new MPP we should no longer need this extension function
// include(subPath, "$module-js")
}
fun Settings_gradle.includeKotlinJvmJsWithExtensions(subPath: String, module: String) {

View File

@@ -1,5 +1,5 @@
description = 'Contains translations for Atrium in de_CH as common module.'
dependencies {
api prefixedProject('core-common')
api prefixedProject("core")
}

View File

@@ -1,5 +1,5 @@
description = 'Contains translations for Atrium in de_CH for the JS platform.'
dependencies {
api prefixedProject('core-js')
api prefixedProject("core")
}

View File

@@ -1,5 +1,5 @@
description = 'Contains translations for Atrium in de_CH for the JVM platform.'
dependencies {
api prefixedProject('core-jvm')
api prefixedProject("core")
}

View File

@@ -1,5 +1,5 @@
description = 'Contains translations for Atrium in en_GB as common module.'
dependencies {
api prefixedProject('core-common')
api prefixedProject("core")
}

View File

@@ -1,5 +1,5 @@
description = 'Contains translations for Atrium in en_GB for the JS platform.'
dependencies {
api prefixedProject('core-js')
api prefixedProject("core")
}

View File

@@ -1,5 +1,5 @@
description = 'Contains translations for Atrium in en_GB for the JVM platform.'
dependencies {
api prefixedProject('core-jvm')
api prefixedProject("core")
}