mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-27 08:50:15 +08:00
[build] Binary validator: support Android
This commit is contained in:
parent
178ca6c1b5
commit
438b58c717
@ -68,7 +68,10 @@ object BinaryCompatibilityConfigurator {
|
|||||||
dir.resolve("build.gradle.kts").writeTextIfNeeded(
|
dir.resolve("build.gradle.kts").writeTextIfNeeded(
|
||||||
applyTemplate(
|
applyTemplate(
|
||||||
project.path,
|
project.path,
|
||||||
if (targetName == null) "classes/kotlin/main" else "classes/kotlin/$targetName/main"
|
listOfNotNull(
|
||||||
|
if (targetName == null) "classes/kotlin/main" else "classes/kotlin/$targetName/main",
|
||||||
|
if (targetName?.contains("android") == true) "tmp/kotlin-classes/debug" else ""
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
dir.resolve(".gitignore").writeTextIfNeeded(
|
dir.resolve(".gitignore").writeTextIfNeeded(
|
||||||
@ -80,7 +83,12 @@ object BinaryCompatibilityConfigurator {
|
|||||||
findProject(getValidatorDir(dir))
|
findProject(getValidatorDir(dir))
|
||||||
?.afterEvaluate {
|
?.afterEvaluate {
|
||||||
if (targetName == null) {
|
if (targetName == null) {
|
||||||
tasks.findByName("apiBuild")?.dependsOn(project.tasks.getByName("jar"))
|
tasks.findByName("apiBuild")?.dependsOn(
|
||||||
|
*listOfNotNull(
|
||||||
|
project.tasks.getByName("jar"),
|
||||||
|
project.tasks.findByName("compileDebugKotlinAndroid")
|
||||||
|
).toTypedArray()
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
tasks.findByName("apiBuild")?.dependsOn(
|
tasks.findByName("apiBuild")?.dependsOn(
|
||||||
if (targetName.contains("android")) {
|
if (targetName.contains("android")) {
|
||||||
@ -94,13 +102,13 @@ object BinaryCompatibilityConfigurator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun applyTemplate(projectPath: String, buildDir: String): String {
|
fun applyTemplate(projectPath: String, buildDirs: List<String>): String {
|
||||||
return this::class.java.classLoader
|
return this::class.java.classLoader
|
||||||
.getResourceAsStream("binary-compatibility-validator-build.txt")!!
|
.getResourceAsStream("binary-compatibility-validator-build.txt")!!
|
||||||
.useToRun { readBytes() }
|
.useToRun { readBytes() }
|
||||||
.decodeToString()
|
.decodeToString()
|
||||||
.replace("$\$PROJECT_PATH$$", projectPath)
|
.replace("$\$PROJECT_PATH$$", projectPath)
|
||||||
.replace("$\$BUILD_DIR$$", buildDir)
|
.replace("$\$BUILD_DIR$$", buildDirs.joinToString("\n"))
|
||||||
.replace("$\$PLUGIN_VERSION$$", Versions.binaryValidator)
|
.replace("$\$PLUGIN_VERSION$$", Versions.binaryValidator)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,12 @@ plugins {
|
|||||||
description = "Binary compatibility validator for project $$PROJECT_PATH$$"
|
description = "Binary compatibility validator for project $$PROJECT_PATH$$"
|
||||||
|
|
||||||
tasks.withType(kotlinx.validation.KotlinApiBuildTask::class) {
|
tasks.withType(kotlinx.validation.KotlinApiBuildTask::class) {
|
||||||
|
val paths = """
|
||||||
|
$$BUILD_DIR$$
|
||||||
|
"""
|
||||||
|
.lines().filter { it.isNotBlank() }.map { project("$$PROJECT_PATH$$").buildDir.resolve(it.trim()) }
|
||||||
inputClassesDirs =
|
inputClassesDirs =
|
||||||
files(inputClassesDirs.files, project("$$PROJECT_PATH$$").buildDir.resolve("$$BUILD_DIR$$"))
|
files(inputClassesDirs.files, *paths.toTypedArray())
|
||||||
}
|
}
|
||||||
|
|
||||||
apiValidation {
|
apiValidation {
|
||||||
|
Loading…
Reference in New Issue
Block a user