2021-02-06 22:32:04 +00:00
|
|
|
plugins {
|
|
|
|
id("com.android.library")
|
|
|
|
kotlin("android")
|
|
|
|
}
|
|
|
|
|
|
|
|
android {
|
|
|
|
compileSdkVersion(Config.compileSdk)
|
|
|
|
buildToolsVersion(Config.buildTools)
|
|
|
|
|
|
|
|
defaultConfig {
|
|
|
|
minSdkVersion(29)
|
|
|
|
targetSdkVersion(Config.targetSdk)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
}
|
|
|
|
|
|
|
|
// dependencies
|
|
|
|
apply("$rootDir/common-dependencies.gradle")
|
|
|
|
|
2021-02-07 19:30:39 +00:00
|
|
|
tasks {
|
|
|
|
val runAllGenerators by registering {
|
|
|
|
doLast {
|
|
|
|
val isWindows = System.getProperty("os.name").toString().toLowerCase().contains("win")
|
|
|
|
val classPath = (configurations.debugCompileOnly.get().asFileTree.toList() +
|
2021-02-06 22:32:04 +00:00
|
|
|
listOf(
|
2021-02-07 19:30:39 +00:00
|
|
|
configurations.androidApis.get().asFileTree.first().absolutePath, // android.jar path
|
|
|
|
"$projectDir/build/intermediates/aar_main_jar/debug/classes.jar" // jar made from this module
|
2021-02-06 22:32:04 +00:00
|
|
|
))
|
|
|
|
.joinToString(if (isWindows) ";" else ":")
|
2021-02-07 19:30:39 +00:00
|
|
|
val javaPath = "${System.getProperty("java.home")}/bin/java"
|
2021-02-06 22:32:04 +00:00
|
|
|
|
2021-02-07 19:30:39 +00:00
|
|
|
val mainClass =
|
|
|
|
"eu.kanade.tachiyomi.multisrc.GeneratorMainKt" // Main class we want to execute
|
2021-02-06 22:32:04 +00:00
|
|
|
|
2021-02-07 19:30:39 +00:00
|
|
|
val javaCommand = if (isWindows) {
|
|
|
|
"\"$javaPath\" -classpath $classPath $mainClass".replace("/", "\\")
|
|
|
|
} else {
|
|
|
|
"$javaPath -classpath $classPath $mainClass"
|
|
|
|
}
|
|
|
|
val javaProcess = Runtime.getRuntime().exec(javaCommand)
|
|
|
|
val exitCode = javaProcess.waitFor()
|
|
|
|
if (exitCode != 0) {
|
|
|
|
throw Exception("Java process failed with exit code: $exitCode")
|
|
|
|
}
|
2021-02-06 22:32:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|