Skip to content

Commit

Permalink
Merge pull request #232 from joreilly/skie_update
Browse files Browse the repository at this point in the history
Kotlin 2.0.0 + related dependency updates
  • Loading branch information
joreilly committed May 25, 2024
2 parents b1ebcb9 + 89cd6b9 commit 32ffd70
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 61 deletions.
5 changes: 1 addition & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
plugins {
id("com.android.application")
kotlin("android")
alias(libs.plugins.compose.compiler)
}

android {
Expand All @@ -26,10 +27,6 @@ android {
compose = true
}

composeOptions {
kotlinCompilerExtensionVersion = libs.versions.androidxComposeCompiler.get()
}

signingConfigs {
getByName("debug") {
keyAlias = "androiddebugkey"
Expand Down
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.jetbrainsCompose) apply false
alias(libs.plugins.kotlinMultiplatform) apply false
alias(libs.plugins.kotlin.serialization) apply false
alias(libs.plugins.kotlinx.serialization) apply false
alias(libs.plugins.skie) apply false
}
33 changes: 22 additions & 11 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
kotlin("multiplatform")
id("kotlinx-serialization")
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.kotlinx.serialization)
id("com.android.library")
id("org.jetbrains.compose") version libs.versions.composeMultiplatform
id("com.google.devtools.ksp")
id("co.touchlab.skie")
alias(libs.plugins.ksp)
alias(libs.plugins.skie)
alias(libs.plugins.room)
alias(libs.plugins.jetbrainsCompose)
alias(libs.plugins.compose.compiler)
}

