2021-04-05 14:37:29 +00:00
|
|
|
import java.io.BufferedReader
|
|
|
|
import java.io.InputStreamReader
|
|
|
|
|
2021-02-06 22:32:04 +00:00
|
|
|
plugins {
|
|
|
|
id("com.android.library")
|
|
|
|
kotlin("android")
|
2021-12-12 23:04:11 +00:00
|
|
|
id("kotlinx-serialization")
|
2021-02-06 22:32:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
android {
|
2022-06-05 14:47:25 +00:00
|
|
|
compileSdk = AndroidConfig.compileSdk
|
2021-02-06 22:32:04 +00:00
|
|
|
|
|
|
|
defaultConfig {
|
2022-06-05 14:47:25 +00:00
|
|
|
minSdk = 29
|
|
|
|
targetSdk = AndroidConfig.targetSdk
|
2021-02-06 22:32:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
}
|
|
|
|
|
2022-06-05 13:49:54 +00:00
|
|
|
configurations {
|
|
|
|
compileOnly {
|
|
|
|
isCanBeResolved = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-28 12:25:23 +00:00
|
|
|
dependencies {
|
|
|
|
compileOnly(libs.bundles.common)
|
|
|
|
}
|
2021-02-06 22:32:04 +00:00
|
|
|
|
2021-02-07 19:30:39 +00:00
|
|
|
tasks {
|
2021-03-09 23:02:17 +00:00
|
|
|
val generateExtensions by registering {
|
2021-02-07 19:30:39 +00:00
|
|
|
doLast {
|
|
|
|
val isWindows = System.getProperty("os.name").toString().toLowerCase().contains("win")
|
2022-06-05 13:49:54 +00:00
|
|
|
var classPath = (
|
|
|
|
configurations.compileOnly.get().asFileTree.toList() +
|
2022-02-28 12:25:23 +00:00
|
|
|
listOf(
|
2021-08-22 15:29:08 +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
|
2022-02-28 12:25:23 +00:00
|
|
|
))
|
2021-02-06 22:32:04 +00:00
|
|
|
.joinToString(if (isWindows) ";" else ":")
|
2021-04-05 14:37:29 +00:00
|
|
|
|
|
|
|
var javaPath = "${System.getProperty("java.home")}/bin/java"
|
2021-02-06 22:32:04 +00:00
|
|
|
|
2021-03-09 23:02:17 +00:00
|
|
|
val mainClass = "generator.GeneratorMainKt" // Main class we want to execute
|
2021-02-06 22:32:04 +00:00
|
|
|
|
2021-04-05 14:37:29 +00:00
|
|
|
if (isWindows) {
|
|
|
|
classPath = classPath.replace("/", "\\")
|
|
|
|
javaPath = javaPath.replace("/", "\\")
|
|
|
|
}
|
|
|
|
|
|
|
|
val javaProcess = ProcessBuilder()
|
|
|
|
.directory(null).command(javaPath, "-classpath", classPath, mainClass)
|
|
|
|
.redirectErrorStream(true).start()
|
|
|
|
|
|
|
|
val inputStreamReader = InputStreamReader(javaProcess.inputStream)
|
|
|
|
val bufferedReader = BufferedReader(inputStreamReader)
|
|
|
|
|
|
|
|
var s: String?
|
|
|
|
while (bufferedReader.readLine().also { s = it } != null) {
|
|
|
|
logger.info(s)
|
2021-02-07 19:30:39 +00:00
|
|
|
}
|
2021-04-05 14:37:29 +00:00
|
|
|
|
|
|
|
bufferedReader.close()
|
|
|
|
inputStreamReader.close()
|
|
|
|
|
2021-02-07 19:30:39 +00:00
|
|
|
val exitCode = javaProcess.waitFor()
|
|
|
|
if (exitCode != 0) {
|
|
|
|
throw Exception("Java process failed with exit code: $exitCode")
|
|
|
|
}
|
2021-02-06 22:32:04 +00:00
|
|
|
}
|
2021-08-22 15:29:08 +00:00
|
|
|
dependsOn("ktFormat", "ktLint", "assembleDebug")
|
|
|
|
}
|
|
|
|
|
|
|
|
register<org.jmailen.gradle.kotlinter.tasks.LintTask>("ktLint") {
|
|
|
|
source(files("src", "overrides"))
|
|
|
|
}
|
|
|
|
|
|
|
|
register<org.jmailen.gradle.kotlinter.tasks.FormatTask>("ktFormat") {
|
|
|
|
source(files("src", "overrides"))
|
2021-02-06 22:32:04 +00:00
|
|
|
}
|
|
|
|
}
|