From 473a1fbc4ef5b183908370e11ac74dcd1688921b Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 7 Feb 2021 15:11:56 -0500 Subject: [PATCH] Don't lint generated source files --- common.gradle | 4 ++++ .../tachiyomi/multisrc/ThemeSourceGenerator.kt | 14 +++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/common.gradle b/common.gradle index 02315cfd8..a59729e5f 100644 --- a/common.gradle +++ b/common.gradle @@ -58,5 +58,9 @@ repositories { apply from: "$rootDir/common-dependencies.gradle" +lintKotlinMain { + exclude 'generated-src/**/*.kt' +} + preBuild.dependsOn(lintKotlin) lintKotlin.dependsOn(formatKotlin) diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/ThemeSourceGenerator.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/ThemeSourceGenerator.kt index 9f2aa6dc0..c9c31280b 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/ThemeSourceGenerator.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/ThemeSourceGenerator.kt @@ -106,8 +106,8 @@ interface ThemeSourceGenerator { val themeSrcPath = "$userDir/multisrc/src/main/java/${themeSuffix(themePkg, "/")}" val themeSrcFile = File(themeSrcPath) val themeDestPath = "$projectRootPath/src/${themeSuffix(themePkg, "/")}" - val themeDestFile = File(themeDestPath) + val themeDestFile = File(themeDestPath) themeDestFile.mkdirs() themeSrcFile.list()!! @@ -147,7 +147,7 @@ interface ThemeSourceGenerator { """.trimIndent() } is ThemeSourceData.MultiLang -> { - val sourceClasses = source.lang.mapIndexed { index, lang -> + val sourceClasses = source.langs.mapIndexed { index, lang -> val indexedClassName = "$themeClass${index}" indexedClassName to """$indexedClassName : $themeClass("${source.name}", "${source.baseUrl}", "$lang") { override val versionId = ${source.versionId} @@ -168,7 +168,7 @@ interface ThemeSourceGenerator { } File("$classPath/${source.className}.kt").writeText(""" - // THIS FILE IS AUTO-GENERATED; DO NOT EDIT??? + // THIS FILE IS AUTO-GENERATED; DO NOT EDIT package eu.kanade.tachiyomi.extension.${pkgNameSuffix(source, ".")} import eu.kanade.tachiyomi.multisrc.$themePkg.$themeClass @@ -181,7 +181,7 @@ interface ThemeSourceGenerator { } private fun cleanDirectory(dir: File) { - for (file in dir.listFiles()!!) { + dir.listFiles()?.forEach { file -> if (file.isDirectory) cleanDirectory(file) file.delete() } @@ -212,20 +212,20 @@ sealed class ThemeSourceData { override val baseUrl: String, val lang: String, override val isNsfw: Boolean = false, + override val versionId: Int = 1, override val className: String = name.replace(" ", ""), override val pkgName: String = className.toLowerCase(Locale.ENGLISH), - override val versionId: Int = 1, override val overrideVersionCode: Int = 0, ) : ThemeSourceData() data class MultiLang( override val name: String, override val baseUrl: String, - val lang: List, + val langs: List, override val isNsfw: Boolean = false, + override val versionId: Int = 1, override val className: String = name.replace(" ", "") + "Factory", override val pkgName: String = className.substringBefore("Factory").toLowerCase(Locale.ENGLISH), - override val versionId: Int = 1, override val overrideVersionCode: Int = 0, ) : ThemeSourceData() }