Create plugin for linting (#8942)

This commit is contained in:
Andreas 2023-01-19 04:33:56 +01:00 committed by GitHub
parent b56b8b55b4
commit c31e75f02f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 45 additions and 38 deletions

View File

@ -36,4 +36,4 @@ jobs:
- name: Build app and run unit tests
uses: gradle/gradle-command-action@v2
with:
arguments: assembleStandardRelease testStandardReleaseUnitTest
arguments: lintKotlin assembleStandardRelease testStandardReleaseUnitTest

View File

@ -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

View File

@ -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 {

View File

@ -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<org.jmailen.gradle.kotlinter.KotlinterPlugin>()
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<Delete>("clean") {

View File

@ -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()
}

View File

@ -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"))
}

View File

@ -0,0 +1,20 @@
import org.jmailen.gradle.kotlinter.KotlinterExtension
import org.jmailen.gradle.kotlinter.KotlinterPlugin
apply<KotlinterPlugin>()
extensions.configure<KotlinterExtension>("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<DefaultTask>("preBuild").configure {
if (!System.getenv("CI").toBoolean())
dependsOn("formatKotlin")
}
}

View File

@ -1,6 +1,7 @@
plugins {
id("com.android.library")
kotlin("android")
id("tachiyomi.lint")
kotlin("plugin.serialization")
}

View File

@ -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" }

View File

@ -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" }
android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin_version" }
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin_version" }

View File

@ -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" }

View File

@ -1,6 +1,7 @@
plugins {
id("com.android.library")
kotlin("android")
id("tachiyomi.lint")
}
android {

View File

@ -1,6 +1,7 @@
plugins {
id("com.android.test")
kotlin("android")
id("tachiyomi.lint")
}
android {

View File

@ -1,6 +1,7 @@
plugins {
id("com.android.library")
kotlin("android")
id("tachiyomi.lint")
kotlin("plugin.serialization")
}

View File

@ -29,6 +29,7 @@ open class Page(
@Transient
private val _progressFlow = MutableStateFlow(0)
@Transient
val progressFlow = _progressFlow.asStateFlow()
var progress: Int