Skip to content

Commit

Permalink
only apply java-base to get rid of MPP issues, update tutteli to 5.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
robstoll committed Nov 2, 2024
1 parent 40b1528 commit 0ab80f4
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("java")
id("java-base")
id("build-logic.gradle-conventions")
}

Expand All @@ -8,8 +8,10 @@ java {
// reading JAVA_VERSION from env to enable jdk17 build in CI
languageVersion.set(JavaLanguageVersion.of(buildParameters.java.version))
}
consistentResolution {
useCompileClasspathVersions()
project.afterEvaluate {
consistentResolution {
useCompileClasspathVersions()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.gradle.kotlin.dsl.extra
import org.gradle.testing.jacoco.plugins.JacocoPluginExtension
import org.gradle.testing.jacoco.tasks.JacocoReport

plugins {
id("ch.tutteli.gradle.plugins.junitjacoco")
}

dependencies {
// used to run the samples
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.junit.jupiter:junit-jupiter-params")
//TODO 1.4.0 move this bit to tutteli-gradle-plugins, could be done there depending if com.github.vlsi.gradle-extensions
// is applied or not
tasks.withType<Test>().configureEach {
testLogging {
// Empty enum throws "Collection is empty", so we use Iterable method
setEvents((events - TestLogEvent.FAILED) as Iterable<TestLogEvent>)
showStackTraces = false
}
}

//TODO switch to buildLibs once gradle supports this in build-logic/src/kotlin files (also jupiter-api above)
Expand All @@ -32,17 +33,3 @@ plugins.withId("jacoco") {
}
}
}


//TODO 1.4.0 move this bit to tutteli-gradle-plugins, could be done there depending if com.github.vlsi.gradle-extensions
// is applied or not

// adjust because we use com.github.vlsi.gradle-extensions which prints tests differently, otherwise we print
// the failed tests twice.
tasks.withType<Test>().configureEach {
testLogging {
// Empty enum throws "Collection is empty", so we use Iterable method
setEvents((events - TestLogEvent.FAILED) as Iterable<TestLogEvent>)
showStackTraces = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("build-logic.kotlin-conventions")
id("build-logic.junit-jacoco-conventions")
// this plugin sets inter alia toolchain and source/targetCompatibility
// but also applies common plugins such as gradle-convention, build-params
id("build-logic.java")
id("build-logic.junit-jacoco-conventions")
}

tasks.configureEach<KotlinCompile> {
compilerOptions{
compilerOptions {
jvmTarget.set(JvmTarget.fromTarget(buildParameters.defaultJdkVersion.toString()))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,3 @@ plugins {
kotlin("jvm")
id("build-logic.kotlin-jvm-conventions")
}

dependencies {
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import org.gradle.kotlin.dsl.kotlin

plugins {
kotlin("multiplatform")
id("build-logic.gradle-conventions")
}

kotlin {
sourceSets {
// necessary due to https://youtrack.jetbrains.com/issue/KT-65352/KMP-Gradle-impossible-to-set-language-apiVersion-for-common-to-1.4
all {
languageSettings {
languageVersion = buildParameters.kotlin.version
apiVersion = buildParameters.kotlin.version
}
}
}
}

// this is necessary due to some crazy kotlin plugin voodoo. If we define this in the rootProject itself,
// then it does not work.
rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin> {
rootProject.configure<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension> {
lockFileDirectory = rootProject.projectDir.resolve("gradle")
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
kotlin("multiplatform")
id("build-logic.kotlin-multiplatform-conventions")
id("build-logic.kotlin-jvm-conventions")
id("ch.tutteli.gradle.plugins.spek")
}
Expand Down Expand Up @@ -55,22 +55,6 @@ kotlin {
implementation(kotlin("test"))
}
}

// necessary due to https://youtrack.jetbrains.com/issue/KT-65352/KMP-Gradle-impossible-to-set-language-apiVersion-for-common-to-1.4
all {
languageSettings {
languageVersion = buildParameters.kotlin.version
apiVersion = buildParameters.kotlin.version
}
}
}
}

// this is necessary due to some crazy kotlin plugin voodoo. If we define this in the rootProject itself,
// then it does not work.
rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin> {
rootProject.configure<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension> {
lockFileDirectory = rootProject.projectDir.resolve("gradle")
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/buildLibs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dokka = "1.9.20"
jacocoTool = "0.8.9"
kotlin = "2.0.21"
task-tree = "4.0.0"
tutteli = "5.0.1"
tutteli = "5.0.3"
vlsi = "1.90"

[libraries]
Expand Down

0 comments on commit 0ab80f4

Please sign in to comment.