From bf7dcec493505995b17f0565e8dc529ff9ede120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf=20Montwe=CC=81?= Date: Mon, 13 Feb 2023 15:02:23 +0100 Subject: [PATCH 1/4] Rename settings.gradle to settings.gradle.kts --- settings.gradle => settings.gradle.kts | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename settings.gradle => settings.gradle.kts (100%) diff --git a/settings.gradle b/settings.gradle.kts similarity index 100% rename from settings.gradle rename to settings.gradle.kts From fdfd7c220392414f937d2ac8d88079bb70b052f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf=20Montwe=CC=81?= Date: Mon, 13 Feb 2023 15:06:32 +0100 Subject: [PATCH 2/4] Change settings.gradle.kts to Kotlin --- settings.gradle.kts | 66 ++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index f8ae7c284..e7f79efef 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -11,39 +11,39 @@ dependencyResolutionManagement { repositories { google() mavenCentral() - maven { url 'https://jitpack.io' } + maven(url = "https://jitpack.io") } } -include ':app:k9mail' -include ':app:ui:base' -include ':app:ui:setup' -include ':app:ui:legacy' -include ':app:ui:message-list-widget' -include ':app:core' -include ':app:storage' -include ':app:crypto-openpgp' -include ':app:testing' -include ':app:autodiscovery:api' -include ':app:autodiscovery:providersxml' -include ':app:autodiscovery:srvrecords' -include ':app:autodiscovery:thunderbird' -include ':app:html-cleaner' -include ':ui-utils:LinearLayoutManager' -include ':ui-utils:ItemTouchHelper' -include ':ui-utils:ToolbarBottomSheet' -include ':mail:common' -include ':mail:testing' -include ':mail:protocols:imap' -include ':mail:protocols:pop3' -include ':mail:protocols:webdav' -include ':mail:protocols:smtp' -include ':backend:api' -include ':backend:testing' -include ':backend:imap' -include ':backend:pop3' -include ':backend:webdav' -include ':backend:jmap' -include ':backend:demo' -include ':plugins:openpgp-api-lib:openpgp-api' -include ':cli:html-cleaner-cli' +include(":app:k9mail") +include(":app:ui:base") +include(":app:ui:setup") +include(":app:ui:legacy") +include(":app:ui:message-list-widget") +include(":app:core") +include(":app:storage") +include(":app:crypto-openpgp") +include(":app:testing") +include(":app:autodiscovery:api") +include(":app:autodiscovery:providersxml") +include(":app:autodiscovery:srvrecords") +include(":app:autodiscovery:thunderbird") +include(":app:html-cleaner") +include(":ui-utils:LinearLayoutManager") +include(":ui-utils:ItemTouchHelper") +include(":ui-utils:ToolbarBottomSheet") +include(":mail:common") +include(":mail:testing") +include(":mail:protocols:imap") +include(":mail:protocols:pop3") +include(":mail:protocols:webdav") +include(":mail:protocols:smtp") +include(":backend:api") +include(":backend:testing") +include(":backend:imap") +include(":backend:pop3") +include(":backend:webdav") +include(":backend:jmap") +include(":backend:demo") +include(":plugins:openpgp-api-lib:openpgp-api") +include(":cli:html-cleaner-cli") From 73f9976838629584127c8645f9407af4c204cfc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf=20Montwe=CC=81?= Date: Mon, 13 Feb 2023 15:07:30 +0100 Subject: [PATCH 3/4] Rename build.gradle to build.gradle.kts --- build.gradle => build.gradle.kts | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename build.gradle => build.gradle.kts (100%) diff --git a/build.gradle b/build.gradle.kts similarity index 100% rename from build.gradle rename to build.gradle.kts From 71ae33719f05789f6512ac3432438a7d994c7e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf=20Montwe=CC=81?= Date: Mon, 13 Feb 2023 15:59:46 +0100 Subject: [PATCH 4/4] Change build.gradle.kts to Kotlin --- build.gradle.kts | 119 +++++++++++++++++++++++++++-------------------- 1 file changed, 69 insertions(+), 50 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a1d24d277..769e587f9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,8 @@ +import com.android.build.gradle.BaseExtension import com.android.build.gradle.BasePlugin import org.jetbrains.kotlin.gradle.dsl.JvmTarget -import org.jetbrains.kotlin.gradle.dsl.KotlinCompile +@Suppress("DSL_SCOPE_VIOLATION") plugins { alias(libs.plugins.android.application) apply false alias(libs.plugins.android.library) apply false @@ -13,85 +14,102 @@ plugins { alias(libs.plugins.spotless) } -project.ext { - testCoverage = project.hasProperty('testCoverage') -} +val propertyTestCoverage: String? by extra -def javaVersion = JavaVersion.VERSION_11 -def jvmTargetVersion = JvmTarget.JVM_11 +val javaVersion = JavaVersion.VERSION_11 +val jvmTargetVersion = JvmTarget.JVM_11 allprojects { + extra.apply { + set("testCoverage", propertyTestCoverage != null) + } + configurations.configureEach { resolutionStrategy.dependencySubstitution { - substitute module("androidx.core:core") using module("androidx.core:core:${libs.versions.androidxCore.get()}") - substitute module("androidx.activity:activity") using module("androidx.activity:activity:${libs.versions.androidxActivity.get()}") - substitute module("androidx.activity:activity-ktx") using module("androidx.activity:activity-ktx:${libs.versions.androidxActivity.get()}") - substitute module("androidx.fragment:fragment") using module("androidx.fragment:fragment:${libs.versions.androidxFragment.get()}") - substitute module("androidx.fragment:fragment-ktx") using module("androidx.fragment:fragment-ktx:${libs.versions.androidxFragment.get()}") - substitute module("androidx.appcompat:appcompat") using module("androidx.appcompat:appcompat:${libs.versions.androidxAppCompat.get()}") - substitute module("androidx.preference:preference") using module("androidx.preference:preference:${libs.versions.androidxPreference.get()}") - substitute module("androidx.recyclerview:recyclerview") using module("androidx.recyclerview:recyclerview:${libs.versions.androidxRecyclerView.get()}") - substitute module("androidx.constraintlayout:constraintlayout") using module("androidx.constraintlayout:constraintlayout:${libs.versions.androidxConstraintLayout.get()}") - substitute module("androidx.drawerlayout:drawerlayout") using module("androidx.drawerlayout:drawerlayout:${libs.versions.androidxDrawerLayout.get()}") - substitute module("androidx.lifecycle:lifecycle-livedata") using module("androidx.lifecycle:lifecycle-livedata:${libs.versions.androidxLifecycle.get()}") - substitute module("androidx.transition:transition") using module("androidx.transition:transition:${libs.versions.androidxTransition.get()}") - substitute module("org.jetbrains:annotations") using module("org.jetbrains:annotations:${libs.versions.jetbrainsAnnotations.get()}") - substitute module("org.jetbrains.kotlin:kotlin-stdlib") using module("org.jetbrains.kotlin:kotlin-stdlib:${libs.versions.kotlin.get()}") - substitute module("org.jetbrains.kotlin:kotlin-stdlib-jdk7") using module("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${libs.versions.kotlin.get()}") - substitute module("org.jetbrains.kotlin:kotlin-stdlib-jdk8") using module("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${libs.versions.kotlin.get()}") - substitute module("org.jetbrains.kotlinx:kotlinx-coroutines-android") using module("org.jetbrains.kotlinx:kotlinx-coroutines-android:${libs.versions.kotlinCoroutines.get()}") + substitute(module("androidx.core:core")) + .using(module("androidx.core:core:${libs.versions.androidxCore.get()}")) + substitute(module("androidx.activity:activity")) + .using(module("androidx.activity:activity:${libs.versions.androidxActivity.get()}")) + substitute(module("androidx.activity:activity-ktx")) + .using(module("androidx.activity:activity-ktx:${libs.versions.androidxActivity.get()}")) + substitute(module("androidx.fragment:fragment")) + .using(module("androidx.fragment:fragment:${libs.versions.androidxFragment.get()}")) + substitute(module("androidx.fragment:fragment-ktx")) + .using(module("androidx.fragment:fragment-ktx:${libs.versions.androidxFragment.get()}")) + substitute(module("androidx.appcompat:appcompat")) + .using(module("androidx.appcompat:appcompat:${libs.versions.androidxAppCompat.get()}")) + substitute(module("androidx.preference:preference")) + .using(module("androidx.preference:preference:${libs.versions.androidxPreference.get()}")) + substitute(module("androidx.recyclerview:recyclerview")) + .using(module("androidx.recyclerview:recyclerview:${libs.versions.androidxRecyclerView.get()}")) + substitute(module("androidx.constraintlayout:constraintlayout")) + .using(module("androidx.constraintlayout:constraintlayout:${libs.versions.androidxConstraintLayout.get()}")) + substitute(module("androidx.drawerlayout:drawerlayout")) + .using(module("androidx.drawerlayout:drawerlayout:${libs.versions.androidxDrawerLayout.get()}")) + substitute(module("androidx.lifecycle:lifecycle-livedata")) + .using(module("androidx.lifecycle:lifecycle-livedata:${libs.versions.androidxLifecycle.get()}")) + substitute(module("androidx.transition:transition")) + .using(module("androidx.transition:transition:${libs.versions.androidxTransition.get()}")) + substitute(module("org.jetbrains:annotations")) + .using(module("org.jetbrains:annotations:${libs.versions.jetbrainsAnnotations.get()}")) + substitute(module("org.jetbrains.kotlin:kotlin-stdlib")) + .using(module("org.jetbrains.kotlin:kotlin-stdlib:${libs.versions.kotlin.get()}")) + substitute(module("org.jetbrains.kotlin:kotlin-stdlib-jdk7")) + .using(module("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${libs.versions.kotlin.get()}")) + substitute(module("org.jetbrains.kotlin:kotlin-stdlib-jdk8")) + .using(module("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${libs.versions.kotlin.get()}")) + substitute(module("org.jetbrains.kotlinx:kotlinx-coroutines-android")) + .using(module("org.jetbrains.kotlinx:kotlinx-coroutines-android:${libs.versions.kotlinCoroutines.get()}")) } } - plugins.withType(BasePlugin).configureEach { - project.android { - compileSdk 33 + plugins.withType { + configure { + compileSdkVersion(33) defaultConfig { - minSdk 21 - targetSdk 31 + minSdk = 21 + targetSdk = 31 vectorDrawables.useSupportLibrary = true - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } compileOptions { - sourceCompatibility javaVersion - targetCompatibility javaVersion + sourceCompatibility = javaVersion + targetCompatibility = javaVersion } lintOptions { - abortOnError false - lintConfig file("$rootProject.projectDir/config/lint/lint.xml") + isAbortOnError = false + lintConfig = file("${rootProject.projectDir}/config/lint/lint.xml") } testOptions { unitTests { - includeAndroidResources = true + isIncludeAndroidResources = true } } } } - plugins.withType(JavaPlugin).configureEach { - project.java { + plugins.withType { + configure { sourceCompatibility = javaVersion targetCompatibility = javaVersion } } - tasks.withType(Test).configureEach { - testLogging { - exceptionFormat "full" - showCauses true - showExceptions true - showStackTraces true - } + tasks.withType { + kotlinOptions.jvmTarget = jvmTargetVersion.target } - tasks.withType(KotlinCompile).configureEach { - compilerOptions { - jvmTarget = jvmTargetVersion + tasks.withType { + testLogging { + exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL + showCauses = true + showExceptions = true + showStackTraces = true } } } @@ -118,9 +136,10 @@ spotless { } } -tasks.register('testsOnCi') { - dependsOn getSubprojects() - .collect { project -> project.tasks.withType(Test) } +tasks.register("testsOnCi") { + dependsOn( + subprojects.map { project -> project.tasks.withType(Test::class.java) } .flatten() - .findAll { task -> task.name in ['testDebugUnitTest', 'test'] } + .filterNot { task -> task.name in arrayOf("testDebugUnitTest", "test") } + ) }