mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-03 15:10:14 +08:00
buildscript: fix task not found errors when android sdk not available (#1161)
* buildscript: fix task not found errors when android sdk not available * fix: this shadowed by run * cleanup: code style * improve: avoid breaking index map
This commit is contained in:
parent
45294e1538
commit
21e8852e0f
@ -42,12 +42,14 @@ object CompiledCodeVerify {
|
||||
sequenceOf("kotlin/main")
|
||||
}.map { sequenceOf(project.buildDir.resolve("classes").resolve(it)) }
|
||||
|
||||
private fun getLibraries(project: Project, info: ProjectInfo): Sequence<Sequence<File>> =
|
||||
private fun getLibraries(project: Project, info: ProjectInfo): Sequence<Sequence<File>?> =
|
||||
if (info.isMpp) {
|
||||
sequenceOf("jvmCompileClasspath", "androidCompileClasspath")
|
||||
} else {
|
||||
sequenceOf("compileClasspath")
|
||||
}.map { project.configurations.getByName(it).files.asSequence() }
|
||||
}.map {
|
||||
project.configurations.findByName(it)?.files?.asSequence()
|
||||
}
|
||||
|
||||
fun Project.registerVerifyTask(taskName: String, action: VerifyAction) {
|
||||
|
||||
@ -55,15 +57,21 @@ object CompiledCodeVerify {
|
||||
|
||||
tasks.register(taskName) {
|
||||
group = VERIFICATION_GROUP_NAME
|
||||
mustRunAfter(*projectInfo.compileTasks)
|
||||
projectInfo.compileTasks.forEach {
|
||||
tasks.findByPath(it)?.also { compileTask ->
|
||||
mustRunAfter(compileTask)
|
||||
}
|
||||
}
|
||||
|
||||
doFirst {
|
||||
getCompiledClassesPath(project, projectInfo).zip(getLibraries(project, projectInfo))
|
||||
.forEach { (compiledClasses, libraries) ->
|
||||
if (libraries != null) {
|
||||
action(compiledClasses, libraries)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named("check").configure { dependsOn(taskName) }
|
||||
rootProject.tasks.getByName(RUN_ALL_VERITY_TASK_NAME).dependsOn(":$name:$taskName")
|
||||
|
@ -101,7 +101,8 @@ kotlin {
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("checkAndroidApiLevel") {
|
||||
if (isAndroidSDKAvailable) {
|
||||
tasks.register("checkAndroidApiLevel") {
|
||||
doFirst {
|
||||
analyzes.AndroidApiLevelCheck.check(
|
||||
buildDir.resolve("classes/kotlin/android/main"),
|
||||
@ -111,8 +112,9 @@ tasks.register("checkAndroidApiLevel") {
|
||||
}
|
||||
group = "verification"
|
||||
this.mustRunAfter("androidMainClasses")
|
||||
}
|
||||
tasks.getByName("androidTest").dependsOn("checkAndroidApiLevel")
|
||||
}
|
||||
tasks.getByName("androidTest").dependsOn("checkAndroidApiLevel")
|
||||
|
||||
fun org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler.implementation1(dependencyNotation: String) =
|
||||
implementation(dependencyNotation) {
|
||||
|
@ -89,7 +89,8 @@ kotlin {
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("checkAndroidApiLevel") {
|
||||
if (isAndroidSDKAvailable) {
|
||||
tasks.register("checkAndroidApiLevel") {
|
||||
doFirst {
|
||||
analyzes.AndroidApiLevelCheck.check(
|
||||
buildDir.resolve("classes/kotlin/android/main"),
|
||||
@ -99,8 +100,9 @@ tasks.register("checkAndroidApiLevel") {
|
||||
}
|
||||
group = "verification"
|
||||
this.mustRunAfter("androidMainClasses")
|
||||
}
|
||||
tasks.getByName("androidTest").dependsOn("checkAndroidApiLevel")
|
||||
}
|
||||
tasks.getByName("androidTest").dependsOn("checkAndroidApiLevel")
|
||||
|
||||
fun org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler.implementation1(dependencyNotation: String) =
|
||||
implementation(dependencyNotation) {
|
||||
|
@ -114,7 +114,8 @@ kotlin {
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("checkAndroidApiLevel") {
|
||||
if (isAndroidSDKAvailable) {
|
||||
tasks.register("checkAndroidApiLevel") {
|
||||
doFirst {
|
||||
analyzes.AndroidApiLevelCheck.check(
|
||||
buildDir.resolve("classes/kotlin/android/main"),
|
||||
@ -124,8 +125,9 @@ tasks.register("checkAndroidApiLevel") {
|
||||
}
|
||||
group = "verification"
|
||||
this.mustRunAfter("androidMainClasses")
|
||||
}
|
||||
tasks.getByName("androidTest").dependsOn("checkAndroidApiLevel")
|
||||
}
|
||||
tasks.getByName("androidTest").dependsOn("checkAndroidApiLevel")
|
||||
|
||||
fun org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler.implementation1(dependencyNotation: String) =
|
||||
implementation(dependencyNotation) {
|
||||
|
Loading…
Reference in New Issue
Block a user