Skip to content

Commit

Permalink
Update kotlin version in examples (#4844)
Browse files Browse the repository at this point in the history
Changes:
- update all examples to Kotlin 2.0
- migrate to using kotlin("plugin.compose") for Compose compiler
configuration
- remove deprecated Compose Web gradle API usages

- added a workaround for
#4848 in
Jetsnack example

Testing:
- `./gradlew build` in every example
- run some examples in simulators (or desktop, browser)

(cherry picked from commit 4c01cbd)
  • Loading branch information
eymar committed May 29, 2024
1 parent 2b4d426 commit 70b8c44
Show file tree
Hide file tree
Showing 100 changed files with 141 additions and 281 deletions.
1 change: 1 addition & 0 deletions ci/templates/desktop-template/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat

plugins {
kotlin("jvm")
kotlin("plugin.compose")
id("org.jetbrains.compose")
}

Expand Down
4 changes: 2 additions & 2 deletions ci/templates/desktop-template/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
kotlin.code.style=official
kotlin.version=1.9.23
compose.version=1.6.2
kotlin.version=2.0.0
compose.version=1.6.10
1 change: 1 addition & 0 deletions ci/templates/desktop-template/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pluginManagement {

plugins {
kotlin("jvm").version(extra["kotlin.version"] as String)
kotlin("plugin.compose").version(extra["kotlin.version"] as String)
id("org.jetbrains.compose").version(extra["compose.version"] as String)
}
}
10 changes: 1 addition & 9 deletions ci/templates/html-library-template/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension

plugins {
kotlin("multiplatform")
kotlin("plugin.compose")
id("org.jetbrains.compose")
}

Expand Down Expand Up @@ -30,12 +31,3 @@ kotlin {
}
}

// a temporary workaround for a bug in jsRun invocation - see https://youtrack.jetbrains.com/issue/KT-48273
afterEvaluate {
rootProject.extensions.configure<NodeJsRootExtension> {
nodeVersion = "16.0.0"
versions.webpackDevServer.version = "4.0.0"
versions.webpackCli.version = "4.10.0"
}
}

4 changes: 2 additions & 2 deletions ci/templates/html-library-template/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
kotlin.code.style=official
kotlin.version=1.9.23
compose.version=1.6.2
kotlin.version=2.0.0
compose.version=1.6.10
1 change: 1 addition & 0 deletions ci/templates/html-library-template/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pluginManagement {

plugins {
kotlin("multiplatform").version(extra["kotlin.version"] as String)
kotlin("plugin.compose").version(extra["kotlin.version"] as String)
id("org.jetbrains.compose").version(extra["compose.version"] as String)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id("com.android.application")
kotlin("android")
kotlin("plugin.compose")
id("org.jetbrains.compose")
}

Expand Down
1 change: 1 addition & 0 deletions ci/templates/multiplatform-template/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
// in each subproject's classloader
kotlin("jvm") apply false
kotlin("multiplatform") apply false
kotlin("plugin.compose") apply false
kotlin("android") apply false
id("com.android.application") apply false
id("com.android.library") apply false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id("com.android.library")
kotlin("multiplatform")
kotlin("plugin.compose")
id("org.jetbrains.compose")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat
plugins {
kotlin("multiplatform")
id("org.jetbrains.compose")
kotlin("plugin.compose")
}

kotlin {
Expand Down
4 changes: 2 additions & 2 deletions ci/templates/multiplatform-template/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
android.useAndroidX=true
android.enableJetifier=true
kotlin.code.style=official
kotlin.version=1.9.23
kotlin.version=2.0.0
agp.version=8.0.2
compose.version=1.6.2
compose.version=1.6.10
1 change: 1 addition & 0 deletions ci/templates/multiplatform-template/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pluginManagement {
plugins {
kotlin("jvm").version(extra["kotlin.version"] as String)
kotlin("multiplatform").version(extra["kotlin.version"] as String)
kotlin("plugin.compose").version(extra["kotlin.version"] as String)
kotlin("android").version(extra["kotlin.version"] as String)
id("com.android.application").version(extra["agp.version"] as String)
id("com.android.library").version(extra["agp.version"] as String)
Expand Down
1 change: 1 addition & 0 deletions examples/chat/androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
kotlin("multiplatform")
kotlin("plugin.compose")
id("com.android.application")
id("org.jetbrains.compose")
}
Expand Down
1 change: 1 addition & 0 deletions examples/chat/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
// in each subproject's classloader
kotlin("jvm") apply false
kotlin("multiplatform") apply false
kotlin("plugin.compose") apply false
kotlin("android") apply false
id("com.android.application") apply false
id("com.android.library") apply false
Expand Down
1 change: 1 addition & 0 deletions examples/chat/desktopApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
kotlin("multiplatform")
kotlin("plugin.compose")
id("org.jetbrains.compose")
}

Expand Down
6 changes: 3 additions & 3 deletions examples/chat/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kotlin.code.style=official
xcodeproj=./iosApp
android.useAndroidX=true
org.gradle.jvmargs=-Xmx3g
org.gradle.jvmargs=-Xmx8g
org.gradle.configuration-cache=true
org.gradle.caching=true
org.jetbrains.compose.experimental.jscanvas.enabled=true
Expand All @@ -10,6 +10,6 @@ kotlin.native.useEmbeddableCompilerJar=true
kotlin.mpp.androidSourceSetLayoutVersion=2
# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
kotlin.version=1.9.23
kotlin.version=2.0.0
agp.version=8.0.2
compose.version=1.6.2
compose.version=1.6.10
5 changes: 1 addition & 4 deletions examples/chat/jsApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
kotlin("multiplatform")
kotlin("plugin.compose")
id("org.jetbrains.compose")
}

Expand All @@ -19,7 +20,3 @@ kotlin {
}
}

