From 0339444dd30d956817d9f02023d87abec7b28be6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf=20Montwe=CC=81?= Date: Tue, 18 Apr 2023 13:27:09 +0200 Subject: [PATCH] Bump Android Gradle Plugin to 8.0.0 and move Kotlin compatibility to build-plugins --- .java-version | 1 + app/k9mail/proguard-rules.pro | 5 +++++ build-plugin/src/main/kotlin/AndroidExtension.kt | 6 +++--- build-plugin/src/main/kotlin/KotlinExtension.kt | 11 +++++++++++ .../src/main/kotlin/ThunderbirdPlugins.kt | 5 ++++- .../src/main/kotlin/ThunderbirdProjectConfig.kt | 2 +- .../kotlin/thunderbird.app.android.gradle.kts | 2 +- .../main/kotlin/thunderbird.app.jvm.gradle.kts | 16 ++++++++++++++++ .../thunderbird.library.android.gradle.kts | 2 +- .../kotlin/thunderbird.library.jvm.gradle.kts | 6 ++++-- .../kotlin/thunderbird.quality.detekt.gradle.kts | 2 +- build.gradle.kts | 9 --------- cli/html-cleaner-cli/build.gradle.kts | 8 +------- gradle/libs.versions.toml | 2 +- 14 files changed, 50 insertions(+), 27 deletions(-) create mode 100644 .java-version create mode 100644 build-plugin/src/main/kotlin/KotlinExtension.kt create mode 100644 build-plugin/src/main/kotlin/thunderbird.app.jvm.gradle.kts diff --git a/.java-version b/.java-version new file mode 100644 index 000000000..03b6389f3 --- /dev/null +++ b/.java-version @@ -0,0 +1 @@ +17.0 diff --git a/app/k9mail/proguard-rules.pro b/app/k9mail/proguard-rules.pro index d18ccdefc..5cfa9613b 100644 --- a/app/k9mail/proguard-rules.pro +++ b/app/k9mail/proguard-rules.pro @@ -53,3 +53,8 @@ # OkHttp platform used only on JVM and when Conscrypt dependency is available. -dontwarn okhttp3.internal.platform.ConscryptPlatform + +-dontwarn kotlinx.serialization.KSerializer +-dontwarn kotlinx.serialization.Serializable +-dontwarn org.apache.http.client.methods.CloseableHttpResponse +-dontwarn org.slf4j.impl.StaticLoggerBinder diff --git a/build-plugin/src/main/kotlin/AndroidExtension.kt b/build-plugin/src/main/kotlin/AndroidExtension.kt index 056dc0adc..5db5fdcb3 100644 --- a/build-plugin/src/main/kotlin/AndroidExtension.kt +++ b/build-plugin/src/main/kotlin/AndroidExtension.kt @@ -14,8 +14,8 @@ internal fun CommonExtension<*, *, *, *>.configureSharedConfig() { } compileOptions { - sourceCompatibility = ThunderbirdProjectConfig.javaVersion - targetCompatibility = ThunderbirdProjectConfig.javaVersion + sourceCompatibility = ThunderbirdProjectConfig.javaCompatibilityVersion + targetCompatibility = ThunderbirdProjectConfig.javaCompatibilityVersion } lint { @@ -45,7 +45,7 @@ internal fun CommonExtension<*, *, *, *>.configureSharedComposeConfig( abortOnError = true } - packagingOptions { + packaging { resources { excludes += "/META-INF/{AL2.0,LGPL2.1}" } diff --git a/build-plugin/src/main/kotlin/KotlinExtension.kt b/build-plugin/src/main/kotlin/KotlinExtension.kt new file mode 100644 index 000000000..816ba7ed5 --- /dev/null +++ b/build-plugin/src/main/kotlin/KotlinExtension.kt @@ -0,0 +1,11 @@ +import org.gradle.api.Project +import org.gradle.kotlin.dsl.withType +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +fun Project.configureKotlinJavaCompatibility() { + tasks.withType { + kotlinOptions { + jvmTarget = ThunderbirdProjectConfig.javaCompatibilityVersion.toString() + } + } +} diff --git a/build-plugin/src/main/kotlin/ThunderbirdPlugins.kt b/build-plugin/src/main/kotlin/ThunderbirdPlugins.kt index 3a4e97e93..b5d195b32 100644 --- a/build-plugin/src/main/kotlin/ThunderbirdPlugins.kt +++ b/build-plugin/src/main/kotlin/ThunderbirdPlugins.kt @@ -3,10 +3,13 @@ object ThunderbirdPlugins { object App { const val android = "thunderbird.app.android" const val androidCompose = "thunderbird.app.android.compose" + + const val jvm = "thunderbird.app.jvm" } object Library { - const val jvm = "thunderbird.library.jvm" const val android = "thunderbird.library.android" const val androidCompose = "thunderbird.library.android.compose" + + const val jvm = "thunderbird.library.jvm" } } diff --git a/build-plugin/src/main/kotlin/ThunderbirdProjectConfig.kt b/build-plugin/src/main/kotlin/ThunderbirdProjectConfig.kt index b0ff253b9..c16a74dd5 100644 --- a/build-plugin/src/main/kotlin/ThunderbirdProjectConfig.kt +++ b/build-plugin/src/main/kotlin/ThunderbirdProjectConfig.kt @@ -2,7 +2,7 @@ import org.gradle.api.JavaVersion object ThunderbirdProjectConfig { - val javaVersion = JavaVersion.VERSION_11 + val javaCompatibilityVersion = JavaVersion.VERSION_11 const val androidSdkMin = 21 const val androidSdkTarget = 31 diff --git a/build-plugin/src/main/kotlin/thunderbird.app.android.gradle.kts b/build-plugin/src/main/kotlin/thunderbird.app.android.gradle.kts index 3710b2946..aaf7067aa 100644 --- a/build-plugin/src/main/kotlin/thunderbird.app.android.gradle.kts +++ b/build-plugin/src/main/kotlin/thunderbird.app.android.gradle.kts @@ -19,7 +19,7 @@ android { } kotlinOptions { - jvmTarget = ThunderbirdProjectConfig.javaVersion.toString() + jvmTarget = ThunderbirdProjectConfig.javaCompatibilityVersion.toString() } lint { diff --git a/build-plugin/src/main/kotlin/thunderbird.app.jvm.gradle.kts b/build-plugin/src/main/kotlin/thunderbird.app.jvm.gradle.kts new file mode 100644 index 000000000..e57a54d27 --- /dev/null +++ b/build-plugin/src/main/kotlin/thunderbird.app.jvm.gradle.kts @@ -0,0 +1,16 @@ +plugins { + id("application") + id("org.jetbrains.kotlin.jvm") +} + +java { + sourceCompatibility = ThunderbirdProjectConfig.javaCompatibilityVersion + targetCompatibility = ThunderbirdProjectConfig.javaCompatibilityVersion +} + +configureKotlinJavaCompatibility() + +dependencies { + implementation(libs.bundles.shared.jvm.main) + testImplementation(libs.bundles.shared.jvm.test) +} diff --git a/build-plugin/src/main/kotlin/thunderbird.library.android.gradle.kts b/build-plugin/src/main/kotlin/thunderbird.library.android.gradle.kts index 5c84329de..b7f0f8a54 100644 --- a/build-plugin/src/main/kotlin/thunderbird.library.android.gradle.kts +++ b/build-plugin/src/main/kotlin/thunderbird.library.android.gradle.kts @@ -11,7 +11,7 @@ android { } kotlinOptions { - jvmTarget = ThunderbirdProjectConfig.javaVersion.toString() + jvmTarget = ThunderbirdProjectConfig.javaCompatibilityVersion.toString() } lint { diff --git a/build-plugin/src/main/kotlin/thunderbird.library.jvm.gradle.kts b/build-plugin/src/main/kotlin/thunderbird.library.jvm.gradle.kts index ac2266127..82086143e 100644 --- a/build-plugin/src/main/kotlin/thunderbird.library.jvm.gradle.kts +++ b/build-plugin/src/main/kotlin/thunderbird.library.jvm.gradle.kts @@ -4,10 +4,12 @@ plugins { } java { - sourceCompatibility = ThunderbirdProjectConfig.javaVersion - targetCompatibility = ThunderbirdProjectConfig.javaVersion + sourceCompatibility = ThunderbirdProjectConfig.javaCompatibilityVersion + targetCompatibility = ThunderbirdProjectConfig.javaCompatibilityVersion } +configureKotlinJavaCompatibility() + dependencies { implementation(libs.bundles.shared.jvm.main) testImplementation(libs.bundles.shared.jvm.test) diff --git a/build-plugin/src/main/kotlin/thunderbird.quality.detekt.gradle.kts b/build-plugin/src/main/kotlin/thunderbird.quality.detekt.gradle.kts index e270ad26a..0d3a06c15 100644 --- a/build-plugin/src/main/kotlin/thunderbird.quality.detekt.gradle.kts +++ b/build-plugin/src/main/kotlin/thunderbird.quality.detekt.gradle.kts @@ -16,7 +16,7 @@ configure { } tasks.withType().configureEach { - jvmTarget = ThunderbirdProjectConfig.javaVersion.toString() + jvmTarget = ThunderbirdProjectConfig.javaCompatibilityVersion.toString() exclude( "**/.gradle/**", diff --git a/build.gradle.kts b/build.gradle.kts index 8f1ef1135..accf2d7ec 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,3 @@ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget - @Suppress("DSL_SCOPE_VIOLATION") plugins { alias(libs.plugins.android.application) apply false @@ -17,9 +15,6 @@ plugins { val propertyTestCoverage: String? by extra -val javaVersion = JavaVersion.VERSION_11 -val jvmTargetVersion = JvmTarget.JVM_11 - allprojects { extra.apply { set("testCoverageEnabled", propertyTestCoverage != null) @@ -72,10 +67,6 @@ allprojects { } } - tasks.withType { - kotlinOptions.jvmTarget = jvmTargetVersion.target - } - tasks.withType { testLogging { exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL diff --git a/cli/html-cleaner-cli/build.gradle.kts b/cli/html-cleaner-cli/build.gradle.kts index 77ae67528..c7f8a3cc4 100644 --- a/cli/html-cleaner-cli/build.gradle.kts +++ b/cli/html-cleaner-cli/build.gradle.kts @@ -1,7 +1,6 @@ @Suppress("DSL_SCOPE_VIOLATION") plugins { - alias(libs.plugins.kotlin.jvm) - id("application") + id(ThunderbirdPlugins.App.jvm) } version = "unspecified" @@ -16,8 +15,3 @@ dependencies { implementation(libs.clikt) implementation(libs.okio) } - -java { - sourceCompatibility = ThunderbirdProjectConfig.javaVersion - targetCompatibility = ThunderbirdProjectConfig.javaVersion -} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a2e59d6ed..7ed684761 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,7 +3,7 @@ [versions] gradle = "8.0.2" -androidGradlePlugin = "7.4.2" +androidGradlePlugin = "8.0.0" ktlint = "0.48.2" kotlin = "1.8.10"