package generator import java.io.File /** * Finds all themes and creates an Intellij Idea run configuration for their generators * Should be run after creation/deletion of each theme */ fun main(args: Array) { val userDir = System.getProperty("user.dir")!! val sourcesDirPath = "$userDir/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc" val sourcesDir = File(sourcesDirPath) // cleanup from past runs File("$userDir/.run").apply { if (exists()) deleteRecursively() mkdirs() } // find all theme packages sourcesDir.list()!! .filter { File(sourcesDir, it).isDirectory } .forEach { themeSource -> // Find all XxxGenerator.kt files File("$sourcesDirPath/$themeSource").list()!! .filter { it.endsWith("Generator.kt") } .map { it.substringBefore(".kt") } .forEach { generatorClass -> val file = File("$userDir/.run/$generatorClass.run.xml") val intellijConfStr = """ """.trimIndent() file.writeText(intellijConfStr) // Find Java class and extract method lists Class.forName("eu/kanade/tachiyomi/multisrc/$themeSource/$generatorClass".replace("/", ".").substringBefore(".kt")) .methods .find { it.name == "main" } } } }