diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml index 051c2e46d..9b6ede0c3 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build_pull_request.yml @@ -36,4 +36,4 @@ jobs: - name: Build app and run unit tests uses: gradle/gradle-command-action@v2 with: - arguments: assembleStandardRelease testStandardReleaseUnitTest \ No newline at end of file + arguments: lintKotlin assembleStandardRelease testStandardReleaseUnitTest \ No newline at end of file diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 588d199a0..5bea25988 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -31,7 +31,7 @@ jobs: - name: Build app and run unit tests uses: gradle/gradle-command-action@v2 with: - arguments: assembleStandardRelease testStandardReleaseUnitTest + arguments: lintKotlin assembleStandardRelease testStandardReleaseUnitTest # Sign APK and create release for tags diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 2ed374a7a..7e6126557 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -6,6 +6,7 @@ plugins { id("com.android.application") id("com.mikepenz.aboutlibraries.plugin") kotlin("android") + id("tachiyomi.lint") kotlin("plugin.serialization") id("com.github.zellius.shortcut-helper") id("com.squareup.sqldelight") @@ -346,11 +347,6 @@ tasks { ) } } - - preBuild { - val ktlintTask = if (System.getenv("GITHUB_BASE_REF") == null) formatKotlin else lintKotlin - dependsOn(ktlintTask) - } } buildscript { diff --git a/build.gradle.kts b/build.gradle.kts index 8d8911245..10b653f9c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,30 +3,12 @@ buildscript { classpath(libs.android.shortcut.gradle) classpath(libs.google.services.gradle) classpath(libs.aboutLibraries.gradle) - classpath(kotlinx.serialization.gradle) classpath(libs.sqldelight.gradle) } } plugins { - alias(androidx.plugins.application) apply false - alias(androidx.plugins.library) apply false - alias(androidx.plugins.test) apply false - alias(kotlinx.plugins.android) apply false - alias(libs.plugins.kotlinter) -} - -subprojects { - apply() - - kotlinter { - experimentalRules = true - - disabledRules = arrayOf( - "experimental:argument-list-wrapping", // Doesn't play well with Android Studio - "filename", // Often broken to give a more general name - ) - } + alias(kotlinx.plugins.serialization) apply false } tasks.register("clean") { diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index c2d953689..b5854fcb5 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -3,12 +3,14 @@ plugins { } dependencies { - compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinLibs.versions.kotlin.version.get()}") - + implementation(androidxLibs.gradle) + implementation(kotlinLibs.gradle) + implementation(libs.kotlinter) implementation(gradleApi()) } repositories { + gradlePluginPortal() mavenCentral() google() } diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts index 807fe41ca..05a279df0 100644 --- a/buildSrc/settings.gradle.kts +++ b/buildSrc/settings.gradle.kts @@ -1,5 +1,11 @@ dependencyResolutionManagement { versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + create("androidxLibs") { + from(files("../gradle/androidx.versions.toml")) + } create("kotlinLibs") { from(files("../gradle/kotlinx.versions.toml")) } diff --git a/buildSrc/src/main/kotlin/tachiyomi.lint.gradle.kts b/buildSrc/src/main/kotlin/tachiyomi.lint.gradle.kts new file mode 100644 index 000000000..12b7b2295 --- /dev/null +++ b/buildSrc/src/main/kotlin/tachiyomi.lint.gradle.kts @@ -0,0 +1,20 @@ +import org.jmailen.gradle.kotlinter.KotlinterExtension +import org.jmailen.gradle.kotlinter.KotlinterPlugin + +apply() + +extensions.configure("kotlinter") { + experimentalRules = true + + disabledRules = arrayOf( + "experimental:argument-list-wrapping", // Doesn't play well with Android Studio + "filename", // Often broken to give a more general name + ) +} + +tasks { + named("preBuild").configure { + if (!System.getenv("CI").toBoolean()) + dependsOn("formatKotlin") + } +} diff --git a/core/build.gradle.kts b/core/build.gradle.kts index f769da7c3..0334387a5 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -1,6 +1,7 @@ plugins { id("com.android.library") kotlin("android") + id("tachiyomi.lint") kotlin("plugin.serialization") } diff --git a/gradle/androidx.versions.toml b/gradle/androidx.versions.toml index ec9184415..96c491b56 100644 --- a/gradle/androidx.versions.toml +++ b/gradle/androidx.versions.toml @@ -3,6 +3,8 @@ agp_version = "7.4.0" lifecycle_version = "2.5.1" [libraries] +gradle = { module = "com.android.tools.build:gradle", version.ref = "agp_version" } + annotation = "androidx.annotation:annotation:1.5.0" appcompat = "androidx.appcompat:appcompat:1.6.0" biometricktx = "androidx.biometric:biometric-ktx:1.2.0-alpha05" @@ -33,8 +35,3 @@ test-uiautomator = "androidx.test.uiautomator:uiautomator:2.2.0" [bundles] lifecycle = ["lifecycle-common", "lifecycle-process", "lifecycle-runtimektx"] workmanager = ["work-runtime", "guava"] - -[plugins] -application = { id = "com.android.application", version.ref = "agp_version" } -library = { id = "com.android.library", version.ref = "agp_version" } -test = { id = "com.android.test", version.ref = "agp_version" } diff --git a/gradle/kotlinx.versions.toml b/gradle/kotlinx.versions.toml index 6f944b83c..bc62e6408 100644 --- a/gradle/kotlinx.versions.toml +++ b/gradle/kotlinx.versions.toml @@ -15,7 +15,6 @@ coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-androi serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version = "1.4.0" } serialization-json-okio = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json-okio", version = "1.4.0" } serialization-protobuf = { module = "org.jetbrains.kotlinx:kotlinx-serialization-protobuf", version.ref = "serialization_version" } -serialization-gradle = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin_version" } serialization-xml-core = { module = "io.github.pdvrieze.xmlutil:core-android", version.ref = "xml_serialization_version" } serialization-xml = { module = "io.github.pdvrieze.xmlutil:serialization-android", version.ref = "xml_serialization_version" } @@ -24,4 +23,5 @@ coroutines = ["coroutines-core", "coroutines-android"] serialization = ["serialization-json", "serialization-json-okio", "serialization-protobuf", "serialization-xml-core", "serialization-xml"] [plugins] -android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin_version" } \ No newline at end of file +android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin_version" } +serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin_version" } \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d30e9c67e..87540e5d4 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -89,6 +89,8 @@ voyager-navigator = { module = "ca.gosyer:voyager-navigator", version.ref = "voy voyager-tab-navigator = { module = "ca.gosyer:voyager-tab-navigator", version.ref = "voyager" } voyager-transitions = { module = "ca.gosyer:voyager-transitions", version.ref = "voyager" } +kotlinter = "org.jmailen.gradle:kotlinter-gradle:3.13.0" + [bundles] reactivex = ["rxandroid", "rxjava", "rxrelay"] okhttp = ["okhttp-core", "okhttp-logging", "okhttp-dnsoverhttps"] @@ -98,6 +100,3 @@ coil = ["coil-core", "coil-gif", "coil-compose"] shizuku = ["shizuku-api", "shizuku-provider"] voyager = ["voyager-navigator", "voyager-tab-navigator", "voyager-transitions"] richtext = ["richtext-commonmark", "richtext-m3"] - -[plugins] -kotlinter = { id = "org.jmailen.kotlinter", version = "3.13.0" } \ No newline at end of file diff --git a/i18n/build.gradle.kts b/i18n/build.gradle.kts index 42239ed07..e0d5f475d 100644 --- a/i18n/build.gradle.kts +++ b/i18n/build.gradle.kts @@ -1,6 +1,7 @@ plugins { id("com.android.library") kotlin("android") + id("tachiyomi.lint") } android { diff --git a/macrobenchmark/build.gradle.kts b/macrobenchmark/build.gradle.kts index 60ef1043f..0b32ad047 100644 --- a/macrobenchmark/build.gradle.kts +++ b/macrobenchmark/build.gradle.kts @@ -1,6 +1,7 @@ plugins { id("com.android.test") kotlin("android") + id("tachiyomi.lint") } android { diff --git a/source-api/build.gradle.kts b/source-api/build.gradle.kts index 89b281543..b530eba00 100644 --- a/source-api/build.gradle.kts +++ b/source-api/build.gradle.kts @@ -1,6 +1,7 @@ plugins { id("com.android.library") kotlin("android") + id("tachiyomi.lint") kotlin("plugin.serialization") } diff --git a/source-api/src/main/java/eu/kanade/tachiyomi/source/model/Page.kt b/source-api/src/main/java/eu/kanade/tachiyomi/source/model/Page.kt index 44180c6a3..a43918f55 100644 --- a/source-api/src/main/java/eu/kanade/tachiyomi/source/model/Page.kt +++ b/source-api/src/main/java/eu/kanade/tachiyomi/source/model/Page.kt @@ -29,6 +29,7 @@ open class Page( @Transient private val _progressFlow = MutableStateFlow(0) + @Transient val progressFlow = _progressFlow.asStateFlow() var progress: Int