From 30163ef77e75b9f37059edfa43bf0ced9ca97b32 Mon Sep 17 00:00:00 2001 From: Viktor Savchik Date: Mon, 12 Jan 2026 23:19:47 +0100 Subject: [PATCH 1/4] Upgrade to Kotlin 2.3.0 and modernize build config - Kotlin 1.9.21 -> 2.3.0 - AGP 8.2.2 -> 8.7.3 - Gradle 8.2 -> 8.11.1 - Compose BOM 2024.12.01 (replaces individual versions) - Core KTX 1.12.0 -> 1.15.0 - Activity Compose 1.8.2 -> 1.9.3 - JVM target 1.8 -> 17 - compileSdk 34 -> 35 - Library version 0.0.6 -> 0.0.7 Migration changes: - Add Kotlin compose compiler plugin (bundled with Kotlin 2.x) - Replace deprecated kotlinOptions with compilerOptions DSL - Fix deprecated getTimeMillis() in iOS implementation - Simplify publishing configuration - Add example app module --- build.gradle.kts | 5 +- example/.gitignore | 10 ++ example/androidApp/build.gradle.kts | 50 ++++++++++ .../androidApp/src/main/AndroidManifest.xml | 17 ++++ .../onexeor/example/android/MainActivity.kt | 40 ++++++++ .../example/android/MyApplicationTheme.kt | 55 +++++++++++ .../androidApp/src/main/res/values/styles.xml | 3 + .../AccentColor.colorset/Contents.json | 11 +++ .../AppIcon.appiconset/Contents.json | 98 +++++++++++++++++++ .../iosApp/Assets.xcassets/Contents.json | 6 ++ example/iosApp/iosApp/ContentView.swift | 16 +++ example/iosApp/iosApp/Info.plist | 48 +++++++++ .../Preview Assets.xcassets/Contents.json | 6 ++ example/iosApp/iosApp/iOSApp.swift | 10 ++ example/shared/build.gradle.kts | 47 +++++++++ .../dev/onexeor/example/Platform.android.kt | 7 ++ .../kotlin/dev/onexeor/example/Greeting.kt | 9 ++ .../kotlin/dev/onexeor/example/Platform.kt | 7 ++ .../dev/onexeor/example/Platform.ios.kt | 9 ++ gradle/libs.versions.toml | 24 ++--- gradle/wrapper/gradle-wrapper.properties | 3 +- settings.gradle.kts | 4 +- shared/build.gradle.kts | 54 ++++------ .../dev/onexeor/kdownloader/KDownloader.kt | 4 +- 24 files changed, 489 insertions(+), 54 deletions(-) create mode 100644 example/.gitignore create mode 100644 example/androidApp/build.gradle.kts create mode 100644 example/androidApp/src/main/AndroidManifest.xml create mode 100644 example/androidApp/src/main/java/dev/onexeor/example/android/MainActivity.kt create mode 100644 example/androidApp/src/main/java/dev/onexeor/example/android/MyApplicationTheme.kt create mode 100644 example/androidApp/src/main/res/values/styles.xml create mode 100644 example/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 example/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 example/iosApp/iosApp/Assets.xcassets/Contents.json create mode 100644 example/iosApp/iosApp/ContentView.swift create mode 100644 example/iosApp/iosApp/Info.plist create mode 100644 example/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json create mode 100644 example/iosApp/iosApp/iOSApp.swift create mode 100644 example/shared/build.gradle.kts create mode 100644 example/shared/src/androidMain/kotlin/dev/onexeor/example/Platform.android.kt create mode 100644 example/shared/src/commonMain/kotlin/dev/onexeor/example/Greeting.kt create mode 100644 example/shared/src/commonMain/kotlin/dev/onexeor/example/Platform.kt create mode 100644 example/shared/src/iosMain/kotlin/dev/onexeor/example/Platform.ios.kt diff --git a/build.gradle.kts b/build.gradle.kts index 4a600e3..07a28a1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,7 @@ plugins { - //trick: for the same plugin versions in all sub-modules + alias(libs.plugins.androidApplication).apply(false) alias(libs.plugins.androidLibrary).apply(false) alias(libs.plugins.kotlinMultiplatform).apply(false) - id("org.jetbrains.kotlin.android") version "1.9.21" apply false + alias(libs.plugins.kotlinAndroid).apply(false) + alias(libs.plugins.composeCompiler).apply(false) } diff --git a/example/.gitignore b/example/.gitignore new file mode 100644 index 0000000..e510fa9 --- /dev/null +++ b/example/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +.idea +.DS_Store +build +captures +.externalNativeBuild +.cxx +local.properties +xcuserdata \ No newline at end of file diff --git a/example/androidApp/build.gradle.kts b/example/androidApp/build.gradle.kts new file mode 100644 index 0000000..c3d7978 --- /dev/null +++ b/example/androidApp/build.gradle.kts @@ -0,0 +1,50 @@ +plugins { + alias(libs.plugins.androidApplication) + alias(libs.plugins.kotlinAndroid) + alias(libs.plugins.composeCompiler) +} + +android { + namespace = "dev.onexeor.example.android" + compileSdk = 35 + defaultConfig { + applicationId = "dev.onexeor.example.android" + minSdk = 24 + targetSdk = 35 + versionCode = 1 + versionName = "1.0" + } + buildFeatures { + compose = true + } + packaging { + resources { + excludes += "/META-INF/{AL2.0,LGPL2.1}" + } + } + buildTypes { + getByName("release") { + isMinifyEnabled = false + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } +} + +kotlin { + compilerOptions { + jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17) + } +} + +dependencies { + implementation(projects.example.shared) + implementation(platform(libs.compose.bom)) + implementation(libs.compose.ui) + implementation(libs.compose.ui.tooling.preview) + implementation(libs.compose.material3) + implementation(libs.androidx.activity.compose) + debugImplementation(libs.compose.ui.tooling) +} diff --git a/example/androidApp/src/main/AndroidManifest.xml b/example/androidApp/src/main/AndroidManifest.xml new file mode 100644 index 0000000..22d1fac --- /dev/null +++ b/example/androidApp/src/main/AndroidManifest.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/example/androidApp/src/main/java/dev/onexeor/example/android/MainActivity.kt b/example/androidApp/src/main/java/dev/onexeor/example/android/MainActivity.kt new file mode 100644 index 0000000..9a6deec --- /dev/null +++ b/example/androidApp/src/main/java/dev/onexeor/example/android/MainActivity.kt @@ -0,0 +1,40 @@ +package dev.onexeor.example.android + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material3.* +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import dev.onexeor.example.Greeting + +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContent { + MyApplicationTheme { + Surface( + modifier = Modifier.fillMaxSize(), + color = MaterialTheme.colorScheme.background + ) { + GreetingView(Greeting().greet()) + } + } + } + } +} + +@Composable +fun GreetingView(text: String) { + Text(text = text) +} + +@Preview +@Composable +fun DefaultPreview() { + MyApplicationTheme { + GreetingView("Hello, Android!") + } +} diff --git a/example/androidApp/src/main/java/dev/onexeor/example/android/MyApplicationTheme.kt b/example/androidApp/src/main/java/dev/onexeor/example/android/MyApplicationTheme.kt new file mode 100644 index 0000000..5b524e6 --- /dev/null +++ b/example/androidApp/src/main/java/dev/onexeor/example/android/MyApplicationTheme.kt @@ -0,0 +1,55 @@ +package dev.onexeor.example.android + +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Shapes +import androidx.compose.material3.Typography +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.lightColorScheme +import androidx.compose.runtime.Composable +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp + +@Composable +fun MyApplicationTheme( + darkTheme: Boolean = isSystemInDarkTheme(), + content: @Composable () -> Unit +) { + val colors = if (darkTheme) { + darkColorScheme( + primary = Color(0xFFBB86FC), + secondary = Color(0xFF03DAC5), + tertiary = Color(0xFF3700B3) + ) + } else { + lightColorScheme( + primary = Color(0xFF6200EE), + secondary = Color(0xFF03DAC5), + tertiary = Color(0xFF3700B3) + ) + } + val typography = Typography( + bodyMedium = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 16.sp + ) + ) + val shapes = Shapes( + small = RoundedCornerShape(4.dp), + medium = RoundedCornerShape(4.dp), + large = RoundedCornerShape(0.dp) + ) + + MaterialTheme( + colorScheme = colors, + typography = typography, + shapes = shapes, + content = content + ) +} diff --git a/example/androidApp/src/main/res/values/styles.xml b/example/androidApp/src/main/res/values/styles.xml new file mode 100644 index 0000000..6b4fa3d --- /dev/null +++ b/example/androidApp/src/main/res/values/styles.xml @@ -0,0 +1,3 @@ + +