From ef0252aa9415cec7a22bcfbe6e0abbbc3b0cd0d6 Mon Sep 17 00:00:00 2001 From: ganfra Date: Thu, 8 Dec 2022 18:52:55 +0100 Subject: [PATCH] Continue cleaning gradle files --- app/build.gradle.kts | 15 ++-------- build.gradle | 12 -------- build.gradle.kts | 11 +++++++ features/login/build.gradle.kts | 13 ++++----- features/messages/build.gradle.kts | 16 ++++------ features/onboarding/build.gradle.kts | 13 ++++----- features/roomlist/build.gradle.kts | 13 ++++----- gradle/libs.versions.toml | 16 ++++++++-- libraries/core/build.gradle.kts | 2 +- libraries/designsystem/build.gradle.kts | 10 +++---- libraries/matrix/build.gradle.kts | 2 +- libraries/textcomposer/build.gradle.kts | 8 ++--- .../main/java/extension/CommonExtension.kt | 14 +-------- .../DependencyHandleScope.kt} | 29 +++++++------------ .../src/main/java/extension/VersionCatalog.kt | 9 ++++++ ...ent.android-compose-application.gradle.kts | 17 +++++++++++ ...element.android-compose-library.gradle.kts | 18 ++++++++++++ .../io.element.android-library.gradle.kts | 2 -- 18 files changed, 112 insertions(+), 108 deletions(-) delete mode 100644 build.gradle create mode 100644 build.gradle.kts rename plugins/src/main/java/{io.element.android-compose.gradle.kts => extension/DependencyHandleScope.kt} (58%) create mode 100644 plugins/src/main/java/extension/VersionCatalog.kt create mode 100644 plugins/src/main/java/io.element.android-compose-application.gradle.kts create mode 100644 plugins/src/main/java/io.element.android-compose-library.gradle.kts diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 9f2ed32189..42fa413a3a 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,7 +1,7 @@ plugins { - id("com.android.application") + id("io.element.android-compose-application") id("org.jetbrains.kotlin.android") - id("com.google.devtools.ksp") version "1.7.20-1.0.7" + alias(libs.plugins.ksp) version "1.7.20-1.0.7" id("com.google.firebase.appdistribution") version "3.0.2" } @@ -125,23 +125,14 @@ dependencies { implementation("io.github.raamcosta.compose-destinations:animations-core:1.7.23-beta") ksp("io.github.raamcosta.compose-destinations:ksp:1.7.23-beta") - val composeBom = platform("androidx.compose:compose-bom:2022.11.00") - implementation(composeBom) - androidTestImplementation(composeBom) - implementation("androidx.core:core-ktx:1.9.0") - implementation("androidx.compose.ui:ui") - implementation("androidx.compose.material3:material3") - implementation("androidx.compose.ui:ui-tooling-preview") implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.5.1") implementation("androidx.activity:activity-compose:1.6.1") implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.5.1") implementation("io.coil-kt:coil:2.2.1") implementation("com.jakewharton.timber:timber:5.0.1") - debugImplementation("androidx.compose.ui:ui-tooling") - debugImplementation("androidx.compose.ui:ui-test-manifest") implementation("com.airbnb.android:mavericks-compose:3.0.1") implementation("com.airbnb.android:showkase:1.0.0-beta14") - ksp("com.airbnb.android:showkase-processor:1.0.0-beta14") + ksp(libs.showkase.processor) } \ No newline at end of file diff --git a/build.gradle b/build.gradle deleted file mode 100644 index a76107c6f3..0000000000 --- a/build.gradle +++ /dev/null @@ -1,12 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -// TODO Convert to .kts -plugins { - id 'com.android.application' version '7.3.0' apply false - id 'com.android.library' version '7.3.0' apply false - id 'org.jetbrains.kotlin.android' version '1.7.20' apply false - id 'com.google.devtools.ksp' version '1.7.20-1.0.7' apply false -} - -task clean(type: Delete) { - delete rootProject.buildDir -} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000000..1c9d692846 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,11 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +plugins { + alias(libs.plugins.android.application) apply false + alias(libs.plugins.android.library) apply false + alias(libs.plugins.kotlin.android) apply false + alias(libs.plugins.ksp) apply false +} + +tasks.register("clean").configure { + delete(rootProject.buildDir) + } \ No newline at end of file diff --git a/features/login/build.gradle.kts b/features/login/build.gradle.kts index c59b274c78..e3704c9495 100644 --- a/features/login/build.gradle.kts +++ b/features/login/build.gradle.kts @@ -1,7 +1,6 @@ plugins { - id("io.element.android-compose") - // TODO Move to common config - id("com.google.devtools.ksp") version "1.7.20-1.0.7" + id("io.element.android-compose-library") + alias(libs.plugins.ksp) } android { @@ -14,11 +13,9 @@ dependencies { implementation(project(":libraries:designsystem")) implementation(project(":libraries:elementresources")) implementation(libs.mavericks.compose) + ksp(libs.showkase.processor) implementation(libs.timber) - testImplementation("junit:junit:4.13.2") - androidTestImplementation("androidx.test.ext:junit:1.1.3") - androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") + testImplementation(libs.test.junit) + androidTestImplementation(libs.test.junitext) - // TODO Move to common config - ksp("com.airbnb.android:showkase-processor:1.0.0-beta14") } \ No newline at end of file diff --git a/features/messages/build.gradle.kts b/features/messages/build.gradle.kts index 43c850e91c..ff5a98fb4b 100644 --- a/features/messages/build.gradle.kts +++ b/features/messages/build.gradle.kts @@ -1,7 +1,6 @@ plugins { - id("io.element.android-compose") - // TODO Move to common config - id("com.google.devtools.ksp") version "1.7.20-1.0.7" + id("io.element.android-compose-library") + alias(libs.plugins.ksp) } android { @@ -19,11 +18,8 @@ dependencies { implementation(libs.datetime) implementation(libs.accompanist.flowlayout) implementation(libs.androidx.recyclerview) - implementation("org.jsoup:jsoup:1.15.3") - testImplementation("junit:junit:4.13.2") - androidTestImplementation("androidx.test.ext:junit:1.1.3") - androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") - - // TODO Move to common config - ksp("com.airbnb.android:showkase-processor:1.0.0-beta14") + implementation(libs.jsoup) + testImplementation(libs.test.junit) + androidTestImplementation(libs.test.junitext) + ksp(libs.showkase.processor) } diff --git a/features/onboarding/build.gradle.kts b/features/onboarding/build.gradle.kts index 7945f93d57..b878aed3c7 100644 --- a/features/onboarding/build.gradle.kts +++ b/features/onboarding/build.gradle.kts @@ -1,7 +1,6 @@ plugins { - id("io.element.android-compose") - // TODO Move to common config - id("com.google.devtools.ksp") version "1.7.20-1.0.7" + id("io.element.android-compose-library") + alias(libs.plugins.ksp) } android { @@ -16,9 +15,7 @@ dependencies { implementation(libs.timber) implementation(libs.accompanist.pager) implementation(libs.accompanist.pagerindicator) - testImplementation("junit:junit:4.13.2") - androidTestImplementation("androidx.test.ext:junit:1.1.3") - androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") - // TODO Move to common config - ksp("com.airbnb.android:showkase-processor:1.0.0-beta14") + testImplementation(libs.test.junit) + androidTestImplementation(libs.test.junitext) + ksp(libs.showkase.processor) } \ No newline at end of file diff --git a/features/roomlist/build.gradle.kts b/features/roomlist/build.gradle.kts index 235cdba1e5..749fbeb6d8 100644 --- a/features/roomlist/build.gradle.kts +++ b/features/roomlist/build.gradle.kts @@ -1,7 +1,6 @@ plugins { - id("io.element.android-compose") - // TODO Move to common config - id("com.google.devtools.ksp") version "1.7.20-1.0.7" + id("io.element.android-compose-library") + alias(libs.plugins.ksp) } android { @@ -16,9 +15,7 @@ dependencies { implementation(libs.timber) implementation(libs.datetime) implementation(libs.accompanist.placeholder) - testImplementation("junit:junit:4.13.2") - androidTestImplementation("androidx.test.ext:junit:1.1.3") - androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") - // TODO Move to common config - ksp("com.airbnb.android:showkase-processor:1.0.0-beta14") + testImplementation(libs.test.junit) + androidTestImplementation(libs.test.junitext) + ksp(libs.showkase.processor) } \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a01d057e24..093616fcd1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -39,7 +39,10 @@ timber = "5.0.1" coil = "2.2.1" datetime = "0.4.0" wysiwyg = "0.7.0.1" -serialization-json = "1.4.1" +serialization_json = "1.4.1" +showkase = "1.0.0-beta14" +compose_destinations = "1.7.23-beta" +jsoup = "1.15.3" [libraries] # Project @@ -88,7 +91,11 @@ mavericks_compose = { module = "com.airbnb.android:mavericks-compose", version.r timber = { module = "com.jakewharton.timber:timber", version.ref = "timber" } coil_compose = { module = "io.coil-kt:coil-compose", version.ref = "coil" } datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "datetime" } -serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization-json" } +serialization_json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization_json" } +compose_destinations = { module = "io.github.raamcosta.compose-destinations:animations-core", version.ref = "compose_destinations" } +showkase = { module = "com.airbnb.android:showkase", version.ref = "showkase" } +showkase_processor = { module = "com.airbnb.android:showkase-processor", version.ref = "showkase" } +jsoup = { module = "org.jsoup:jsoup", version.ref = "jsoup" } # Composer wysiwyg = { module = "io.element.android:wysiwyg", version.ref = "wysiwyg" } @@ -96,4 +103,7 @@ wysiwyg = { module = "io.element.android:wysiwyg", version.ref = "wysiwyg" } [bundles] [plugins] -ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } +android_application = { id = "com.android.application", version.ref = "android_gradle_plugin" } +android_library = { id = "com.android.library", version.ref = "android_gradle_plugin" } +kotlin_android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } \ No newline at end of file diff --git a/libraries/core/build.gradle.kts b/libraries/core/build.gradle.kts index 94f5d3ea69..6706fcdfa8 100644 --- a/libraries/core/build.gradle.kts +++ b/libraries/core/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("io.element.android-compose") + id("io.element.android-compose-library") } android { diff --git a/libraries/designsystem/build.gradle.kts b/libraries/designsystem/build.gradle.kts index f56a38445d..c132b472c3 100644 --- a/libraries/designsystem/build.gradle.kts +++ b/libraries/designsystem/build.gradle.kts @@ -1,7 +1,6 @@ plugins { - id("io.element.android-compose") - // TODO Move to common config - id("com.google.devtools.ksp") version "1.7.20-1.0.7" + id("io.element.android-compose-library") + alias(libs.plugins.ksp) } android { @@ -9,9 +8,8 @@ android { dependencies { // Should not be there, but this is a POC - implementation("io.coil-kt:coil-compose:2.2.1") + implementation(libs.coil.compose) implementation(libs.accompanist.systemui) - // TODO Move to common config - ksp("com.airbnb.android:showkase-processor:1.0.0-beta14") + ksp(libs.showkase.processor) } } \ No newline at end of file diff --git a/libraries/matrix/build.gradle.kts b/libraries/matrix/build.gradle.kts index e315786659..1af5b3898f 100644 --- a/libraries/matrix/build.gradle.kts +++ b/libraries/matrix/build.gradle.kts @@ -11,7 +11,7 @@ dependencies { api(project(":libraries:rustSdk")) implementation(project(":libraries:core")) implementation(libs.timber) - implementation("net.java.dev.jna:jna:5.10.0@aar") + implementation("net.java.dev.jna:jna:5.12.1@aar") implementation(libs.coil.compose) implementation(libs.androidx.datastore.preferences) implementation(libs.serialization.json) diff --git a/libraries/textcomposer/build.gradle.kts b/libraries/textcomposer/build.gradle.kts index c8120437ec..512d52a573 100644 --- a/libraries/textcomposer/build.gradle.kts +++ b/libraries/textcomposer/build.gradle.kts @@ -1,7 +1,6 @@ plugins { - id("io.element.android-compose") - // TODO Move to common config - id("com.google.devtools.ksp") version "1.7.20-1.0.7" + id("io.element.android-compose-library") + alias(libs.plugins.ksp) } android { @@ -17,6 +16,5 @@ dependencies { implementation(libs.wysiwyg) implementation(libs.androidx.constraintlayout) implementation("com.google.android.material:material:1.7.0") - // TODO Move to common config - ksp("com.airbnb.android:showkase-processor:1.0.0-beta14") + ksp(libs.showkase.processor) } diff --git a/plugins/src/main/java/extension/CommonExtension.kt b/plugins/src/main/java/extension/CommonExtension.kt index 05cc4880f3..f819b2d58e 100644 --- a/plugins/src/main/java/extension/CommonExtension.kt +++ b/plugins/src/main/java/extension/CommonExtension.kt @@ -2,9 +2,7 @@ package extension import Versions import com.android.build.api.dsl.CommonExtension -import com.android.build.api.dsl.LibraryExtension -import composeVersion -import org.gradle.api.artifacts.VersionCatalog + fun CommonExtension<*, *, *, *>.androidConfig() { defaultConfig { @@ -39,13 +37,3 @@ fun CommonExtension<*, *, *, *>.composeConfig() { } } -fun LibraryExtension.proguardConfig() { - buildTypes { - getByName("release") { - isMinifyEnabled = true - proguardFiles("proguard-android.txt", "proguard-rules.pro") - consumerProguardFiles("proguard-rules.pro") - } - } -} - diff --git a/plugins/src/main/java/io.element.android-compose.gradle.kts b/plugins/src/main/java/extension/DependencyHandleScope.kt similarity index 58% rename from plugins/src/main/java/io.element.android-compose.gradle.kts rename to plugins/src/main/java/extension/DependencyHandleScope.kt index 2efafcfb09..09fdd1bb23 100644 --- a/plugins/src/main/java/io.element.android-compose.gradle.kts +++ b/plugins/src/main/java/extension/DependencyHandleScope.kt @@ -1,23 +1,15 @@ -import extension.androidConfig -import extension.composeConfig -import extension.proguardConfig +package extension -plugins { - id("com.android.library") - id("kotlin-android") -// alias(libs.plugins.ksp) -// id("com.google.devtools.ksp") // version "1.7.20-1.0.7" -} +import gradle.kotlin.dsl.accessors._4b7ad2363fc1fce7c774e054dc9a9300.androidTestImplementation +import gradle.kotlin.dsl.accessors._4b7ad2363fc1fce7c774e054dc9a9300.debugImplementation +import gradle.kotlin.dsl.accessors._4b7ad2363fc1fce7c774e054dc9a9300.implementation +import org.gradle.kotlin.dsl.DependencyHandlerScope -android { - androidConfig() - proguardConfig() - composeConfig() -} - -dependencies { - implementation(platform("androidx.compose:compose-bom:2022.11.00")) +fun DependencyHandlerScope.composeDependencies(){ + val composeBom = platform("androidx.compose:compose-bom:2022.11.00") + implementation(composeBom) + androidTestImplementation(composeBom) implementation("androidx.compose.ui:ui") implementation("androidx.compose.material:material") implementation("androidx.compose.material3:material3") @@ -29,7 +21,6 @@ dependencies { implementation("com.airbnb.android:mavericks-compose:3.0.1") debugImplementation("androidx.compose.ui:ui-tooling") debugImplementation("androidx.compose.ui:ui-test-manifest") - implementation("com.airbnb.android:showkase:1.0.0-beta14") - // ksp("com.airbnb.android:showkase-processor:1.0.0-beta14") } + diff --git a/plugins/src/main/java/extension/VersionCatalog.kt b/plugins/src/main/java/extension/VersionCatalog.kt new file mode 100644 index 0000000000..950ba1db3a --- /dev/null +++ b/plugins/src/main/java/extension/VersionCatalog.kt @@ -0,0 +1,9 @@ +package extension + +import org.gradle.api.artifacts.VersionCatalog + +private fun VersionCatalog.getLibrary(library: String) = findLibrary(library).get() + +private fun VersionCatalog.getBundle(bundle: String) = findBundle(bundle).get() + +private fun VersionCatalog.getPlugin(plugin: String) = findPlugin(plugin).get() \ No newline at end of file diff --git a/plugins/src/main/java/io.element.android-compose-application.gradle.kts b/plugins/src/main/java/io.element.android-compose-application.gradle.kts new file mode 100644 index 0000000000..8814bb7682 --- /dev/null +++ b/plugins/src/main/java/io.element.android-compose-application.gradle.kts @@ -0,0 +1,17 @@ +import extension.androidConfig +import extension.composeConfig +import extension.composeDependencies + +plugins { + id("com.android.application") + id("kotlin-android") +} + +android { + androidConfig() + composeConfig() +} + +dependencies { + composeDependencies() +} diff --git a/plugins/src/main/java/io.element.android-compose-library.gradle.kts b/plugins/src/main/java/io.element.android-compose-library.gradle.kts new file mode 100644 index 0000000000..736b47140a --- /dev/null +++ b/plugins/src/main/java/io.element.android-compose-library.gradle.kts @@ -0,0 +1,18 @@ +import extension.androidConfig +import extension.composeConfig +import extension.composeDependencies + +plugins { + id("com.android.library") + id("kotlin-android") +} + + +android { + androidConfig() + composeConfig() +} + +dependencies { + composeDependencies() +} diff --git a/plugins/src/main/java/io.element.android-library.gradle.kts b/plugins/src/main/java/io.element.android-library.gradle.kts index c80c9ae399..4283de3fa2 100644 --- a/plugins/src/main/java/io.element.android-library.gradle.kts +++ b/plugins/src/main/java/io.element.android-library.gradle.kts @@ -1,5 +1,4 @@ import extension.androidConfig -import extension.proguardConfig plugins { id("com.android.library") @@ -8,5 +7,4 @@ plugins { android { androidConfig() - proguardConfig() }