Skip to content

Commit

Permalink
Migrate to kotlin 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
xxfast committed May 29, 2024
1 parent 7491f3b commit bcd90d4
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 37 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@

[![Kotlin Experimental](https://kotl.in/badges/experimental.svg)](https://kotlinlang.org/docs/components-stability.html)
[![Build](https://github.com/xxfast/Decompose-Router/actions/workflows/build.yml/badge.svg)](https://github.com/xxfast/Decompose-Router/actions/workflows/build.yml)
[![Kotlin](https://img.shields.io/badge/Kotlin-1.9.10-blue.svg?style=flat&logo=kotlin)](https://kotlinlang.org)
[![Kotlin](https://img.shields.io/badge/Kotlin-2.0.0-blue.svg?style=flat&logo=kotlin)](https://kotlinlang.org)
[![Maven Central](https://img.shields.io/maven-central/v/io.github.xxfast/decompose-router?color=blue)](https://search.maven.org/search?q=g:io.github.xxfast)

![badge-android](http://img.shields.io/badge/platform-android-6EDB8D.svg?style=flat)
![badge-wearos](http://img.shields.io/badge/platform-wearos-8ECDA0.svg?style=flat)
![badge-desktop](http://img.shields.io/badge/platform-desktop-4D76CD.svg?style=flat)
![badge-ios](http://img.shields.io/badge/platform-ios-EAEAEA.svg?style=flat)
![badge-browser](https://img.shields.io/badge/platform-js-F8DB5D.svg?style=flat)
![badge-browser-js](https://img.shields.io/badge/platform-js-F8DB5D.svg?style=flat)
![badge-browser-wasm](https://img.shields.io/badge/platform-wasm-F8DB5D.svg?style=flat)

A Compose-multiplatform navigation library that leverage [Decompose](https://github.com/arkivanov/Decompose) to create an API inspired by [Conductor](https://github.com/bluelinelabs/Conductor)

Expand Down
10 changes: 5 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

plugins {
kotlin("multiplatform")
kotlin("plugin.serialization")
id("com.android.application")
id("org.jetbrains.compose")
alias(libs.plugins.android.application)
alias(libs.plugins.compose.multiplatform)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.kotlin.serialization)
}

@OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class)
kotlin {
targetHierarchy.default()
applyDefaultHierarchyTemplate()

androidTarget {
compilations.all {
Expand Down
24 changes: 11 additions & 13 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties

plugins {
id("org.jetbrains.dokka") version "1.8.20"
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.13.2"
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.compose) apply false
alias(libs.plugins.compose.multiplatform) apply false

alias(libs.plugins.dokka)
alias(libs.plugins.binary.compatibility.validator)
}

buildscript {
Expand All @@ -11,13 +16,6 @@ buildscript {
mavenCentral()
gradlePluginPortal()
}

dependencies {
classpath(libs.agp)
classpath(libs.compose.multiplatform)
classpath(libs.kotlin.gradle.plugin)
classpath(libs.kotlin.serialization.plugin)
}
}

apiValidation {
Expand Down Expand Up @@ -52,8 +50,8 @@ allprojects {
)

credentials {
username = gradleLocalProperties(rootDir).getProperty("sonatypeUsername")
password = gradleLocalProperties(rootDir).getProperty("sonatypePassword")
username = gradleLocalProperties(rootDir, providers).getProperty("sonatypeUsername")
password = gradleLocalProperties(rootDir, providers).getProperty("sonatypePassword")
}
}
}
Expand Down Expand Up @@ -100,8 +98,8 @@ allprojects {
val publishing = extensions.getByType<PublishingExtension>()
extensions.configure<SigningExtension> {
useInMemoryPgpKeys(
gradleLocalProperties(rootDir).getProperty("gpgKeySecret"),
gradleLocalProperties(rootDir).getProperty("gpgKeyPassword"),
gradleLocalProperties(rootDir, providers).getProperty("gpgKeySecret"),
gradleLocalProperties(rootDir, providers).getProperty("gpgKeyPassword"),
)

sign(publishing.publications)
Expand Down
5 changes: 3 additions & 2 deletions decompose-router-wear/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
plugins {
kotlin("multiplatform")
id("com.android.library")
id("org.jetbrains.compose")
alias(libs.plugins.android.library)
alias(libs.plugins.compose.multiplatform)
alias(libs.plugins.kotlin.compose)
}

kotlin {
Expand Down
6 changes: 3 additions & 3 deletions decompose-router/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

plugins {
kotlin("multiplatform")
id("com.android.library")
id("org.jetbrains.compose")
id("kotlin-parcelize")
alias(libs.plugins.android.library)
alias(libs.plugins.compose.multiplatform)
alias(libs.plugins.kotlin.compose)
}

kotlin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisallowComposableCalls
import androidx.compose.runtime.remember
import com.arkivanov.essenty.instancekeeper.InstanceKeeper
import com.arkivanov.essenty.instancekeeper.getOrCreate
import kotlin.reflect.KClass

/***
Expand All @@ -23,12 +24,7 @@ fun <T: Any> rememberOnRoute(
val routerContext: RouterContext = LocalRouterContext.current
val instanceKeeper: InstanceKeeper = routerContext.instanceKeeper
val routeInstance: RouteInstance = remember(key) {
var instance: RouteInstance? = instanceKeeper.get(key) as RouteInstance?
if (instance == null) {
instance = RouteInstance(block(routerContext))
instanceKeeper.put(key, instance)
}
instance
instanceKeeper.getOrCreate(key) { RouteInstance(block(routerContext)) }
}
return routeInstance.instance
}
18 changes: 13 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
[versions]
agp = "8.1.1"
agp = "8.3.2"
androidx-activity ="1.7.2"
androidx-fragment ="1.6.1"
compose-multiplatform = "1.6.10"
compose-test-rule = "1.5.1"
decompose = "3.0.0"
essenty = "2.0.0"
dokka = "1.8.20"
binary-compatibility-validator = "0.13.2"
horologist = "0.5.7"
kotlin = "1.9.24"
kotlin = "2.0.0"
kotlinx-coroutines = "1.8.0"
kotlinx-serialization = "1.6.3"
wear-compose = "1.3.0-alpha03"

[libraries]
agp = { module = "com.android.tools.build:gradle", version.ref = "agp" }
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" }
androidx-activity-ktx = { module = "androidx.activity:activity-ktx", version.ref = "androidx-activity" }
androidx-fragment-ktx = { module = "androidx.fragment:fragment-ktx", version.ref = "androidx-fragment" }
Expand All @@ -25,9 +25,17 @@ decompose-compose-multiplatform = { module = "com.arkivanov.decompose:extensions
horologist-compose-layouts = { module = "com.google.android.horologist:horologist-compose-layout", version.ref = "horologist" }
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
kotlinx-coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-swing", version.ref = "kotlinx-coroutines" }
kotlin-serialization-plugin = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" }
kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlinx-serialization" }
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlin-serialization-json", version.ref = "kotlinx-serialization" }
wear-compose-foundation = { module = "androidx.wear.compose:compose-foundation", version.ref = "wear-compose" }
wear-compose-material = { module = "androidx.wear.compose:compose-material", version.ref = "wear-compose" }
wear-compose-ui-tooling = { module = "androidx.wear.compose:compose-ui-tooling", version.ref = "wear-compose" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
binary-compatibility-validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binary-compatibility-validator" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
compose-multiplatform = { id = "org.jetbrains.compose", version.ref = "compose-multiplatform" }
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit bcd90d4

Please sign in to comment.