[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)
|
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("""
|
gradle.writeText("""
|
||||||
// THIS FILE IS AUTO-GENERATED; DO NOT EDIT
|
// THIS FILE IS AUTO-GENERATED; DO NOT EDIT
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
@ -64,7 +69,8 @@ interface ThemeSourceGenerator {
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
${if (source.isNsfw) "containsNsfw = true\n" else ""}
|
${if (source.isNsfw) "containsNsfw = true\n" else ""}
|
||||||
}
|
}
|
||||||
|
$defaultAdditionalGradleText
|
||||||
|
$additionalGradleOverrideText
|
||||||
apply from: "${'$'}rootDir/common.gradle"
|
apply from: "${'$'}rootDir/common.gradle"
|
||||||
""".trimIndent())
|
""".trimIndent())
|
||||||
}
|
}
|
||||||
|
@ -85,10 +91,12 @@ interface ThemeSourceGenerator {
|
||||||
val projectRootPath = "$userDir/generated-src/${pkgNameSuffix(source, "/")}"
|
val projectRootPath = "$userDir/generated-src/${pkgNameSuffix(source, "/")}"
|
||||||
val projectSrcPath = "$projectRootPath/src/eu/kanade/tachiyomi/extension/${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 overridesPath = "$userDir/multisrc/overrides/$themePkg/${source.pkgName}" // userDir = tachiyomi-extensions project root path
|
||||||
val defaultResPath = "$userDir/multisrc/overrides/$themePkg/default_res"
|
val defaultResPath = "$userDir/multisrc/overrides/$themePkg/default/res"
|
||||||
val resOverridesPath = "$overridesPath/res"
|
val defaultAdditionalGradlePath = "$userDir/multisrc/overrides/$themePkg/default/additional.gradle.kts"
|
||||||
val srcOverridesPath = "$overridesPath/src"
|
val resOverridePath = "$overridesPath/res"
|
||||||
val manifestOverridesPath = "$overridesPath/AndroidManifest.xml"
|
val srcOverridePath = "$overridesPath/src"
|
||||||
|
val manifestOverridePath = "$overridesPath/AndroidManifest.xml"
|
||||||
|
val additionalGradleOverridePath = "$overridesPath/additional.gradle.kts"
|
||||||
val projectGradleFile = File("$projectRootPath/build.gradle")
|
val projectGradleFile = File("$projectRootPath/build.gradle")
|
||||||
val projectAndroidManifestFile = File("$projectRootPath/AndroidManifest.xml")
|
val projectAndroidManifestFile = File("$projectRootPath/AndroidManifest.xml")
|
||||||
|
|
||||||
|
@ -99,13 +107,13 @@ interface ThemeSourceGenerator {
|
||||||
// remove everything from past runs
|
// remove everything from past runs
|
||||||
cleanDirectory(projectRootFile)
|
cleanDirectory(projectRootFile)
|
||||||
|
|
||||||
writeGradle(projectGradleFile, source, themePkg, baseVersionCode)
|
writeGradle(projectGradleFile, source, themePkg, baseVersionCode, defaultAdditionalGradlePath, additionalGradleOverridePath)
|
||||||
writeAndroidManifest(projectAndroidManifestFile, manifestOverridesPath)
|
writeAndroidManifest(projectAndroidManifestFile, manifestOverridePath)
|
||||||
|
|
||||||
writeSourceClasses(projectSrcPath, srcOverridesPath, source, themePkg, themeClass)
|
writeSourceClasses(projectSrcPath, srcOverridePath, source, themePkg, themeClass)
|
||||||
copyThemeClasses(userDir, themePkg, projectRootPath)
|
copyThemeClasses(userDir, themePkg, projectRootPath)
|
||||||
|
|
||||||
copyResFiles(overridesPath, defaultResPath, source, projectRootPath)
|
copyResFiles(resOverridePath, defaultResPath, source, projectRootPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,13 +126,13 @@ interface ThemeSourceGenerator {
|
||||||
themeDestFile.mkdirs()
|
themeDestFile.mkdirs()
|
||||||
|
|
||||||
themeSrcFile.list()!!
|
themeSrcFile.list()!!
|
||||||
.filter { it.endsWith(".kt") && !it.endsWith("Generator.kt") }
|
.filter { it.endsWith(".kt") && !it.endsWith("Generator.kt") }
|
||||||
.forEach { Files.copy(File("$themeSrcPath/$it").toPath(), File("$themeDestPath/$it").toPath(), StandardCopyOption.REPLACE_EXISTING) }
|
.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
|
// check if res override exists if not copy default res
|
||||||
val resOverride = File("$overridesPath/res")
|
val resOverride = File(resOverridePath)
|
||||||
return if (resOverride.exists())
|
return if (resOverride.exists())
|
||||||
resOverride.copyRecursively(File("$projectRootPath/res"))
|
resOverride.copyRecursively(File("$projectRootPath/res"))
|
||||||
else
|
else
|
||||||
|
@ -205,23 +213,23 @@ sealed class ThemeSourceData {
|
||||||
abstract val overrideVersionCode: Int
|
abstract val overrideVersionCode: Int
|
||||||
|
|
||||||
data class SingleLang(
|
data class SingleLang(
|
||||||
override val name: String,
|
override val name: String,
|
||||||
override val baseUrl: String,
|
override val baseUrl: String,
|
||||||
val lang: String,
|
val lang: String,
|
||||||
override val isNsfw: Boolean = false,
|
override val isNsfw: Boolean = false,
|
||||||
override val className: String = name.replace(" ", ""),
|
override val className: String = name.replace(" ", ""),
|
||||||
override val pkgName: String = className.toLowerCase(Locale.ENGLISH),
|
override val pkgName: String = className.toLowerCase(Locale.ENGLISH),
|
||||||
override val overrideVersionCode: Int = 0,
|
override val overrideVersionCode: Int = 0,
|
||||||
) : ThemeSourceData()
|
) : ThemeSourceData()
|
||||||
|
|
||||||
data class MultiLang(
|
data class MultiLang(
|
||||||
override val name: String,
|
override val name: String,
|
||||||
override val baseUrl: String,
|
override val baseUrl: String,
|
||||||
val langs: List<String>,
|
val langs: List<String>,
|
||||||
override val isNsfw: Boolean = false,
|
override val isNsfw: Boolean = false,
|
||||||
override val className: String = name.replace(" ", "") + "Factory",
|
override val className: String = name.replace(" ", "") + "Factory",
|
||||||
override val pkgName: String = className.substringBefore("Factory").toLowerCase(Locale.ENGLISH),
|
override val pkgName: String = className.substringBefore("Factory").toLowerCase(Locale.ENGLISH),
|
||||||
override val overrideVersionCode: Int = 0,
|
override val overrideVersionCode: Int = 0,
|
||||||
) : ThemeSourceData()
|
) : ThemeSourceData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|