kotlin {
Expand Down Expand Up @@ -39,11 +41,16 @@ kotlin {
jvm()


@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
languageVersion.set(KOTLIN_1_9)
languageVersion.set(KotlinVersion.KOTLIN_2_0)
}

sourceSets {
sourceSets.commonMain {
kotlin.srcDir("build/generated/ksp/metadata")
}

all {
languageSettings.optIn("kotlinx.cinterop.ExperimentalForeignApi")
}
Expand Down Expand Up @@ -102,12 +109,16 @@ kotlin.sourceSets.all {


dependencies {
add("kspAndroid", libs.androidx.room.compiler)
add("kspIosSimulatorArm64", libs.androidx.room.compiler)
add("kspIosX64", libs.androidx.room.compiler)
add("kspIosArm64", libs.androidx.room.compiler)
add("kspCommonMainMetadata", libs.androidx.room.compiler)
}


room {
schemaDirectory("$projectDir/schemas")
}

tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>>().configureEach {
if (name != "kspCommonMainKotlinMetadata" ) {
dependsOn("kspCommonMainKotlinMetadata")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ import kotlinx.datetime.LocalDateTime

@Database(entities = [Team::class, Player::class, GameFixture::class], version = 1)
@TypeConverters(LocalDateTimeConverter::class)
abstract class AppDatabase : RoomDatabase() {
abstract class AppDatabase : RoomDatabase(), DB {
abstract fun fantasyPremierLeagueDao(): FantasyPremierLeagueDao

override fun clearAllTables() {
super.clearAllTables()
}
}

internal const val dbFileName = "fantasypremierleague.db"
Expand All @@ -28,4 +32,11 @@ class LocalDateTimeConverter {
fun dateToTimestamp(date: LocalDateTime?): String? {
return date?.toString()
}
}


// FIXME: Added a hack to resolve below issue:
// Class 'AppDatabase_Impl' is not abstract and does not implement abstract base class member 'clearAllTables'.
interface DB {
fun clearAllTables(): Unit {}
}
7 changes: 4 additions & 3 deletions common/src/jvmMain/kotlin/dev/johnoreilly/common/actual.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dev.johnoreilly.common

import androidx.datastore.core.DataStore
import androidx.room.Room
import androidx.sqlite.driver.bundled.BundledSQLiteDriver
import dev.johnoreilly.common.database.AppDatabase
import dev.johnoreilly.common.database.dbFileName
import io.ktor.client.engine.java.*
Expand All @@ -18,9 +19,9 @@ actual fun platformModule() = module {

fun createRoomDatabase(): AppDatabase {
val dbFile = File(System.getProperty("java.io.tmpdir"), dbFileName)
return Room.databaseBuilder<AppDatabase>(
name = dbFile.absolutePath,
).build()
return Room.databaseBuilder<AppDatabase>(name = dbFile.absolutePath,)
.setDriver(BundledSQLiteDriver())
.build()
}

fun dataStore(): DataStore<androidx.datastore.preferences.core.Preferences> =
Expand Down
3 changes: 2 additions & 1 deletion compose-desktop/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm")
id("org.jetbrains.compose") version libs.versions.composeMultiplatform
alias(libs.plugins.jetbrainsCompose)
alias(libs.plugins.compose.compiler)
application
}

Expand Down
5 changes: 3 additions & 2 deletions compose-desktop/src/main/kotlin/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import androidx.compose.ui.window.application
import androidx.compose.ui.window.rememberWindowState
import dev.johnoreilly.common.data.repository.FantasyPremierLeagueRepository
import dev.johnoreilly.common.di.initKoin
import dev.johnoreilly.common.domain.entities.Player
import dev.johnoreilly.common.model.Player
import dev.johnoreilly.common.ui.PlayerDetailsViewShared
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.FlowPreview
Expand Down Expand Up @@ -63,13 +63,14 @@ fun MainLayout() {

val searchQuery = MutableStateFlow("")
val playerList by searchQuery.debounce(250).flatMapLatest { searchQueryValue ->
repository.playerList.mapLatest { playerList ->
repository.getPlayers().mapLatest { playerList ->
playerList
.filter { it.name.contains(searchQueryValue, ignoreCase = true) }
.sortedByDescending { it.points }
}
}.collectAsState(emptyList())


BoxWithConstraints {
if (maxWidth.value > 700) {
TwoColumnsLayout(playerList, selectedPlayer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.unit.dp
import dev.johnoreilly.common.domain.entities.Player
import dev.johnoreilly.common.model.Player
import java.awt.image.BufferedImage
import java.io.ByteArrayOutputStream
import java.io.InputStream
Expand Down
14 changes: 0 additions & 14 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Thu Aug 05 18:30:54 IST 2021
kotlin.code.style=official
org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M"
android.useAndroidX=true
Expand All @@ -21,4 +8,3 @@ org.jetbrains.compose.experimental.uikit.enabled=true
# Disabled due to https://youtrack.jetbrains.com/issue/KT-65761
kotlin.native.disableCompilerDaemon = true

kotlin.experimental.tryK2=true
37 changes: 19 additions & 18 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
[versions]
kotlin = "1.9.23"
ksp = "1.9.23-1.0.19"
coroutines = "1.8.0"
kotlinxSerialization = "1.6.3"
kotlinxDateTime = "0.5.0"
kotlin = "2.0.0"
ksp = "2.0.0-1.0.21"
kotlinx-coroutines = "1.8.1"
kotlinx-serialization = "1.6.3"
kotlinx-dateTime = "0.6.0"

androidGradlePlugin = "8.2.2"
koalaplot = "0.5.3"
koin = "3.6.0-Beta4"
koinCompose = "3.6.0-Beta4"
koinComposeMultiplatform = "1.2.0-Beta4"
ktor = "2.3.9"
ktor = "2.3.11"
slf4j = "2.0.12"
skie = "0.6.2"
skie = "0.8.0"
datastore = "1.1.1"

androidxActivity = "1.9.0"
androidxComposeCompiler = "1.5.11-dev-k1.9.23-96ef9dc6af1"
jbComposeCompiler = "1.5.8"
androidxComposeBom = "2024.04.01"
androidxNavigationCompose = "2.8.0-alpha08"
androidxLifecycle = "2.8.0-rc01"
androidxRoom = "2.7.0-alpha01"
androidxComposeBom = "2024.05.00"
androidxNavigationCompose = "2.8.0-beta01"
androidxLifecycle = "2.8.0"
androidxRoom = "2.7.0-alpha02"
sqlite = "2.5.0-SNAPSHOT"
composeMultiplatform = "1.6.1"
compose-plugin = "1.6.10"
accompanist = "0.32.0"
coilCompose = "2.6.0"
image-loader = "1.7.8"
Expand All @@ -34,9 +33,9 @@ compileSdk = "34"


[libraries]
kotlinx-coroutines = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "coroutines" }
kotlinx-datetime = { group = "org.jetbrains.kotlinx", name = "kotlinx-datetime", version.ref = "kotlinxDateTime" }
kotlinx-serialization = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-core", version.ref = "kotlinxSerialization" }
kotlinx-coroutines = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
kotlinx-datetime = { group = "org.jetbrains.kotlinx", name = "kotlinx-datetime", version.ref = "kotlinx-dateTime" }
kotlinx-serialization = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-core", version.ref = "kotlinx-serialization" }

androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidxActivity" }
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "androidxComposeBom" }
Expand Down Expand Up @@ -97,6 +96,8 @@ android-application = { id = "com.android.application", version.ref = "androidGr
android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
skie = { id = "co.touchlab.skie", version.ref = "skie"}
room = { id = "androidx.room", version.ref = "androidxRoom" }
jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", 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.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
5 changes: 1 addition & 4 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
maven("https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental")
maven("https://androidx.dev/storage/compose-compiler/repository")
}
}

rootProject.name = "FantasyPremierLeague"

include(":app", ":common")
//include("compose-desktop")
include("compose-desktop")

0 comments on commit 32ffd70

Please sign in to comment.