From a1c60897916f418726107fec80ad79b2a4b8d500 Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Thu, 31 Oct 2024 20:17:27 +0600 Subject: [PATCH] Address some build warnings and cleanup (#1412) --- app/build.gradle.kts | 43 +++++++++---------- .../kanade/tachiyomi/data/saver/ImageSaver.kt | 1 + .../mihon/buildlogic/ProjectExtensions.kt | 2 +- core/common/build.gradle.kts | 7 +-- .../tachiyomi/util/system/WebViewUtil.kt | 1 - data/build.gradle.kts | 15 +++---- domain/build.gradle.kts | 15 +++---- i18n/build.gradle.kts | 13 +++--- .../moko-resources/base/strings.xml | 2 +- presentation-core/build.gradle.kts | 32 ++++++-------- .../core/components/SettingsItems.kt | 3 +- source-api/build.gradle.kts | 15 +++---- source-local/build.gradle.kts | 19 ++++---- 13 files changed, 78 insertions(+), 90 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 5f339095a8..20814d2cb7 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,7 +1,8 @@ +@file:Suppress("ChromeOsAbiSupport") + import mihon.buildlogic.getBuildTime import mihon.buildlogic.getCommitCount import mihon.buildlogic.getGitSha -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { id("mihon.android.application") @@ -142,6 +143,24 @@ android { } } +kotlin { + compilerOptions { + freeCompilerArgs.addAll( + "-opt-in=androidx.compose.animation.ExperimentalAnimationApi", + "-opt-in=androidx.compose.animation.graphics.ExperimentalAnimationGraphicsApi", + "-opt-in=androidx.compose.foundation.ExperimentalFoundationApi", + "-opt-in=androidx.compose.foundation.layout.ExperimentalLayoutApi", + "-opt-in=androidx.compose.material3.ExperimentalMaterial3Api", + "-opt-in=androidx.compose.ui.ExperimentalComposeUiApi", + "-opt-in=coil3.annotation.ExperimentalCoilApi", + "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", + "-opt-in=kotlinx.coroutines.FlowPreview", + "-opt-in=kotlinx.coroutines.InternalCoroutinesApi", + "-opt-in=kotlinx.serialization.ExperimentalSerializationApi", + ) + } +} + dependencies { implementation(projects.i18n) implementation(projects.core.archive) @@ -279,28 +298,6 @@ androidComponents { } } -tasks { - // See https://kotlinlang.org/docs/reference/experimental.html#experimental-status-of-experimental-api(-markers) - withType { - compilerOptions.freeCompilerArgs.addAll( - "-Xcontext-receivers", - "-opt-in=androidx.compose.foundation.layout.ExperimentalLayoutApi", - "-opt-in=androidx.compose.material.ExperimentalMaterialApi", - "-opt-in=androidx.compose.material3.ExperimentalMaterial3Api", - "-opt-in=androidx.compose.material.ExperimentalMaterialApi", - "-opt-in=androidx.compose.ui.ExperimentalComposeUiApi", - "-opt-in=androidx.compose.foundation.ExperimentalFoundationApi", - "-opt-in=androidx.compose.animation.ExperimentalAnimationApi", - "-opt-in=androidx.compose.animation.graphics.ExperimentalAnimationGraphicsApi", - "-opt-in=coil3.annotation.ExperimentalCoilApi", - "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", - "-opt-in=kotlinx.coroutines.FlowPreview", - "-opt-in=kotlinx.coroutines.InternalCoroutinesApi", - "-opt-in=kotlinx.serialization.ExperimentalSerializationApi", - ) - } -} - buildscript { dependencies { classpath(kotlinx.gradle) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/saver/ImageSaver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/saver/ImageSaver.kt index 0cc0ebc04d..144c6f1fb6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/saver/ImageSaver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/saver/ImageSaver.kt @@ -175,6 +175,7 @@ sealed class Image( } sealed interface Location { + @ConsistentCopyVisibility data class Pictures private constructor(val relativePath: String) : Location { companion object { fun create(relativePath: String = ""): Pictures { diff --git a/buildSrc/src/main/kotlin/mihon/buildlogic/ProjectExtensions.kt b/buildSrc/src/main/kotlin/mihon/buildlogic/ProjectExtensions.kt index 86d16d33b5..1895887a2f 100644 --- a/buildSrc/src/main/kotlin/mihon/buildlogic/ProjectExtensions.kt +++ b/buildSrc/src/main/kotlin/mihon/buildlogic/ProjectExtensions.kt @@ -45,8 +45,8 @@ internal fun Project.configureAndroid(commonExtension: CommonExtension<*, *, *, compilerOptions { jvmTarget.set(AndroidConfig.JvmTarget) freeCompilerArgs.addAll( - "-opt-in=kotlin.RequiresOptIn", "-Xcontext-receivers", + "-opt-in=kotlin.RequiresOptIn", ) // Treat all Kotlin warnings as errors (disabled by default) diff --git a/core/common/build.gradle.kts b/core/common/build.gradle.kts index d00fec6822..83e2c02ce2 100644 --- a/core/common/build.gradle.kts +++ b/core/common/build.gradle.kts @@ -6,10 +6,11 @@ plugins { android { namespace = "eu.kanade.tachiyomi.core.common" +} - kotlinOptions { - freeCompilerArgs += listOf( - "-Xcontext-receivers", +kotlin { + compilerOptions { + freeCompilerArgs.addAll( "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", "-opt-in=kotlinx.serialization.ExperimentalSerializationApi", ) diff --git a/core/common/src/main/kotlin/eu/kanade/tachiyomi/util/system/WebViewUtil.kt b/core/common/src/main/kotlin/eu/kanade/tachiyomi/util/system/WebViewUtil.kt index b2ebc477e7..51069398af 100644 --- a/core/common/src/main/kotlin/eu/kanade/tachiyomi/util/system/WebViewUtil.kt +++ b/core/common/src/main/kotlin/eu/kanade/tachiyomi/util/system/WebViewUtil.kt @@ -68,7 +68,6 @@ fun WebView.setDefaultSettings() { with(settings) { javaScriptEnabled = true domStorageEnabled = true - databaseEnabled = true useWideViewPort = true loadWithOverviewMode = true cacheMode = WebSettings.LOAD_DEFAULT diff --git a/data/build.gradle.kts b/data/build.gradle.kts index d3ca29085d..552bae9b3a 100644 --- a/data/build.gradle.kts +++ b/data/build.gradle.kts @@ -23,6 +23,12 @@ android { } } +kotlin { + compilerOptions { + freeCompilerArgs.add("-opt-in=kotlinx.serialization.ExperimentalSerializationApi") + } +} + dependencies { implementation(projects.sourceApi) implementation(projects.domain) @@ -30,12 +36,3 @@ dependencies { api(libs.bundles.sqldelight) } - -tasks { - withType { - compilerOptions.freeCompilerArgs.addAll( - "-Xcontext-receivers", - "-opt-in=kotlinx.serialization.ExperimentalSerializationApi", - ) - } -} diff --git a/domain/build.gradle.kts b/domain/build.gradle.kts index 328d739d1d..fd4c194176 100644 --- a/domain/build.gradle.kts +++ b/domain/build.gradle.kts @@ -13,6 +13,12 @@ android { } } +kotlin { + compilerOptions { + freeCompilerArgs.add("-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi") + } +} + dependencies { implementation(projects.sourceApi) implementation(projects.core.common) @@ -30,12 +36,3 @@ dependencies { testImplementation(libs.bundles.test) testImplementation(kotlinx.coroutines.test) } - -tasks { - withType { - compilerOptions.freeCompilerArgs.addAll( - "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", - "-Xcontext-receivers", - ) - } -} diff --git a/i18n/build.gradle.kts b/i18n/build.gradle.kts index ac5fa0bd49..7259e46fdb 100644 --- a/i18n/build.gradle.kts +++ b/i18n/build.gradle.kts @@ -1,6 +1,6 @@ import mihon.buildlogic.generatedBuildDir import mihon.buildlogic.tasks.getLocalesConfigTask -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi plugins { id("mihon.library") @@ -20,6 +20,11 @@ kotlin { } } } + + @OptIn(ExperimentalKotlinGradlePluginApi::class) + compilerOptions { + freeCompilerArgs.add("-Xexpect-actual-classes") + } } val generatedAndroidResourceDir = generatedBuildDir.resolve("android/res") @@ -49,10 +54,4 @@ tasks { preBuild { dependsOn(localesConfigTask) } - - withType { - compilerOptions.freeCompilerArgs.addAll( - "-Xexpect-actual-classes", - ) - } } diff --git a/i18n/src/commonMain/moko-resources/base/strings.xml b/i18n/src/commonMain/moko-resources/base/strings.xml index d6020896a7..6d7e7adba1 100644 --- a/i18n/src/commonMain/moko-resources/base/strings.xml +++ b/i18n/src/commonMain/moko-resources/base/strings.xml @@ -540,7 +540,7 @@ Trackers not logged into: You may need to install any missing extensions and log in to tracking services afterwards to use them. Restore completed - %02d min, %02d sec + %1$02d min, %2$02d sec Backup is already in progress What do you want to backup? App settings diff --git a/presentation-core/build.gradle.kts b/presentation-core/build.gradle.kts index c6e5c0b65b..f55a8c0608 100644 --- a/presentation-core/build.gradle.kts +++ b/presentation-core/build.gradle.kts @@ -13,6 +13,20 @@ android { } } +kotlin { + compilerOptions { + freeCompilerArgs.addAll( + "-opt-in=androidx.compose.animation.ExperimentalAnimationApi", + "-opt-in=androidx.compose.animation.graphics.ExperimentalAnimationGraphicsApi", + "-opt-in=androidx.compose.foundation.ExperimentalFoundationApi", + "-opt-in=androidx.compose.foundation.layout.ExperimentalLayoutApi", + "-opt-in=androidx.compose.material3.ExperimentalMaterial3Api", + "-opt-in=androidx.compose.ui.ExperimentalComposeUiApi", + "-opt-in=kotlinx.coroutines.FlowPreview", + ) + } +} + dependencies { api(projects.core.common) api(projects.i18n) @@ -30,21 +44,3 @@ dependencies { implementation(kotlinx.immutables) } - -tasks { - // See https://kotlinlang.org/docs/reference/experimental.html#experimental-status-of-experimental-api(-markers) - withType { - compilerOptions.freeCompilerArgs.addAll( - "-opt-in=androidx.compose.foundation.layout.ExperimentalLayoutApi", - "-opt-in=androidx.compose.material.ExperimentalMaterialApi", - "-opt-in=androidx.compose.material3.ExperimentalMaterial3Api", - "-opt-in=androidx.compose.material.ExperimentalMaterialApi", - "-opt-in=androidx.compose.ui.ExperimentalComposeUiApi", - "-opt-in=androidx.compose.foundation.ExperimentalFoundationApi", - "-opt-in=androidx.compose.animation.ExperimentalAnimationApi", - "-opt-in=androidx.compose.animation.graphics.ExperimentalAnimationGraphicsApi", - "-opt-in=coil3.annotation.ExperimentalCoilApi", - "-opt-in=kotlinx.coroutines.FlowPreview", - ) - } -} diff --git a/presentation-core/src/main/java/tachiyomi/presentation/core/components/SettingsItems.kt b/presentation-core/src/main/java/tachiyomi/presentation/core/components/SettingsItems.kt index acf55fcd72..5a8ab42153 100644 --- a/presentation-core/src/main/java/tachiyomi/presentation/core/components/SettingsItems.kt +++ b/presentation-core/src/main/java/tachiyomi/presentation/core/components/SettingsItems.kt @@ -26,6 +26,7 @@ import androidx.compose.material3.ExposedDropdownMenuBox import androidx.compose.material3.ExposedDropdownMenuDefaults import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.MenuAnchorType import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.RadioButton import androidx.compose.material3.Text @@ -219,7 +220,7 @@ fun SelectItem( ) { OutlinedTextField( modifier = Modifier - .menuAnchor() + .menuAnchor(MenuAnchorType.PrimaryNotEditable) .fillMaxWidth() .padding( horizontal = SettingsItemsPaddings.Horizontal, diff --git a/source-api/build.gradle.kts b/source-api/build.gradle.kts index b336e2c06c..330e5f29d5 100644 --- a/source-api/build.gradle.kts +++ b/source-api/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi + plugins { id("mihon.library") kotlin("multiplatform") @@ -29,6 +31,11 @@ kotlin { } } } + + @OptIn(ExperimentalKotlinGradlePluginApi::class) + compilerOptions { + freeCompilerArgs.add("-Xexpect-actual-classes") + } } android { @@ -38,11 +45,3 @@ android { consumerProguardFile("consumer-proguard.pro") } } - -tasks { - withType { - compilerOptions.freeCompilerArgs.addAll( - "-Xexpect-actual-classes", - ) - } -} diff --git a/source-local/build.gradle.kts b/source-local/build.gradle.kts index 1e1d3e0721..f7c8b7dce1 100644 --- a/source-local/build.gradle.kts +++ b/source-local/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi + plugins { id("mihon.library") kotlin("multiplatform") @@ -27,6 +29,14 @@ kotlin { } } } + + @OptIn(ExperimentalKotlinGradlePluginApi::class) + compilerOptions { + freeCompilerArgs.addAll( + "-Xexpect-actual-classes", + "-opt-in=kotlinx.serialization.ExperimentalSerializationApi", + ) + } } android { @@ -37,12 +47,3 @@ android { consumerProguardFiles("consumer-rules.pro") } } - -tasks { - withType { - compilerOptions.freeCompilerArgs.addAll( - "-Xexpect-actual-classes", - "-opt-in=kotlinx.serialization.ExperimentalSerializationApi", - ) - } -}