From 50ada62fb0c6ea225860418613dab2637358c603 Mon Sep 17 00:00:00 2001 From: Urs Joss Date: Sun, 26 Feb 2023 16:50:51 +0100 Subject: [PATCH] Revert "chore: Migrate to gradle 8.0 (#125)" This reverts commit dd35fd049be2d58601710017a787669c4be50df8. --- .github/workflows/main.yml | 2 +- build.gradle.kts | 26 ++++++++++------ gradle-plugins/build.gradle.kts | 8 ----- gradle-plugins/publishing/build.gradle.kts | 4 +++ gradle-plugins/verification/build.gradle.kts | 4 +++ gradle/libs.versions.toml | 5 ++- gradle/wrapper/gradle-wrapper.properties | 2 +- subprojects/kris-core/kris-core.gradle.kts | 2 +- subprojects/kris-guide/kris-guide.gradle.kts | 11 +++++-- subprojects/kris-io/kris-io.gradle.kts | 32 +++----------------- 10 files changed, 45 insertions(+), 51 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0e05f0b2..31aa26ac 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -68,7 +68,7 @@ jobs: path: '**/build/reports' - name: Run all tests with Gradle - run: ./gradlew check detekt --info --no-daemon + run: ./gradlew check detekt sonar --info --no-daemon env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/build.gradle.kts b/build.gradle.kts index 5d019a37..a233b34f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,3 @@ -@file:Suppress("UnstableApiUsage") - import org.jetbrains.dokka.gradle.DokkaTask import org.jetbrains.dokka.gradle.DokkaTaskPartial import org.jetbrains.kotlin.gradle.tasks.KotlinCompile @@ -24,6 +22,10 @@ plugins { jacoco } +java { + toolchain.languageVersion.set(JavaLanguageVersion.of(libs.versions.java.get())) +} + val jacocoTestReportFile = "$buildDir/reports/jacoco/test/jacocoTestReport.xml" jacoco { @@ -76,27 +78,31 @@ tasks { } } -testing { - suites { - val test by getting(JvmTestSuite::class) { - useJUnitJupiter() - } - } -} - val kotlinSrcSet = "/src/main/kotlin" subprojects.forEach { subProject -> subProject.tasks { val kotlinVersion = libs.versions.kotlin.get() val kotlinApiLangVersion = kotlinVersion.subSequence(0, 3).toString() + val jvmTargetVersion = libs.versions.java.get() withType().configureEach { kotlinOptions { apiVersion = kotlinApiLangVersion languageVersion = kotlinApiLangVersion + jvmTarget = jvmTargetVersion + freeCompilerArgs = freeCompilerArgs + listOf("-opt-in=kotlin.RequiresOptIn") } } + withType().configureEach { + sourceCompatibility = jvmTargetVersion + targetCompatibility = jvmTargetVersion + } + withType { + useJUnitPlatform { + includeEngines("junit-jupiter", "kotest") + } + } withType().configureEach { dokkaSourceSets { configureEach { diff --git a/gradle-plugins/build.gradle.kts b/gradle-plugins/build.gradle.kts index 2f27a8ac..50f4aa10 100644 --- a/gradle-plugins/build.gradle.kts +++ b/gradle-plugins/build.gradle.kts @@ -1,11 +1,3 @@ -plugins { - kotlin("jvm") version "1.8.10" -} - -kotlin { - jvmToolchain(11) -} - val buildTask = tasks.register("buildPlugins") subprojects { diff --git a/gradle-plugins/publishing/build.gradle.kts b/gradle-plugins/publishing/build.gradle.kts index c026ca9c..dabbac8a 100644 --- a/gradle-plugins/publishing/build.gradle.kts +++ b/gradle-plugins/publishing/build.gradle.kts @@ -9,6 +9,10 @@ dependencies { implementation(libs.plugin.detekt) } +tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile::class.java).configureEach { + kotlinOptions.jvmTarget = libs.versions.java.get() +} + detekt { buildUponDefaultConfig = true config.from(file("../../config/detekt/detekt.yml")) diff --git a/gradle-plugins/verification/build.gradle.kts b/gradle-plugins/verification/build.gradle.kts index 7a244b76..5724351c 100644 --- a/gradle-plugins/verification/build.gradle.kts +++ b/gradle-plugins/verification/build.gradle.kts @@ -11,6 +11,10 @@ dependencies { implementation(libs.plugin.detekt) } +tasks.withType(KotlinJvmCompile::class.java).configureEach { + kotlinOptions.jvmTarget = libs.versions.java.get() +} + detekt { buildUponDefaultConfig = true config.from(file("../../config/detekt/detekt.yml")) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f433acaa..92881893 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -15,6 +15,7 @@ mockk = "1.13.4" nexusPublish = "1.2.0" rxjava = "2.2.21" sonarqube = "4.0.0.2929" +testSets = "4.0.0" versions = "0.46.0" [libraries] @@ -37,7 +38,8 @@ plugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version. [bundles] kotlin = ["kotlin-stdlib", "kotlin-reflect", "coroutines-core"] -testDeps = ["junitJupiter-api", "kotest-runner-junit5", "kotest-framework-api", "mockk", "kluent", "assertj-core"] +testDeps = ["junitJupiter-api", "kotest-framework-api", "mockk", "kluent", "assertj-core"] +testEngines = ["junitJupiter-engine", "kotest-runner-junit5"] [plugins] asciidoctorConvert = { id = "org.asciidoctor.jvm.convert", version.ref = "asciidoctor" } @@ -46,4 +48,5 @@ dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } gitPublish = { id = "org.ajoberstar.git-publish", version.ref = "gitPublish" } nexusPublish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexusPublish" } sonarqube = { id = "org.sonarqube", version.ref = "sonarqube" } +testSets = { id = "org.unbroken-dome.test-sets", version.ref = "testSets" } versions = { id = "com.github.ben-manes.versions", version.ref = "versions" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 42defcc9..f398c33c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/subprojects/kris-core/kris-core.gradle.kts b/subprojects/kris-core/kris-core.gradle.kts index 45b9cb18..27e1a3b9 100644 --- a/subprojects/kris-core/kris-core.gradle.kts +++ b/subprojects/kris-core/kris-core.gradle.kts @@ -14,11 +14,11 @@ dependencies { implementation(libs.coroutines.rx2) testImplementation(libs.bundles.testDeps) + testRuntimeOnly(libs.bundles.testEngines) } kotlin { explicitApi() - jvmToolchain(libs.versions.java.get().toInt()) } tasks { diff --git a/subprojects/kris-guide/kris-guide.gradle.kts b/subprojects/kris-guide/kris-guide.gradle.kts index 7e79756c..bc0fd1a0 100644 --- a/subprojects/kris-guide/kris-guide.gradle.kts +++ b/subprojects/kris-guide/kris-guide.gradle.kts @@ -1,10 +1,16 @@ +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + plugins { `java-library` kotlin("jvm") } -kotlin { - jvmToolchain(libs.versions.java.get().toInt()) +tasks { + withType().configureEach { + kotlinOptions { + jvmTarget = libs.versions.java.get() + } + } } dependencies { @@ -13,4 +19,5 @@ dependencies { implementation(libs.bundles.kotlin) testImplementation(libs.bundles.testDeps) + testRuntimeOnly(libs.bundles.testEngines) } diff --git a/subprojects/kris-io/kris-io.gradle.kts b/subprojects/kris-io/kris-io.gradle.kts index 8d597113..7d942956 100644 --- a/subprojects/kris-io/kris-io.gradle.kts +++ b/subprojects/kris-io/kris-io.gradle.kts @@ -4,44 +4,21 @@ plugins { id("kris-publish") id("kris-jacoco") kotlin("jvm") - `jvm-test-suite` + alias(libs.plugins.testSets) alias(libs.plugins.dokka) } kotlin { explicitApi() - jvmToolchain(libs.versions.java.get().toInt()) } -testing { - suites { - val test by getting(JvmTestSuite::class) { - useJUnitJupiter() - } - - val integrationTest by registering(JvmTestSuite::class) { - dependencies { - implementation(project()) - } - - targets { - all { - testTask.configure { - shouldRunAfter(test) - } - } - } - } - } -} - -val integrationTestImplementation by configurations.getting { - extendsFrom(configurations.testImplementation.get()) +testSets { + create("integrationTest") } tasks { named("check") { - dependsOn(testing.suites.named("integrationTest")) + dependsOn("integrationTest") } val javadocJar by existing(Jar::class) { group = JavaBasePlugin.DOCUMENTATION_GROUP @@ -60,4 +37,5 @@ dependencies { implementation(libs.bundles.kotlin) testImplementation(libs.bundles.testDeps) + testRuntimeOnly(libs.bundles.testEngines) }