[SKIP CI] add additional gradle support (#5845)
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 7.4 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 69 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 1006 B After Width: | Height: | Size: 1006 B |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 7.5 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 8.5 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.3 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 87 KiB |
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 7.4 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 89 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 81 KiB |
|
@ -49,7 +49,12 @@ interface ThemeSourceGenerator {
|
|||
return listOf("eu", "kanade", "tachiyomi", "multisrc", themePkg).joinToString(separator)
|
||||
}
|
||||
|
||||
private fun writeGradle(gradle: File, source: ThemeSourceData, themePkg: String, baseVersionCode: Int) {
|
||||
private fun writeGradle(gradle: File, source: ThemeSourceData, themePkg: String, baseVersionCode: Int, defaultAdditionalGradlePath: String, additionalGradleOverridePath: String) {
|
||||
fun File.readTextOrEmptyString(): String = if (exists()) readText(Charsets.UTF_8) else ""
|
||||
|
||||
val defaultAdditionalGradleText = File(defaultAdditionalGradlePath).readTextOrEmptyString()
|
||||
val additionalGradleOverrideText = File(additionalGradleOverridePath).readTextOrEmptyString()
|
||||
|
||||
gradle.writeText("""
|
||||
// THIS FILE IS AUTO-GENERATED; DO NOT EDIT
|
||||
apply plugin: 'com.android.application'
|
||||
|
@ -64,7 +69,8 @@ interface ThemeSourceGenerator {
|
|||
libVersion = '1.2'
|
||||
${if (source.isNsfw) "containsNsfw = true\n" else ""}
|
||||
}
|
||||
|
||||
$defaultAdditionalGradleText
|
||||
$additionalGradleOverrideText
|
||||
apply from: "${'$'}rootDir/common.gradle"
|
||||
""".trimIndent())
|
||||
}
|
||||
|
@ -85,10 +91,12 @@ interface ThemeSourceGenerator {
|
|||
val projectRootPath = "$userDir/generated-src/${pkgNameSuffix(source, "/")}"
|
||||
val projectSrcPath = "$projectRootPath/src/eu/kanade/tachiyomi/extension/${pkgNameSuffix(source, "/")}"
|
||||
val overridesPath = "$userDir/multisrc/overrides/$themePkg/${source.pkgName}" // userDir = tachiyomi-extensions project root path
|
||||
val defaultResPath = "$userDir/multisrc/overrides/$themePkg/default_res"
|
||||
val resOverridesPath = "$overridesPath/res"
|
||||
val srcOverridesPath = "$overridesPath/src"
|
||||
val manifestOverridesPath = "$overridesPath/AndroidManifest.xml"
|
||||
val defaultResPath = "$userDir/multisrc/overrides/$themePkg/default/res"
|
||||
val defaultAdditionalGradlePath = "$userDir/multisrc/overrides/$themePkg/default/additional.gradle.kts"
|
||||
val resOverridePath = "$overridesPath/res"
|
||||
val srcOverridePath = "$overridesPath/src"
|
||||
val manifestOverridePath = "$overridesPath/AndroidManifest.xml"
|
||||
val additionalGradleOverridePath = "$overridesPath/additional.gradle.kts"
|
||||
val projectGradleFile = File("$projectRootPath/build.gradle")
|
||||
val projectAndroidManifestFile = File("$projectRootPath/AndroidManifest.xml")
|
||||
|
||||
|
@ -99,13 +107,13 @@ interface ThemeSourceGenerator {
|
|||
// remove everything from past runs
|
||||
cleanDirectory(projectRootFile)
|
||||
|
||||
writeGradle(projectGradleFile, source, themePkg, baseVersionCode)
|
||||
writeAndroidManifest(projectAndroidManifestFile, manifestOverridesPath)
|
||||
writeGradle(projectGradleFile, source, themePkg, baseVersionCode, defaultAdditionalGradlePath, additionalGradleOverridePath)
|
||||
writeAndroidManifest(projectAndroidManifestFile, manifestOverridePath)
|
||||
|
||||
writeSourceClasses(projectSrcPath, srcOverridesPath, source, themePkg, themeClass)
|
||||
writeSourceClasses(projectSrcPath, srcOverridePath, source, themePkg, themeClass)
|
||||
copyThemeClasses(userDir, themePkg, projectRootPath)
|
||||
|
||||
copyResFiles(overridesPath, defaultResPath, source, projectRootPath)
|
||||
copyResFiles(resOverridePath, defaultResPath, source, projectRootPath)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,9 +130,9 @@ interface ThemeSourceGenerator {
|
|||
.forEach { Files.copy(File("$themeSrcPath/$it").toPath(), File("$themeDestPath/$it").toPath(), StandardCopyOption.REPLACE_EXISTING) }
|
||||
}
|
||||
|
||||
private fun copyResFiles(overridesPath: String, defaultResPath: String, source: ThemeSourceData, projectRootPath: String): Any {
|
||||
private fun copyResFiles(resOverridePath: String, defaultResPath: String, source: ThemeSourceData, projectRootPath: String): Any {
|
||||
// check if res override exists if not copy default res
|
||||
val resOverride = File("$overridesPath/res")
|
||||
val resOverride = File(resOverridePath)
|
||||
return if (resOverride.exists())
|
||||
resOverride.copyRecursively(File("$projectRootPath/res"))
|
||||
else
|
||||
|
|