From 7db5e5073585663b898ddc68925a83457327aa79 Mon Sep 17 00:00:00 2001 From: avan1235 Date: Sat, 16 Sep 2023 14:03:42 +0200 Subject: [PATCH 1/3] Update AndroidX Core Ktx version to 1.12.0 --- shared/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts index 7efa84c..47c2faa 100644 --- a/shared/build.gradle.kts +++ b/shared/build.gradle.kts @@ -34,7 +34,7 @@ kotlin { dependencies { api("androidx.activity:activity-compose:1.7.2") api("androidx.appcompat:appcompat:1.6.1") - api("androidx.core:core-ktx:1.10.1") + api("androidx.core:core-ktx:1.12.0") } } val iosX64Main by getting From a78a3e01d2a6478604d35587ce0dd7c44a370409 Mon Sep 17 00:00:00 2001 From: avan1235 Date: Sat, 16 Sep 2023 14:09:07 +0200 Subject: [PATCH 2/3] Remove unneeded kotlin android and jvm plugins --- settings.gradle.kts | 2 -- 1 file changed, 2 deletions(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index b40c9db..d06fc55 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -17,9 +17,7 @@ pluginManagement { val agpVersion = extra["agp.version"] as String val composeVersion = extra["compose.version"] as String - kotlin("jvm").version(kotlinVersion) kotlin("multiplatform").version(kotlinVersion) - kotlin("android").version(kotlinVersion) id("com.android.application").version(agpVersion) id("com.android.library").version(agpVersion) From 74108b29bdf2dfe32e5702bd6fa5e6da009968f1 Mon Sep 17 00:00:00 2001 From: avan1235 Date: Sat, 16 Sep 2023 14:42:04 +0200 Subject: [PATCH 3/3] Migrate build to version catalogs with libs.versions.toml --- androidApp/build.gradle.kts | 12 ++++++------ build.gradle.kts | 8 ++++---- desktopApp/build.gradle.kts | 6 +++--- gradle.properties | 8 -------- gradle/libs.versions.toml | 23 +++++++++++++++++++++++ settings.gradle.kts | 13 ------------- shared/build.gradle.kts | 16 ++++++++-------- 7 files changed, 44 insertions(+), 42 deletions(-) create mode 100644 gradle/libs.versions.toml diff --git a/androidApp/build.gradle.kts b/androidApp/build.gradle.kts index 478d6a5..622eb3b 100644 --- a/androidApp/build.gradle.kts +++ b/androidApp/build.gradle.kts @@ -1,7 +1,7 @@ plugins { - kotlin("multiplatform") - id("com.android.application") - id("org.jetbrains.compose") + alias(libs.plugins.kotlin.multiplatform) + alias(libs.plugins.android.application) + alias(libs.plugins.compose.multiplatform) } kotlin { @@ -16,15 +16,15 @@ kotlin { } android { - compileSdk = (findProperty("android.compileSdk") as String).toInt() + compileSdk = libs.versions.android.compileSdk.get().toInt() namespace = "com.myapplication" sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") defaultConfig { applicationId = "com.myapplication.MyApplication" - minSdk = (findProperty("android.minSdk") as String).toInt() - targetSdk = (findProperty("android.targetSdk") as String).toInt() + minSdk = libs.versions.android.minSdk.get().toInt() + targetSdk = libs.versions.android.targetSdk.get().toInt() versionCode = 1 versionName = "1.0" } diff --git a/build.gradle.kts b/build.gradle.kts index b7e1d5d..32909ca 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,8 +1,8 @@ plugins { // this is necessary to avoid the plugins to be loaded multiple times // in each subproject's classloader - kotlin("multiplatform").apply(false) - id("com.android.application").apply(false) - id("com.android.library").apply(false) - id("org.jetbrains.compose").apply(false) + alias(libs.plugins.kotlin.multiplatform) apply false + alias(libs.plugins.android.application) apply false + alias(libs.plugins.android.library) apply false + alias(libs.plugins.compose.multiplatform) apply false } diff --git a/desktopApp/build.gradle.kts b/desktopApp/build.gradle.kts index 931f346..653f1c5 100644 --- a/desktopApp/build.gradle.kts +++ b/desktopApp/build.gradle.kts @@ -1,14 +1,14 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat plugins { - kotlin("multiplatform") - id("org.jetbrains.compose") + alias(libs.plugins.kotlin.multiplatform) + alias(libs.plugins.compose.multiplatform) } kotlin { jvm() sourceSets { - val jvmMain by getting { + val jvmMain by getting { dependencies { implementation(compose.desktop.currentOs) implementation(project(":shared")) diff --git a/gradle.properties b/gradle.properties index 2707573..8f2e920 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,11 +14,3 @@ org.jetbrains.compose.experimental.uikit.enabled=true #Android android.useAndroidX=true -android.compileSdk=34 -android.targetSdk=34 -android.minSdk=24 - -#Versions -kotlin.version=1.9.10 -agp.version=8.0.2 -compose.version=1.5.2 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..2bcc4ae --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,23 @@ +[versions] +kotlin = "1.9.10" +android-gradle-plugin = "8.0.2" +compose = "1.5.2" + +androidx-activity-compose = "1.7.2" +androidx-appcompat-appcompat = "1.6.1" +androidx-core-ktx = "1.12.0" + +android-compileSdk = "34" +android-targetSdk = "34" +android-minSdk = "24" + +[libraries] +androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity-compose" } +androidx-appcompat-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat-appcompat" } +androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "androidx-core-ktx" } + +[plugins] +android-application = { id = "com.android.application", version.ref = "android-gradle-plugin" } +android-library = { id = "com.android.library", version.ref = "android-gradle-plugin" } +kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } +compose-multiplatform = { id = "org.jetbrains.compose", version.ref = "compose" } diff --git a/settings.gradle.kts b/settings.gradle.kts index d06fc55..0ef7a8e 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -11,19 +11,6 @@ pluginManagement { google() maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") } - - plugins { - val kotlinVersion = extra["kotlin.version"] as String - val agpVersion = extra["agp.version"] as String - val composeVersion = extra["compose.version"] as String - - kotlin("multiplatform").version(kotlinVersion) - - id("com.android.application").version(agpVersion) - id("com.android.library").version(agpVersion) - - id("org.jetbrains.compose").version(composeVersion) - } } plugins { diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts index 47c2faa..a2d8121 100644 --- a/shared/build.gradle.kts +++ b/shared/build.gradle.kts @@ -1,7 +1,7 @@ plugins { - kotlin("multiplatform") - id("com.android.library") - id("org.jetbrains.compose") + alias(libs.plugins.kotlin.multiplatform) + alias(libs.plugins.android.library) + alias(libs.plugins.compose.multiplatform) } kotlin { @@ -32,9 +32,9 @@ kotlin { } val androidMain by getting { dependencies { - api("androidx.activity:activity-compose:1.7.2") - api("androidx.appcompat:appcompat:1.6.1") - api("androidx.core:core-ktx:1.12.0") + api(libs.androidx.activity.compose) + api(libs.androidx.appcompat.appcompat) + api(libs.androidx.core.ktx) } } val iosX64Main by getting @@ -55,7 +55,7 @@ kotlin { } android { - compileSdk = (findProperty("android.compileSdk") as String).toInt() + compileSdk = libs.versions.android.compileSdk.get().toInt() namespace = "com.myapplication.common" sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") @@ -63,7 +63,7 @@ android { sourceSets["main"].resources.srcDirs("src/commonMain/resources") defaultConfig { - minSdk = (findProperty("android.minSdk") as String).toInt() + minSdk = libs.versions.android.minSdk.get().toInt() } compileOptions { sourceCompatibility = JavaVersion.VERSION_17