From ecbdcce4cfc5bd0c040121d73c9e3c534570bd5a Mon Sep 17 00:00:00 2001 From: Jens Klingenberg Date: Sat, 1 Jun 2024 19:16:47 +0200 Subject: [PATCH] Update to Kotlin 2.0 --- app/build.gradle | 132 -------------------------------------- app/build.gradle.kts | 103 +++++++++++++++++++++++++++++ app/proguard-rules.pro | 2 +- build.gradle | 4 +- gradle/libs.versions.toml | 8 +++ 5 files changed, 114 insertions(+), 135 deletions(-) delete mode 100644 app/build.gradle create mode 100644 app/build.gradle.kts create mode 100644 gradle/libs.versions.toml diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index f2b15e979..000000000 --- a/app/build.gradle +++ /dev/null @@ -1,132 +0,0 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' - - - -repositories { - mavenCentral() - google() -} - -android { - packagingOptions { - exclude("META-INF/DEPENDENCIES.TXT") - exclude("META-INF/LICENSE.TXT") - exclude("META-INF/AL2.0") - exclude("META-INF/LGPL2.1") - exclude("win32-x86/attach_hotspot_windows.dll") - exclude("win32-x86-64/attach_hotspot_windows.dll") - pickFirst("META-INF/licenses/ASM") - } - compileSdk 34 - defaultConfig { - applicationId "de.jensklingenberg.jetpackcomposeplayground" - minSdkVersion 21 - targetSdk 34 - versionCode 1 - versionName "1.0" - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - namespace "de.jensklingenberg.jetpackcomposeplayground" - - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - kotlinOptions { - jvmTarget = "1.8" - - } - - buildFeatures { - compose true - } - composeOptions { - kotlinCompilerExtensionVersion "1.5.10" - } -} - -subprojects { - tasks.withType(KotlinCompile).configureEach { - kotlinOptions { - if (project.findProperty("composeCompilerReports") == "true") { - freeCompilerArgs += [ - "-P", - "plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" + - project.buildDir.absolutePath + "/compose_compiler" - ] - } - if (project.findProperty("composeCompilerMetrics") == "true") { - freeCompilerArgs += [ - "-P", - "plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" + - project.buildDir.absolutePath + "/compose_compiler" - ] - } - } - } -} - -dependencies { - - implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation "androidx.activity:activity-compose:1.8.2" - implementation "androidx.appcompat:appcompat:1.6.1" - implementation "androidx.compose.animation:animation-core:$compose_version" - implementation "androidx.compose.animation:animation:$compose_version" - implementation "androidx.compose.foundation:foundation-layout:$compose_version" - implementation "androidx.compose.foundation:foundation:$compose_version" - implementation "androidx.compose.material:material-icons-core:$compose_version" - implementation "androidx.compose.material:material-icons-extended:$compose_version" - implementation "androidx.compose.material:material:$compose_version" - implementation "androidx.compose.material:material:$compose_version" - implementation "androidx.compose.runtime:runtime-livedata:$compose_version" - implementation "androidx.compose.runtime:runtime-rxjava2:$compose_version" - implementation "androidx.compose.ui:ui-geometry:$compose_version" - implementation "androidx.compose.ui:ui-graphics:$compose_version" - implementation "androidx.compose.ui:ui-tooling:$compose_version" - implementation "androidx.compose.ui:ui-tooling:$compose_version" - implementation "androidx.compose.ui:ui:$compose_version" - implementation "androidx.core:core-ktx:1.12.0" - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.7.0' - implementation 'com.google.android.material:material:1.11.0' - implementation ("androidx.compose.ui:ui-viewbinding:$compose_version") - implementation("androidx.compose.ui:ui-text:$compose_version") - implementation("androidx.compose.ui:ui-util:$compose_version") - implementation("androidx.compose.ui:ui:$compose_version") - - //Compose Constraintlayout - implementation 'androidx.constraintlayout:constraintlayout-compose:1.0.1' - - testImplementation "junit:junit:4.13.2" - androidTestImplementation "androidx.test.espresso:espresso-core:3.5.1" - androidTestImplementation "androidx.test:runner:1.5.2" - androidTestImplementation("androidx.compose.ui:ui-test-junit4:$compose_version") - androidTestImplementation("androidx.compose.ui:ui-test:$compose_version") - androidTestImplementation("androidx.test.espresso:espresso-intents:3.5.1") - androidTestImplementation("androidx.test.ext:junit:1.1.5") - androidTestImplementation("androidx.test:core:1.5.0") - androidTestImplementation("androidx.test:rules:1.5.0") - androidTestImplementation("androidx.test:runner:1.5.2") - androidTestImplementation("com.android.support.test.espresso:espresso-core:3.0.2") - androidTestImplementation("org.mockito:mockito-core:5.3.1") - debugImplementation("androidx.compose.ui:ui-test-manifest:$compose_version") - - androidTestImplementation('com.adevinta.android:barista:4.3.0') { - exclude group: 'org.jetbrains.kotlin' // Only if you already use Kotlin in your project - } - - -} diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 000000000..a831abd3a --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,103 @@ +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + id("com.android.application") + id("kotlin-android") + alias(libs.plugins.compose.compiler) +} + +android { + compileSdk = 34 + + defaultConfig { + applicationId = "de.jensklingenberg.jetpackcomposeplayground" + minSdk = 21 + targetSdk = 34 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + getByName("release") { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = "1.8" + } + + namespace = "de.jensklingenberg.jetpackcomposeplayground" + +} + +tasks.withType().configureEach { + kotlinOptions { + freeCompilerArgs += listOf( + "-P", + "plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=${project.buildDir.absolutePath}/compose_compiler" + ) + freeCompilerArgs += listOf( + "-P", + "plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=${project.buildDir.absolutePath}/compose_compiler" + ) + } +} +val compose_version = "1.6.7" +dependencies { + implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) + implementation("androidx.activity:activity-compose:1.9.0") + implementation("androidx.appcompat:appcompat:1.7.0") + implementation("androidx.compose.animation:animation-core:$compose_version") + implementation("androidx.compose.animation:animation:$compose_version") + implementation("androidx.compose.foundation:foundation-layout:$compose_version") + implementation("androidx.compose.foundation:foundation:$compose_version") + implementation("androidx.compose.material:material-icons-core:$compose_version") + implementation("androidx.compose.material:material-icons-extended:$compose_version") + implementation("androidx.compose.material:material:$compose_version") + implementation("androidx.compose.material:material:$compose_version") + implementation("androidx.compose.runtime:runtime-livedata:$compose_version") + implementation("androidx.compose.runtime:runtime-rxjava2:$compose_version") + implementation("androidx.compose.ui:ui-geometry:$compose_version") + implementation("androidx.compose.ui:ui-graphics:$compose_version") + implementation("androidx.compose.ui:ui-tooling:$compose_version") + implementation("androidx.compose.ui:ui-tooling:$compose_version") + implementation("androidx.compose.ui:ui:$compose_version") + implementation("androidx.core:core-ktx:1.13.1") + implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.1") + implementation("com.google.android.material:material:1.12.0") + implementation("androidx.compose.ui:ui-viewbinding:$compose_version") + implementation("androidx.compose.ui:ui-text:$compose_version") + implementation("androidx.compose.ui:ui-util:$compose_version") + implementation("androidx.compose.ui:ui:$compose_version") + implementation("androidx.constraintlayout:constraintlayout-compose:1.0.1") + + testImplementation("junit:junit:4.13.2") + androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") + androidTestImplementation("androidx.test:runner:1.5.2") + androidTestImplementation("androidx.compose.ui:ui-test-junit4:$compose_version") + androidTestImplementation("androidx.compose.ui:ui-test:$compose_version") + androidTestImplementation("androidx.test.espresso:espresso-intents:3.5.1") + androidTestImplementation("androidx.test.ext:junit:1.1.5") + androidTestImplementation("androidx.test:core:1.5.0") + androidTestImplementation("androidx.test:rules:1.5.0") + androidTestImplementation("androidx.test:runner:1.5.2") + androidTestImplementation("com.android.support.test.espresso:espresso-core:3.0.2") + androidTestImplementation("org.mockito:mockito-core:5.3.1") + debugImplementation("androidx.compose.ui:ui-test-manifest:$compose_version") + + androidTestImplementation("com.adevinta.android:barista:4.3.0") { + exclude(group = "org.jetbrains.kotlin") + } +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index f1b424510..2fe953834 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradl. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/build.gradle b/build.gradle index 733d99ce7..145dab572 100644 --- a/build.gradle +++ b/build.gradle @@ -3,8 +3,8 @@ buildscript { ext { - compose_version = '1.6.3' - kotlin_version = "1.9.22" + compose_version = '1.6.7' + kotlin_version = "2.0.0" } repositories { google() diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 000000000..71c27a925 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,8 @@ +[versions] +kotlin = "2.0.0" +compose_version = "1.6.7" +[plugins] +org-jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } + + +compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }