From 228a67d824e8b382448f670559f4028ad1bb387a Mon Sep 17 00:00:00 2001 From: Henrik Klev Date: Mon, 21 Oct 2024 13:22:11 +0200 Subject: [PATCH] Refactored gradle files --- app/build.gradle.kts | 50 +++++++++---------- .../pax/ecr/app/ExampleInstrumentedTest.kt | 23 --------- build.gradle.kts | 6 +-- gradle/libs.versions.toml | 42 ++++++++++++++++ 4 files changed, 70 insertions(+), 51 deletions(-) delete mode 100644 app/src/androidTest/java/com/pax/ecr/app/ExampleInstrumentedTest.kt create mode 100644 gradle/libs.versions.toml diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 0667e91..a61372c 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,17 +1,19 @@ plugins { - id("com.android.application") - id("org.jetbrains.kotlin.android") - id("org.jetbrains.kotlin.plugin.compose") version "2.0.21" - kotlin("plugin.serialization") version "2.0.21" + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.compose) + alias(libs.plugins.serialization) } android { namespace = "com.pax.ecr.app" - compileSdk = 34 + compileSdk = 35 defaultConfig { applicationId = "com.pax.ecr.app" minSdk = 27 + //noinspection ExpiredTargetSdkVersion App will not be published to Google Play + targetSdk = 28 versionCode = 1 versionName = "1.0" @@ -51,27 +53,25 @@ android { } dependencies { + // Debug Dependencies + debugImplementation(libs.androidx.ui.test.manifest) + debugImplementation(libs.androidx.ui.tooling) - androidTestImplementation("androidx.compose.ui:ui-test-junit4") - androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1") - androidTestImplementation("androidx.test.ext:junit:1.2.1") - androidTestImplementation("com.willowtreeapps.assertk:assertk-jvm:0.28.1") - androidTestImplementation(platform("androidx.compose:compose-bom:2024.09.03")) + // Main Implementation Dependencies + implementation(libs.androidx.activity.compose) + implementation(libs.androidx.material3) + implementation(libs.androidx.ui) + implementation(libs.androidx.ui.graphics) + implementation(libs.androidx.ui.tooling.preview) + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.material.icons) + implementation(platform(libs.androidx.compose.bom.main)) - debugImplementation("androidx.compose.ui:ui-test-manifest") - debugImplementation("androidx.compose.ui:ui-tooling") + // Kotlin Serialization + implementation(libs.kotlinx.serialization.json) - implementation("androidx.activity:activity-compose:1.9.2") - implementation("androidx.compose.material3:material3") - implementation("androidx.compose.ui:ui") - implementation("androidx.compose.ui:ui-graphics") - implementation("androidx.compose.ui:ui-tooling-preview") - implementation("androidx.core:core-ktx:1.13.1") - implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.6") - implementation(platform("androidx.compose:compose-bom:2024.09.03")) - - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") - - testImplementation("com.willowtreeapps.assertk:assertk-jvm:0.28.1") - testImplementation("junit:junit:4.13.2") + // Test Dependencies + testImplementation(libs.assertk.jvm) + testImplementation(libs.junit) } diff --git a/app/src/androidTest/java/com/pax/ecr/app/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/pax/ecr/app/ExampleInstrumentedTest.kt deleted file mode 100644 index b9cad27..0000000 --- a/app/src/androidTest/java/com/pax/ecr/app/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.pax.ecr.app - -import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.platform.app.InstrumentationRegistry -import assertk.assertThat -import assertk.assertions.isEqualTo -import org.junit.Test -import org.junit.runner.RunWith - -/** - * Instrumented test, which will execute on an Android device. - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -@RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertThat(appContext.packageName).isEqualTo("com.pax.ecr.app") - } -} diff --git a/build.gradle.kts b/build.gradle.kts index 7fe9f4d..f5fb1a4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,8 +1,8 @@ plugins { - id("com.android.application") version "8.7.1" apply false - id("org.jetbrains.kotlin.android") version "2.0.21" apply false - id("org.jlleitschuh.gradle.ktlint") version "12.1.1" + alias(libs.plugins.android.application) apply false + alias(libs.plugins.kotlin.android) apply false + alias(libs.plugins.ktlint) } subprojects { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..e2083f5 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,42 @@ +[versions] +junit = "4.13.2" +assertk = "0.28.1" +activity_compose = "1.9.3" +material3 = "latest.release" +compose_bom = "2024.10.00" +core_ktx = "1.13.1" +lifecycle_ktx = "2.8.6" +serialization_json = "1.7.3" +agp = "8.7.1" +kotlin = "2.0.21" +ktlint = "12.1.1" +material_icons = "1.7.4" + +[libraries] + +# Debug Dependencies +androidx_ui_test_manifest = { module = "androidx.compose.ui:ui-test-manifest" } +androidx_ui_tooling = { module = "androidx.compose.ui:ui-tooling" } + +# Main Implementation Dependencies +androidx_activity_compose = { module = "androidx.activity:activity-compose", version.ref = "activity_compose" } +androidx_material3 = { module = "androidx.compose.material3:material3", version.ref = "material3" } +androidx_ui = { module = "androidx.compose.ui:ui" } +androidx_ui_graphics = { module = "androidx.compose.ui:ui-graphics" } +androidx_ui_tooling_preview = { module = "androidx.compose.ui:ui-tooling-preview" } +androidx_core_ktx = { module = "androidx.core:core-ktx", version.ref = "core_ktx" } +androidx_lifecycle_runtime_ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycle_ktx" } +androidx_compose_bom_main = { module = "androidx.compose:compose-bom", version.ref = "compose_bom" } +kotlinx_serialization_json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization_json" } +androidx_material_icons = { group = "androidx.compose.material", name = "material-icons-extended", version.ref = "material_icons" } + +# Test Dependencies +assertk_jvm = { module = "com.willowtreeapps.assertk:assertk-jvm", version.ref = "assertk" } +junit = { module = "junit:junit", version.ref = "junit" } + +[plugins] +android_application = { id = "com.android.application", version.ref = "agp" } +kotlin_android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" } +compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } +serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } \ No newline at end of file