diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 94b7ea1c..5b464a9a 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -1,3 +1,4 @@ +import com.android.build.api.variant.HasUnitTestBuilder import com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsExtension import com.google.firebase.perf.plugin.FirebasePerfExtension import io.github.reactivecircus.kstreamlined.buildlogic.FlavorDimensions @@ -169,7 +170,7 @@ androidComponents { it.enable = it.flavorName == ProductFlavors.PROD && it.buildType == "release" || it.flavorName != ProductFlavors.PROD && it.buildType == "debug" || it.flavorName == ProductFlavors.DEV && it.buildType == "benchmark" - it.enableUnitTest = false + (it as HasUnitTestBuilder).enableUnitTest = false it.enableAndroidTest = false } diff --git a/android/ui/ui-common/build.gradle.kts b/android/ui/ui-common/build.gradle.kts index 1b8f2c22..ad936caf 100644 --- a/android/ui/ui-common/build.gradle.kts +++ b/android/ui/ui-common/build.gradle.kts @@ -1,3 +1,5 @@ +import com.android.build.api.variant.HasUnitTestBuilder + plugins { id("kstreamlined.android.library") id("kstreamlined.android.library.compose") @@ -12,7 +14,7 @@ android { androidComponents { beforeVariants { - it.enableUnitTest = false + (it as HasUnitTestBuilder).enableUnitTest = false it.enableAndroidTest = false } } diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index f8463ae1..26d6a0d7 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -17,7 +17,7 @@ kotlin { } } jvmToolchain { - languageVersion.set(JavaLanguageVersion.of(20)) + languageVersion.set(JavaLanguageVersion.of(21)) vendor.set(JvmVendorSpec.AZUL) } } diff --git a/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/KMMBuildLogic.kt b/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/KMMBuildLogic.kt index a5559a0a..47658338 100644 --- a/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/KMMBuildLogic.kt +++ b/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/KMMBuildLogic.kt @@ -1,11 +1,6 @@ -@file:Suppress("UNUSED_VARIABLE") - package io.github.reactivecircus.kstreamlined.buildlogic import org.gradle.api.Project -import org.gradle.kotlin.dsl.creating -import org.gradle.kotlin.dsl.getValue -import org.gradle.kotlin.dsl.getting import org.gradle.kotlin.dsl.withType import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompile import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension @@ -28,23 +23,7 @@ internal fun KotlinMultiplatformExtension.configureKMMCommon( iosX64() } - with(sourceSets) { - val commonMain by getting - val iosArm64Main by getting - val iosMain by creating { - dependsOn(commonMain) - iosArm64Main.dependsOn(this) - if (project.isAppleSilicon) { - val iosSimulatorArm64Main by getting - iosSimulatorArm64Main.dependsOn(this) - } else { - val iosX64Main by getting - iosX64Main.dependsOn(this) - } - } - } - - sourceSets.all { + sourceSets.configureEach { languageSettings { applyLanguageSettings() } @@ -54,38 +33,18 @@ internal fun KotlinMultiplatformExtension.configureKMMCommon( /** * Apply test configs to KMM project. */ -internal fun KotlinMultiplatformExtension.configureKMMTest( - project: Project, - enableJvmTest: Boolean = true, - enableIosTest: Boolean = true, -) { +internal fun KotlinMultiplatformExtension.configureKMMTest() { with(sourceSets) { - val commonTest by getting { + commonTest { dependencies { implementation(kotlin("test-common")) implementation(kotlin("test-annotations-common")) } } - if (enableJvmTest) { - val jvmTest by getting { - dependencies { - implementation(kotlin("test")) - implementation(kotlin("test-junit")) - } - } - } - if (enableIosTest) { - val iosArm64Test by getting - val iosTest by creating { - dependsOn(commonTest) - iosArm64Test.dependsOn(this) - if (project.isAppleSilicon) { - val iosSimulatorArm64Test by getting - iosSimulatorArm64Test.dependsOn(this) - } else { - val iosX64Test by getting - iosX64Test.dependsOn(this) - } + jvmTest { + dependencies { + implementation(kotlin("test")) + implementation(kotlin("test-junit")) } } } diff --git a/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/KotlinJvmBuildLogic.kt b/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/KotlinJvmBuildLogic.kt index 1b43a9bd..d4eb776a 100644 --- a/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/KotlinJvmBuildLogic.kt +++ b/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/KotlinJvmBuildLogic.kt @@ -14,7 +14,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile @Suppress("MagicNumber") internal fun KotlinProjectExtension.configureKotlinJvm(target: Project) { jvmToolchain { - languageVersion.set(JavaLanguageVersion.of(20)) + languageVersion.set(JavaLanguageVersion.of(21)) vendor.set(JvmVendorSpec.AZUL) } target.tasks.withType().configureEach { diff --git a/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/SlimTests.kt b/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/SlimTests.kt index 4fab66e3..031b474f 100644 --- a/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/SlimTests.kt +++ b/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/SlimTests.kt @@ -3,6 +3,7 @@ package io.github.reactivecircus.kstreamlined.buildlogic import com.android.build.api.variant.ApplicationAndroidComponentsExtension +import com.android.build.api.variant.HasUnitTestBuilder import com.android.build.api.variant.LibraryAndroidComponentsExtension import org.gradle.api.Project import org.gradle.kotlin.dsl.findByType @@ -21,29 +22,29 @@ internal fun Project.configureSlimTests() { // disable unit test tasks on the release, benchmark build types for Android Library projects extensions.findByType()?.run { beforeVariants(selector().withBuildType("release")) { - it.enableUnitTest = false + (it as HasUnitTestBuilder).enableUnitTest = false } beforeVariants(selector().withBuildType("benchmark")) { - it.enableUnitTest = false + (it as HasUnitTestBuilder).enableUnitTest = false } } // disable unit test tasks on the release, benchmark build types and all non-dev flavors for Android Application projects. extensions.findByType()?.run { beforeVariants(selector().withBuildType("release")) { - it.enableUnitTest = false + (it as HasUnitTestBuilder).enableUnitTest = false } beforeVariants(selector().withBuildType("benchmark")) { - it.enableUnitTest = false + (it as HasUnitTestBuilder).enableUnitTest = false } beforeVariants(selector().withFlavor(FlavorDimensions.ENVIRONMENT to ProductFlavors.DEMO)) { - it.enableUnitTest = false + (it as HasUnitTestBuilder).enableUnitTest = false } beforeVariants(selector().withFlavor(FlavorDimensions.ENVIRONMENT to ProductFlavors.MOCK)) { - it.enableUnitTest = false + (it as HasUnitTestBuilder).enableUnitTest = false } beforeVariants(selector().withFlavor(FlavorDimensions.ENVIRONMENT to ProductFlavors.PROD)) { - it.enableUnitTest = false + (it as HasUnitTestBuilder).enableUnitTest = false } } } diff --git a/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/convention/AndroidApplicationConventionPlugin.kt b/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/convention/AndroidApplicationConventionPlugin.kt index d24ef3c0..95ab7d67 100644 --- a/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/convention/AndroidApplicationConventionPlugin.kt +++ b/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/convention/AndroidApplicationConventionPlugin.kt @@ -23,7 +23,7 @@ internal class AndroidApplicationConventionPlugin : Plugin { extensions.configure { configureKotlinJvm(target) - sourceSets.all { + sourceSets.configureEach { languageSettings { applyLanguageSettings() } diff --git a/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/convention/AndroidLibraryConventionPlugin.kt b/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/convention/AndroidLibraryConventionPlugin.kt index 966f0d4e..d14a0385 100644 --- a/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/convention/AndroidLibraryConventionPlugin.kt +++ b/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/convention/AndroidLibraryConventionPlugin.kt @@ -24,7 +24,7 @@ internal class AndroidLibraryConventionPlugin : Plugin { extensions.configure { configureKotlinJvm(target) - sourceSets.all { + sourceSets.configureEach { languageSettings { applyLanguageSettings() } diff --git a/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/convention/AndroidTestConventionPlugin.kt b/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/convention/AndroidTestConventionPlugin.kt index f8b013a9..7b2ee9ff 100644 --- a/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/convention/AndroidTestConventionPlugin.kt +++ b/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/convention/AndroidTestConventionPlugin.kt @@ -20,7 +20,7 @@ internal class AndroidTestConventionPlugin : Plugin { extensions.configure { configureKotlinJvm(target) - sourceSets.all { + sourceSets.configureEach { languageSettings { applyLanguageSettings() } diff --git a/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/convention/KMMTestConventionPlugin.kt b/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/convention/KMMTestConventionPlugin.kt index 1a2b5c2e..4cb761e7 100644 --- a/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/convention/KMMTestConventionPlugin.kt +++ b/build-logic/src/main/kotlin/io/github/reactivecircus/kstreamlined/buildlogic/convention/KMMTestConventionPlugin.kt @@ -11,7 +11,7 @@ internal class KMMTestConventionPlugin : Plugin { pluginManager.apply("org.jetbrains.kotlin.multiplatform") extensions.configure { - configureKMMTest(target) + configureKMMTest() } } } diff --git a/kmm/apollo-models/build.gradle.kts b/kmm/apollo-models/build.gradle.kts index 16f8d88b..7d826e1b 100644 --- a/kmm/apollo-models/build.gradle.kts +++ b/kmm/apollo-models/build.gradle.kts @@ -14,7 +14,7 @@ apollo { kotlin { sourceSets { - val commonMain by getting { + commonMain { dependencies { api(libs.apollo.api) } diff --git a/kmm/core-utils/build.gradle.kts b/kmm/core-utils/build.gradle.kts index ada5c207..848376c6 100644 --- a/kmm/core-utils/build.gradle.kts +++ b/kmm/core-utils/build.gradle.kts @@ -5,7 +5,7 @@ plugins { kotlin { sourceSets { - val commonMain by getting { + commonMain { dependencies { implementation(libs.kotlinx.coroutines.core) } diff --git a/kmm/data-common/build.gradle.kts b/kmm/data-common/build.gradle.kts index a76d0284..797481e1 100644 --- a/kmm/data-common/build.gradle.kts +++ b/kmm/data-common/build.gradle.kts @@ -4,7 +4,7 @@ plugins { kotlin { sourceSets { - val commonMain by getting { + commonMain { dependencies { api(project(":kmm:apollo-models")) implementation(libs.kotlinx.coroutines.core) diff --git a/kmm/data-runtime-cloud/build.gradle.kts b/kmm/data-runtime-cloud/build.gradle.kts index 8454b31c..d52c76b1 100644 --- a/kmm/data-runtime-cloud/build.gradle.kts +++ b/kmm/data-runtime-cloud/build.gradle.kts @@ -5,7 +5,7 @@ plugins { kotlin { sourceSets { - val commonMain by getting { + commonMain { dependencies { api(project(":kmm:data-common")) api(libs.apollo.runtime) @@ -14,7 +14,7 @@ kotlin { implementation(libs.kermit) } } - val commonTest by getting { + commonTest { dependencies { implementation(project(":kmm:test-utils")) implementation(libs.apollo.testingSupport) diff --git a/kmm/data-runtime-edge/build.gradle.kts b/kmm/data-runtime-edge/build.gradle.kts index fdbfe599..f13332fb 100644 --- a/kmm/data-runtime-edge/build.gradle.kts +++ b/kmm/data-runtime-edge/build.gradle.kts @@ -5,14 +5,14 @@ plugins { kotlin { sourceSets { - val commonMain by getting { + commonMain { dependencies { api(project(":kmm:data-common")) implementation(libs.kotlinx.coroutines.core) implementation(libs.kermit) } } - val commonTest by getting { + commonTest { dependencies { implementation(libs.kotlinx.coroutines.test) } diff --git a/kmm/data-testing/build.gradle.kts b/kmm/data-testing/build.gradle.kts index d44fda7f..21cdc25e 100644 --- a/kmm/data-testing/build.gradle.kts +++ b/kmm/data-testing/build.gradle.kts @@ -5,13 +5,13 @@ plugins { kotlin { sourceSets { - val commonMain by getting { + commonMain { dependencies { api(project(":kmm:data-common")) implementation(libs.kotlinx.coroutines.core) } } - val commonTest by getting { + commonTest { dependencies { implementation(libs.kotlinx.coroutines.test) } diff --git a/kmm/test-utils/build.gradle.kts b/kmm/test-utils/build.gradle.kts index 6758ce26..9dc99e26 100644 --- a/kmm/test-utils/build.gradle.kts +++ b/kmm/test-utils/build.gradle.kts @@ -4,7 +4,7 @@ plugins { kotlin { sourceSets { - val commonMain by getting { + commonMain { dependencies { api(libs.kotlinx.coroutines.test) }