From 76c46b422959533560f5dd60292714481739cbca Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Thu, 30 Sep 2021 02:30:42 +0530 Subject: [PATCH] build: cleanup sourceSet handling to drop unused vals --- common/build.gradle.kts | 42 ++++++++++++--------------------------- database/build.gradle.kts | 28 ++++++-------------------- desktop/build.gradle.kts | 18 ++++++++--------- 3 files changed, 27 insertions(+), 61 deletions(-) diff --git a/common/build.gradle.kts b/common/build.gradle.kts index cd0b66c2..f72eb54a 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -8,39 +8,23 @@ plugins { } kotlin { - android() { compilations.all { kotlinOptions.jvmTarget = "11" } } + android { compilations.all { kotlinOptions.jvmTarget = "11" } } jvm("desktop") { compilations.all { kotlinOptions.jvmTarget = "11" } } - sourceSets { - // Workaround for: - // - // The Kotlin source set androidAndroidTestRelease was configured but not added to any - // Kotlin compilation. You can add a source set to a target's compilation by connecting it - // with the compilation's default source set using 'dependsOn'. - // See - // https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#connecting-source-sets - // - // This workaround includes `dependsOn(androidAndroidTestRelease)` in the `androidTest` - // sourceSet. - val androidAndroidTestRelease by getting - val commonMain by getting { - dependencies { - api(compose.runtime) - api(compose.foundation) - api(compose.material) - api(projects.database) - } + sourceSets["commonMain"].apply { + dependencies { + api(compose.runtime) + api(compose.foundation) + api(compose.material) + api(projects.database) } - val commonTest by getting - val androidMain by getting { - dependencies { - implementation(libs.androidx.browser) - implementation(libs.coil.compose) - } + } + sourceSets["androidMain"].apply { + dependencies { + implementation(libs.androidx.browser) + implementation(libs.coil.compose) } - val androidTest by getting { dependsOn(androidAndroidTestRelease) } - val desktopMain by getting { dependencies { implementation(libs.kamel.image) } } - val desktopTest by getting } + sourceSets["desktopMain"].apply { dependencies { implementation(libs.kamel.image) } } } tasks.withType { diff --git a/database/build.gradle.kts b/database/build.gradle.kts index 06ca9c99..981a9d5b 100644 --- a/database/build.gradle.kts +++ b/database/build.gradle.kts @@ -13,28 +13,12 @@ kotlin { kotlinOptions.freeCompilerArgs + listOf("-Xopt-in=kotlin.RequiresOptIn") } } - sourceSets { - // Workaround for: - // - // The Kotlin source set androidAndroidTestRelease was configured but not added to any - // Kotlin compilation. You can add a source set to a target's compilation by connecting it - // with the compilation's default source set using 'dependsOn'. - // See - // https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#connecting-source-sets - // - // This workaround includes `dependsOn(androidAndroidTestRelease)` in the `androidTest` - // sourceSet. - val androidAndroidTestRelease by getting - val commonMain by getting - val commonTest by getting - val androidMain by getting { dependencies { implementation(libs.sqldelight.androidDriver) } } - val androidTest by getting { dependsOn(androidAndroidTestRelease) } - val desktopMain by getting { dependencies { implementation(libs.sqldelight.jvmDriver) } } - val desktopTest by getting { - dependencies { - implementation(libs.kotlin.coroutines.core) - implementation(kotlin("test-junit")) - } + sourceSets["androidMain"].apply { dependencies { implementation(libs.sqldelight.androidDriver) } } + sourceSets["desktopMain"].apply { dependencies { implementation(libs.sqldelight.jvmDriver) } } + sourceSets["desktopTest"].apply { + dependencies { + implementation(libs.kotlin.coroutines.core) + implementation(kotlin("test-junit")) } } } diff --git a/desktop/build.gradle.kts b/desktop/build.gradle.kts index 8af7b783..e8cc1c4b 100644 --- a/desktop/build.gradle.kts +++ b/desktop/build.gradle.kts @@ -12,17 +12,15 @@ version = "1.0" kotlin { jvm { compilations.all { kotlinOptions.jvmTarget = "11" } } - sourceSets { - val jvmMain by getting { - dependencies { - implementation(projects.common) - implementation(libs.aurora.component) - implementation(libs.aurora.skin) - implementation(libs.aurora.window) - implementation(compose.desktop.currentOs) - } + sourceSets["jvmMain"].apply { + dependencies { + implementation(projects.api) + implementation(projects.common) + implementation(libs.aurora.component) + implementation(libs.aurora.skin) + implementation(libs.aurora.window) + implementation(compose.desktop.currentOs) } - val jvmTest by getting } }