From 8e2685f8a9fc6475cfb04cbf4bb45872f050eaa9 Mon Sep 17 00:00:00 2001 From: John O'Reilly Date: Sun, 26 May 2024 09:35:42 +0100 Subject: [PATCH] Kotlin 2.0 + related dependencies --- README.md | 14 ++++++ androidApp/build.gradle.kts | 42 ++++++---------- build.gradle.kts | 53 +++++++++++--------- buildSrc/.gitignore | 1 - buildSrc/build.gradle.kts | 7 --- buildSrc/src/main/java/Dependencies.kt | 63 ------------------------ compose-desktop/build.gradle.kts | 12 +---- gradle.properties | 4 ++ gradle/libs.versions.toml | 42 ++++++++++++++++ gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle.kts | 12 ++++- shared/build.gradle.kts | 23 +++++---- 12 files changed, 129 insertions(+), 146 deletions(-) delete mode 100644 buildSrc/.gitignore delete mode 100644 buildSrc/build.gradle.kts delete mode 100644 buildSrc/src/main/java/Dependencies.kt create mode 100644 gradle/libs.versions.toml diff --git a/README.md b/README.md index 447196c..66074dd 100644 --- a/README.md +++ b/README.md @@ -63,3 +63,17 @@ Any updates to `boardStatus` or `boardGuesses` will trigger our SwiftUI UI to be ![Simulator Screen Shot - iPhone 13 Pro - 2022-01-08 at 22 38 11](https://user-images.githubusercontent.com/6302/148663064-3ed57b1f-c1a3-4e39-b2c2-2ddb3fb09ed9.png) ![Screenshot_1641682073](https://user-images.githubusercontent.com/6302/148663060-c1047266-425c-4b14-bdaf-b7177a1fa332.png) + +## Full set of Kotlin Multiplatform/Compose/SwiftUI samples + +* PeopleInSpace (https://github.com/joreilly/PeopleInSpace) +* GalwayBus (https://github.com/joreilly/GalwayBus) +* Confetti (https://github.com/joreilly/Confetti) +* BikeShare (https://github.com/joreilly/BikeShare) +* FantasyPremierLeague (https://github.com/joreilly/FantasyPremierLeague) +* ClimateTrace (https://github.com/joreilly/ClimateTraceKMP) +* GeminiKMP (https://github.com/joreilly/GeminiKMP) +* MortyComposeKMM (https://github.com/joreilly/MortyComposeKMM) +* StarWars (https://github.com/joreilly/StarWars) +* WordMasterKMP (https://github.com/joreilly/WordMasterKMP) +* Chip-8 (https://github.com/joreilly/chip-8) diff --git a/androidApp/build.gradle.kts b/androidApp/build.gradle.kts index 43b9a6c..47b049a 100644 --- a/androidApp/build.gradle.kts +++ b/androidApp/build.gradle.kts @@ -1,31 +1,26 @@ plugins { id("com.android.application") kotlin("android") + alias(libs.plugins.compose.compiler) } android { namespace = "dev.johnoreilly.wordmaster.androidApp" - compileSdk = AndroidSdk.compile + compileSdk = libs.versions.android.compileSdk.get().toInt() defaultConfig { - //applicationId = "dev.johnoreilly.wordle.androidApp" - minSdk = AndroidSdk.min - targetSdk = AndroidSdk.target + minSdk = libs.versions.android.minSdk.get().toInt() + compileSdk = libs.versions.android.targetSdk.get().toInt() versionCode = 1 versionName = "1.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } - buildFeatures { compose = true } - composeOptions { - kotlinCompilerExtensionVersion = Versions.composeCompiler - } - buildTypes { getByName("release") { isMinifyEnabled = false @@ -43,26 +38,17 @@ android { } - dependencies { implementation(project(":shared")) - with (Compose) { - implementation(compiler) - implementation(ui) - implementation(uiGraphics) - implementation(uiTooling) - implementation(foundationLayout) - implementation(material) - implementation(navigation) - } - - with(Test) { - testImplementation(junit) - androidTestImplementation(composeUiTest) - androidTestImplementation(composeUiTestJUnit) - debugImplementation(composeUiTestManifest) - } - - implementation(Google.Accompanist.insets) + implementation(libs.androidx.activity.compose) + implementation(platform(libs.androidx.compose.bom)) + implementation(libs.androidx.compose.foundation) + implementation(libs.androidx.compose.foundation.layout) + implementation(libs.androidx.compose.material) + implementation(libs.androidx.compose.runtime) + implementation(libs.androidx.compose.ui) + implementation(libs.androidx.compose.ui.tooling) + implementation(libs.androidx.compose.material3) + implementation(libs.accompanist.insets) } diff --git a/build.gradle.kts b/build.gradle.kts index 2c45efc..81f6150 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,24 +1,33 @@ -buildscript { - repositories { - gradlePluginPortal() - google() - mavenCentral() - maven(url = "https://androidx.dev/storage/compose-compiler/repository") - } - - dependencies { - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlinVersion}") - classpath("com.android.tools.build:gradle:8.2.0") - classpath("com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:2.0.0-Beta1-1.0.15") - classpath("com.rickclephas.kmp:kmp-nativecoroutines-gradle-plugin:${Versions.kmpNativeCoroutines}") - } +plugins { + alias(libs.plugins.androidApplication) apply false + alias(libs.plugins.androidLibrary) apply false + alias(libs.plugins.jetbrainsCompose) apply false + alias(libs.plugins.kotlinMultiplatform) apply false + alias(libs.plugins.ksp) apply false + alias(libs.plugins.kmpNativeCoroutines) apply false } -allprojects { - repositories { - google() - mavenCentral() - maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-coroutines/maven") - maven(url = "https://androidx.dev/storage/compose-compiler/repository") - } -} +//buildscript { +// repositories { +// gradlePluginPortal() +// google() +// mavenCentral() +// maven(url = "https://androidx.dev/storage/compose-compiler/repository") +// } +// +// dependencies { +// classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlinVersion}") +// classpath("com.android.tools.build:gradle:8.2.0") +// classpath("com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:2.0.0-Beta1-1.0.15") +// classpath("com.rickclephas.kmp:kmp-nativecoroutines-gradle-plugin:${Versions.kmpNativeCoroutines}") +// } +//} +// +//allprojects { +// repositories { +// google() +// mavenCentral() +// maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-coroutines/maven") +// maven(url = "https://androidx.dev/storage/compose-compiler/repository") +// } +//} diff --git a/buildSrc/.gitignore b/buildSrc/.gitignore deleted file mode 100644 index 378eac2..0000000 --- a/buildSrc/.gitignore +++ /dev/null @@ -1 +0,0 @@ -build diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts deleted file mode 100644 index d317042..0000000 --- a/buildSrc/build.gradle.kts +++ /dev/null @@ -1,7 +0,0 @@ -repositories { - mavenCentral() -} - -plugins { - `kotlin-dsl` -} diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt deleted file mode 100644 index 36dfda8..0000000 --- a/buildSrc/src/main/java/Dependencies.kt +++ /dev/null @@ -1,63 +0,0 @@ - -object Versions { - const val kotlinVersion = "2.0.0-Beta1" - const val kotlinCoroutines = "1.7.3" - - const val compose = "1.5.4" - const val composeCompiler = "1.5.5-dev-k2.0.0-Beta1-06b8ae672a4" - const val composeDesktopWeb = "1.6.0" - const val navCompose = "2.5.2" - const val accompanist = "0.26.2-beta" - const val okio = "3.0.0" - - const val kmpNativeCoroutines = "1.0.0-ALPHA-18" - - const val junit = "4.13" -} - - -object AndroidSdk { - const val min = 24 - const val compile = 34 - const val target = compile -} - -object Compose { - const val compiler = "androidx.compose.compiler:compiler:${Versions.composeCompiler}" - const val ui = "androidx.compose.ui:ui:${Versions.compose}" - const val runtime = "androidx.compose.runtime:runtime:${Versions.compose}" - const val uiGraphics = "androidx.compose.ui:ui-graphics:${Versions.compose}" - const val uiTooling = "androidx.compose.ui:ui-tooling:${Versions.compose}" - const val foundationLayout = "androidx.compose.foundation:foundation-layout:${Versions.compose}" - const val material = "androidx.compose.material:material:${Versions.compose}" - const val navigation = "androidx.navigation:navigation-compose:${Versions.navCompose}" -} - -object Google { - object Accompanist { - const val insets = "com.google.accompanist:accompanist-insets:${Versions.accompanist}" - } -} - -object Test { - const val junit = "junit:junit:${Versions.junit}" - const val composeUiTest = "androidx.compose.ui:ui-test:${Versions.compose}" - const val composeUiTestJUnit = "androidx.compose.ui:ui-test-junit4:${Versions.compose}" - const val composeUiTestManifest = "androidx.compose.ui:ui-test-manifest:${Versions.compose}" -} - -object Kotlinx { - const val coroutinesCore = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.kotlinCoroutines}" - const val coroutinesTest = "org.jetbrains.kotlinx:kotlinx-coroutines-test:${Versions.kotlinCoroutines}" -} - -object Square { - const val okio = "com.squareup.okio:okio:${Versions.okio}" -} - - - - - - - diff --git a/compose-desktop/build.gradle.kts b/compose-desktop/build.gradle.kts index f370b0f..a4e7baf 100644 --- a/compose-desktop/build.gradle.kts +++ b/compose-desktop/build.gradle.kts @@ -1,17 +1,13 @@ plugins { kotlin("jvm") - id("org.jetbrains.compose") version Versions.composeDesktopWeb application + alias(libs.plugins.jetbrainsCompose) + alias(libs.plugins.compose.compiler) } group = "me.joreilly" version = "1.0-SNAPSHOT" -repositories { - mavenCentral() - maven(url = "https://maven.pkg.jetbrains.space/public/p/compose/dev") -} - dependencies { implementation(compose.desktop.currentOs) implementation(project(":shared")) @@ -21,7 +17,3 @@ application { mainClass.set("MainKt") } -compose { - kotlinCompilerPlugin.set("1.5.4-dev1-kt2.0.0-Beta1") - kotlinCompilerPluginArgs.add("suppressKotlinVersionCompatibilityCheck=2.0.0-Beta1") -} diff --git a/gradle.properties b/gradle.properties index f282a27..a06dffb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,7 @@ +#Gradle +org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx2048M" + + kotlin.code.style=official android.useAndroidX=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..970d6e0 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,42 @@ +[versions] +kotlin = "2.0.0" +ksp = "2.0.0-1.0.21" +kotlinx-coroutines = "1.8.1" + + +agp = "8.4.1" +android-compileSdk = "34" +android-minSdk = "24" +android-targetSdk = "34" +androidx-activityCompose = "1.9.0" +androidxComposeBom = "2024.05.00" +compose-plugin = "1.6.10" +accompanist = "0.26.2-beta" +kmp-nativecoroutines = "1.0.0-ALPHA-31" +okio = "3.9.0" + +[libraries] +kotlinx-coroutines = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" } +kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" } + +androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" } +androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "androidxComposeBom" } +androidx-compose-foundation = { group = "androidx.compose.foundation", name = "foundation" } +androidx-compose-foundation-layout = { group = "androidx.compose.foundation", name = "foundation-layout" } +androidx-compose-material = { group = "androidx.compose.material", name = "material" } +androidx-compose-runtime = { group = "androidx.compose.runtime", name = "runtime" } +androidx-compose-ui = { group = "androidx.compose.ui", name = "ui" } +androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" } +androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" } +accompanist-insets = { module = "com.google.accompanist:accompanist-insets", version.ref = "accompanist" } +okio = { module = "com.squareup.okio:okio", version.ref = "okio" } + + +[plugins] +androidApplication = { id = "com.android.application", version.ref = "agp" } +androidLibrary = { id = "com.android.library", version.ref = "agp" } +ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } +jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" } +compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } +kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } +kmpNativeCoroutines = { id = "com.rickclephas.kmp.nativecoroutines", version.ref = "kmp-nativecoroutines" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e998515..e50d3e3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Sat Jan 21 13:46:25 GMT 2023 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle.kts b/settings.gradle.kts index 75de3c4..25d1fc1 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -3,10 +3,18 @@ pluginManagement { google() gradlePluginPortal() mavenCentral() - maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") } } -rootProject.name = "WordMasterKMP" +dependencyResolutionManagement { + repositories { + google() + mavenCentral() + } +} + + + +rootProject.name = "WordMasterKMP" include(":androidApp", ":shared", "compose-desktop") diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts index 1f4a9a9..2dd8594 100644 --- a/shared/build.gradle.kts +++ b/shared/build.gradle.kts @@ -1,8 +1,8 @@ plugins { kotlin("multiplatform") id("com.android.library") - id("com.google.devtools.ksp") - id("com.rickclephas.kmp.nativecoroutines") + alias(libs.plugins.ksp) + alias(libs.plugins.kmpNativeCoroutines) } kotlin { @@ -21,15 +21,15 @@ kotlin { sourceSets { commonMain.dependencies { - api(Kotlinx.coroutinesCore) - implementation(Square.okio) + implementation(libs.kotlinx.coroutines) + implementation(libs.okio) } -// commonTest.dependencies { -// implementation(Kotlinx.coroutinesTest) -// implementation(kotlin("test-common")) -// implementation(kotlin("test-annotations-common")) -// } + commonTest.dependencies { + implementation(libs.kotlinx.coroutines.test) + implementation(kotlin("test-common")) + implementation(kotlin("test-annotations-common")) + } val androidUnitTest by getting { dependencies { @@ -43,11 +43,10 @@ kotlin { android { namespace = "dev.johnoreilly.wordmaster.shared" - compileSdk = AndroidSdk.compile + compileSdk = libs.versions.android.compileSdk.get().toInt() sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") defaultConfig { - minSdk = AndroidSdk.min - targetSdk = AndroidSdk.target + minSdk = libs.versions.android.minSdk.get().toInt() } compileOptions { sourceCompatibility = JavaVersion.VERSION_17