compose.experimental {
web.application {}
}

6 changes: 4 additions & 2 deletions examples/chat/jsApp/src/jsMain/kotlin/main.js.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.ui.Modifier
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.CanvasBasedWindow
import androidx.compose.ui.ExperimentalComposeUiApi
import org.jetbrains.skiko.wasm.onWasmReady

@OptIn(ExperimentalComposeUiApi::class)
fun main() {
onWasmReady {
Window("Chat") {
CanvasBasedWindow(title = "Chat") {
Column(modifier = Modifier.fillMaxSize()) {
MainView()
}
Expand Down
1 change: 1 addition & 0 deletions examples/chat/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pluginManagement {

kotlin("jvm").version(kotlinVersion)
kotlin("multiplatform").version(kotlinVersion)
kotlin("plugin.compose").version(kotlinVersion)
kotlin("android").version(kotlinVersion)
id("com.android.base").version(agpVersion)
id("com.android.application").version(agpVersion)
Expand Down
1 change: 1 addition & 0 deletions examples/chat/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

plugins {
kotlin("multiplatform")
kotlin("plugin.compose")
id("com.android.library")
id("org.jetbrains.compose")
}
Expand Down
1 change: 1 addition & 0 deletions examples/cocoapods-ios-example/androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
kotlin("multiplatform")
kotlin("plugin.compose")
id("com.android.application")
id("org.jetbrains.compose")
}
Expand Down
1 change: 1 addition & 0 deletions examples/cocoapods-ios-example/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
// this is necessary to avoid the plugins to be loaded multiple times
// in each subproject's classloader
kotlin("multiplatform").apply(false)
kotlin("plugin.compose").apply(false)
id("com.android.application").apply(false)
id("com.android.library").apply(false)
id("org.jetbrains.compose").apply(false)
Expand Down
6 changes: 3 additions & 3 deletions examples/cocoapods-ios-example/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Gradle
org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M"
org.gradle.jvmargs=-Xmx8g -Dkotlin.daemon.jvm.options\="-Xmx8g"
org.gradle.configuration-cache=true
org.gradle.caching=true

Expand All @@ -20,6 +20,6 @@ android.minSdk=24
#Compose

#Versions
kotlin.version=1.9.23
kotlin.version=2.0.0
agp.version=8.0.2
compose.version=1.6.2
compose.version=1.6.10
1 change: 1 addition & 0 deletions examples/cocoapods-ios-example/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pluginManagement {
val composeVersion = extra["compose.version"] as String

kotlin("jvm").version(kotlinVersion)
kotlin("plugin.compose").version(kotlinVersion)
kotlin("multiplatform").version(kotlinVersion)
kotlin("android").version(kotlinVersion)

Expand Down
1 change: 1 addition & 0 deletions examples/cocoapods-ios-example/shared/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
kotlin("multiplatform")
kotlin("plugin.compose")
kotlin("native.cocoapods")
id("com.android.library")
id("org.jetbrains.compose")
Expand Down
1 change: 1 addition & 0 deletions examples/codeviewer/androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
kotlin("multiplatform")
kotlin("plugin.compose")
id("com.android.application")
id("org.jetbrains.compose")
}
Expand Down
1 change: 1 addition & 0 deletions examples/codeviewer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
// in each subproject's classloader
kotlin("jvm") apply false
kotlin("multiplatform") apply false
kotlin("plugin.compose") apply false
kotlin("android") apply false
id("com.android.application") apply false
id("com.android.library") apply false
Expand Down
1 change: 1 addition & 0 deletions examples/codeviewer/desktopApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat

plugins {
kotlin("multiplatform")
kotlin("plugin.compose")
id("org.jetbrains.compose")
}

Expand Down
6 changes: 3 additions & 3 deletions examples/codeviewer/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kotlin.code.style=official
xcodeproj=./iosApp
android.useAndroidX=true
org.gradle.jvmargs=-Xmx3g
org.gradle.jvmargs=-Xmx8g
org.gradle.configuration-cache=true
org.gradle.caching=true
org.jetbrains.compose.experimental.jscanvas.enabled=true
Expand All @@ -10,6 +10,6 @@ kotlin.native.useEmbeddableCompilerJar=true
kotlin.mpp.androidSourceSetLayoutVersion=2
# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
kotlin.version=1.9.23
kotlin.version=2.0.0
agp.version=8.0.2
compose.version=1.6.2
compose.version=1.6.10
1 change: 1 addition & 0 deletions examples/codeviewer/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pluginManagement {

kotlin("jvm").version(kotlinVersion)
kotlin("multiplatform").version(kotlinVersion)
kotlin("plugin.compose").version(kotlinVersion)
kotlin("android").version(kotlinVersion)
id("com.android.base").version(agpVersion)
id("com.android.application").version(agpVersion)
Expand Down
1 change: 1 addition & 0 deletions examples/codeviewer/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

plugins {
kotlin("multiplatform")
kotlin("plugin.compose")
id("com.android.library")
id("org.jetbrains.compose")
}
Expand Down
Loading

0 comments on commit 70b8c44

Please sign in to comment.