Fix wrong indentation in multisrc generated files (#13092)
* Fix wrong indentation in generated files. * Lint the file.
This commit is contained in:
parent
a9aa05581a
commit
6fb71ea1a9
|
@ -59,35 +59,40 @@ interface ThemeSourceGenerator {
|
|||
val placeholders = mapOf(
|
||||
"SOURCEHOST" to source.baseUrl.toHttpUrlOrNull()?.host,
|
||||
"SOURCESCHEME" to source.baseUrl.toHttpUrlOrNull()?.scheme
|
||||
).filter { it.value != null }
|
||||
)
|
||||
|
||||
val placeholdersStr = placeholders
|
||||
.filter { it.value != null }
|
||||
.map { "${" ".repeat(12)}${it.key}: \"${it.value}\"" }
|
||||
.joinToString(",\n")
|
||||
|
||||
gradle.writeText(
|
||||
"""
|
||||
// THIS FILE IS AUTO-GENERATED; DO NOT EDIT
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlinx-serialization'
|
||||
|
||||
ext {
|
||||
extName = '${source.name}'
|
||||
pkgNameSuffix = '${pkgNameSuffix(source, ".")}'
|
||||
extClass = '.${source.className}'
|
||||
extFactory = '$themePkg'
|
||||
extVersionCode = ${baseVersionCode + source.overrideVersionCode + multisrcLibraryVersion}
|
||||
${if (source.isNsfw) "isNsfw = true\n" else ""}
|
||||
}
|
||||
$defaultAdditionalGradleText
|
||||
$additionalGradleOverrideText
|
||||
apply from: "${'$'}rootDir/common.gradle"
|
||||
|
||||
android {
|
||||
defaultConfig {
|
||||
manifestPlaceholders += [
|
||||
${placeholders.map { "${" ".repeat(28)}${it.key}: \"${it.value}\""}.joinToString(",\n")}
|
||||
]
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
|// THIS FILE IS AUTO-GENERATED; DO NOT EDIT
|
||||
|apply plugin: 'com.android.application'
|
||||
|apply plugin: 'kotlin-android'
|
||||
|apply plugin: 'kotlinx-serialization'
|
||||
|
|
||||
|ext {
|
||||
| extName = '${source.name}'
|
||||
| pkgNameSuffix = '${pkgNameSuffix(source, ".")}'
|
||||
| extClass = '.${source.className}'
|
||||
| extFactory = '$themePkg'
|
||||
| extVersionCode = ${baseVersionCode + source.overrideVersionCode + multisrcLibraryVersion}
|
||||
| ${if (source.isNsfw) "isNsfw = true\n" else ""}
|
||||
|}
|
||||
|$defaultAdditionalGradleText
|
||||
|$additionalGradleOverrideText
|
||||
|apply from: "${'$'}rootDir/common.gradle"
|
||||
|
|
||||
|android {
|
||||
| defaultConfig {
|
||||
| manifestPlaceholders += [
|
||||
|$placeholdersStr
|
||||
| ]
|
||||
| }
|
||||
|}
|
||||
""".trimMargin()
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -101,10 +106,10 @@ ${placeholders.map { "${" ".repeat(28)}${it.key}: \"${it.value}\""}.joinToString
|
|||
} else {
|
||||
androidManifestFile.writeText(
|
||||
"""
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- THIS FILE IS AUTO-GENERATED; DO NOT EDIT -->
|
||||
<manifest package="eu.kanade.tachiyomi.extension" />
|
||||
""".trimIndent()
|
||||
|<?xml version="1.0" encoding="utf-8"?>
|
||||
|<!-- THIS FILE IS AUTO-GENERATED; DO NOT EDIT -->
|
||||
|<manifest package="eu.kanade.tachiyomi.extension" />
|
||||
""".trimMargin()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -144,17 +149,15 @@ ${placeholders.map { "${" ".repeat(28)}${it.key}: \"${it.value}\""}.joinToString
|
|||
private fun copyThemeReadmes(userDir: String, themePkg: String, overridesPath: String, projectRootPath: String) {
|
||||
val sourcePath = "$userDir/multisrc/src/main/java/${themeSuffix(themePkg, "/")}"
|
||||
|
||||
val destinationPath = "$projectRootPath"
|
||||
File(destinationPath).mkdirs()
|
||||
File(projectRootPath).mkdirs()
|
||||
|
||||
listOf(sourcePath, overridesPath).forEach { path ->
|
||||
File(path)
|
||||
?.list()
|
||||
File(path).list()
|
||||
?.filter { it.endsWith("README.md") || it.endsWith("CHANGELOG.md") }
|
||||
?.forEach {
|
||||
Files.copy(
|
||||
File("$path/$it").toPath(),
|
||||
File("$destinationPath/$it").toPath(),
|
||||
File("$projectRootPath/$it").toPath(),
|
||||
StandardCopyOption.REPLACE_EXISTING
|
||||
)
|
||||
}
|
||||
|
@ -167,8 +170,7 @@ ${placeholders.map { "${" ".repeat(28)}${it.key}: \"${it.value}\""}.joinToString
|
|||
val themeDestPath = "$projectRootPath/src/${themeSuffix(themePkg, "/")}"
|
||||
File(themeDestPath).mkdirs()
|
||||
|
||||
File(themeSrcPath)
|
||||
?.list()
|
||||
File(themeSrcPath).list()
|
||||
?.filter { it.endsWith(".kt") && !it.endsWith("Generator.kt") }
|
||||
?.forEach { Files.copy(File("$themeSrcPath/$it").toPath(), File("$themeDestPath/$it").toPath(), StandardCopyOption.REPLACE_EXISTING) }
|
||||
}
|
||||
|
@ -207,25 +209,26 @@ ${placeholders.map { "${" ".repeat(28)}${it.key}: \"${it.value}\""}.joinToString
|
|||
}
|
||||
|
||||
"""
|
||||
class ${source.className} : SourceFactory {
|
||||
override fun createSources() = listOf(
|
||||
${sourceClasses.joinToString(",\n")}
|
||||
)
|
||||
}
|
||||
""".trimIndent()
|
||||
|class ${source.className} : SourceFactory {
|
||||
| override fun createSources() = listOf(
|
||||
| ${sourceClasses.joinToString(",\n")}
|
||||
| )
|
||||
|}
|
||||
""".trimMargin()
|
||||
}
|
||||
}
|
||||
|
||||
File("$classPath/${source.className}.kt").writeText(
|
||||
"""/* ktlint-disable */
|
||||
// THIS FILE IS AUTO-GENERATED; DO NOT EDIT
|
||||
package eu.kanade.tachiyomi.extension.${pkgNameSuffix(source, ".")}
|
||||
|
||||
import eu.kanade.tachiyomi.multisrc.$themePkg.$themeClass
|
||||
${if (source is ThemeSourceData.MultiLang) "import eu.kanade.tachiyomi.source.SourceFactory" else ""}
|
||||
|
||||
${factoryClassText()}
|
||||
""".trimIndent()
|
||||
"""
|
||||
|/* ktlint-disable */
|
||||
|// THIS FILE IS AUTO-GENERATED; DO NOT EDIT
|
||||
|package eu.kanade.tachiyomi.extension.${pkgNameSuffix(source, ".")}
|
||||
|
|
||||
|import eu.kanade.tachiyomi.multisrc.$themePkg.$themeClass
|
||||
|${if (source is ThemeSourceData.MultiLang) "import eu.kanade.tachiyomi.source.SourceFactory" else ""}
|
||||
|
|
||||
|${factoryClassText()}
|
||||
""".trimMargin()
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -271,7 +274,7 @@ sealed class ThemeSourceData {
|
|||
val lang: String,
|
||||
override val isNsfw: Boolean = false,
|
||||
override val className: String = name.replace(" ", ""),
|
||||
override val pkgName: String = className.toLowerCase(Locale.ENGLISH),
|
||||
override val pkgName: String = className.lowercase(Locale.ENGLISH),
|
||||
override val sourceName: String = name,
|
||||
override val overrideVersionCode: Int = 0,
|
||||
) : ThemeSourceData()
|
||||
|
@ -282,7 +285,7 @@ sealed class ThemeSourceData {
|
|||
val langs: List<String>,
|
||||
override val isNsfw: Boolean = false,
|
||||
override val className: String = name.replace(" ", "") + "Factory",
|
||||
override val pkgName: String = className.substringBefore("Factory").toLowerCase(Locale.ENGLISH),
|
||||
override val pkgName: String = className.substringBefore("Factory").lowercase(Locale.ENGLISH),
|
||||
override val sourceName: String = name,
|
||||
override val overrideVersionCode: Int = 0,
|
||||
) : ThemeSourceData()
|
||||
|
|
Loading…
Reference in New Issue