mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-04 22:42:27 +08:00
Ignore Android targets when Android SDK is not installed
This commit is contained in:
parent
10d813ce21
commit
ddeb174aff
@ -1,4 +1,5 @@
|
||||
@file:Suppress("UNUSED_VARIABLE")
|
||||
import java.util.Properties
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
@ -31,21 +32,34 @@ description = "QQ protocol library"
|
||||
version = rootProject.ext.get("mirai_version")!!.toString()
|
||||
|
||||
kotlin {
|
||||
android("android") {
|
||||
publishAllLibraryVariants()
|
||||
project.android {
|
||||
compileSdkVersion(29)
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion(15)
|
||||
val keyProps = Properties()
|
||||
val keyFile = file("../local.properties")
|
||||
if (keyFile.exists()) keyProps.load(keyFile.inputStream())
|
||||
if (keyProps.getProperty("sdk.dir", "").isNotEmpty()) {
|
||||
android("android") {
|
||||
publishAllLibraryVariants()
|
||||
project.android {
|
||||
compileSdkVersion(29)
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion(15)
|
||||
}
|
||||
|
||||
// sourceSets.filterIsInstance(com.android.build.gradle.api.AndroidSourceSet::class.java).forEach {
|
||||
// it.manifest.srcFile("src/androidMain/res/AndroidManifest.xml")
|
||||
// it.res.srcDirs(file("src/androidMain/res"))
|
||||
// }
|
||||
//(sourceSets["main"] as AndroidSourceSet).java.srcDirs(file("src/androidMain/kotlin"))
|
||||
}
|
||||
|
||||
// sourceSets.filterIsInstance(com.android.build.gradle.api.AndroidSourceSet::class.java).forEach {
|
||||
// it.manifest.srcFile("src/androidMain/res/AndroidManifest.xml")
|
||||
// it.res.srcDirs(file("src/androidMain/res"))
|
||||
// }
|
||||
//(sourceSets["main"] as AndroidSourceSet).java.srcDirs(file("src/androidMain/kotlin"))
|
||||
}
|
||||
} else {
|
||||
println(
|
||||
"""Android SDK 可能未安装.
|
||||
$name 的 Android 目标编译将不会进行.
|
||||
这不会影响 Android 以外的平台的编译, 因此 JVM 等平台相关的编译和测试均能正常进行.
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
jvm("jvm") {
|
||||
|
@ -1,4 +1,5 @@
|
||||
@file:Suppress("UNUSED_VARIABLE")
|
||||
import java.util.Properties
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
@ -31,21 +32,33 @@ description = "QQ protocol library"
|
||||
version = rootProject.ext.get("mirai_version")!!.toString()
|
||||
|
||||
kotlin {
|
||||
android("android") {
|
||||
publishAllLibraryVariants()
|
||||
project.android {
|
||||
compileSdkVersion(29)
|
||||
val keyProps = Properties()
|
||||
val keyFile = file("../local.properties")
|
||||
if (keyFile.exists()) keyProps.load(keyFile.inputStream())
|
||||
if (keyProps.getProperty("sdk.dir", "").isNotEmpty()) {
|
||||
android("android") {
|
||||
publishAllLibraryVariants()
|
||||
project.android {
|
||||
compileSdkVersion(29)
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion(15)
|
||||
defaultConfig {
|
||||
minSdkVersion(15)
|
||||
}
|
||||
|
||||
// sourceSets.filterIsInstance(com.android.build.gradle.api.AndroidSourceSet::class.java).forEach {
|
||||
// it.manifest.srcFile("src/androidMain/res/AndroidManifest.xml")
|
||||
// it.res.srcDirs(file("src/androidMain/res"))
|
||||
// }
|
||||
//(sourceSets["main"] as AndroidSourceSet).java.srcDirs(file("src/androidMain/kotlin"))
|
||||
}
|
||||
|
||||
// sourceSets.filterIsInstance(com.android.build.gradle.api.AndroidSourceSet::class.java).forEach {
|
||||
// it.manifest.srcFile("src/androidMain/res/AndroidManifest.xml")
|
||||
// it.res.srcDirs(file("src/androidMain/res"))
|
||||
// }
|
||||
//(sourceSets["main"] as AndroidSourceSet).java.srcDirs(file("src/androidMain/kotlin"))
|
||||
}
|
||||
} else {
|
||||
println(
|
||||
"""Android SDK 可能未安装.
|
||||
$name 的 Android 目标编译将不会进行.
|
||||
这不会影响 Android 以外的平台的编译, 因此 JVM 等平台相关的编译和测试均能正常进行.
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
jvm("jvm") {
|
||||
|
@ -1,5 +1,7 @@
|
||||
@file:Suppress("UNUSED_VARIABLE")
|
||||
|
||||
import java.util.*
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
id("kotlinx-atomicfu")
|
||||
@ -30,21 +32,33 @@ fun ktor(id: String, version: String) = "io.ktor:ktor-$id:$version"
|
||||
description = "QQ protocol library"
|
||||
|
||||
kotlin {
|
||||
android("android") {
|
||||
publishAllLibraryVariants()
|
||||
project.android {
|
||||
compileSdkVersion(29)
|
||||
val keyProps = Properties()
|
||||
val keyFile = file("../local.properties")
|
||||
if (keyFile.exists()) keyProps.load(keyFile.inputStream())
|
||||
if (keyProps.getProperty("sdk.dir", "").isNotEmpty()) {
|
||||
android("android") {
|
||||
publishAllLibraryVariants()
|
||||
project.android {
|
||||
compileSdkVersion(29)
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion(15)
|
||||
defaultConfig {
|
||||
minSdkVersion(15)
|
||||
}
|
||||
|
||||
// sourceSets.filterIsInstance(com.android.build.gradle.api.AndroidSourceSet::class.java).forEach {
|
||||
// it.manifest.srcFile("src/androidMain/res/AndroidManifest.xml")
|
||||
// it.res.srcDirs(file("src/androidMain/res"))
|
||||
// }
|
||||
//(sourceSets["main"] as AndroidSourceSet).java.srcDirs(file("src/androidMain/kotlin"))
|
||||
}
|
||||
|
||||
// sourceSets.filterIsInstance(com.android.build.gradle.api.AndroidSourceSet::class.java).forEach {
|
||||
// it.manifest.srcFile("src/androidMain/res/AndroidManifest.xml")
|
||||
// it.res.srcDirs(file("src/androidMain/res"))
|
||||
// }
|
||||
//(sourceSets["main"] as AndroidSourceSet).java.srcDirs(file("src/androidMain/kotlin"))
|
||||
}
|
||||
} else {
|
||||
println(
|
||||
"""Android SDK 可能未安装.
|
||||
$name 的 Android 目标编译将不会进行.
|
||||
这不会影响 Android 以外的平台的编译, 因此 JVM 等平台相关的编译和测试均能正常进行.
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
jvm("jvm") {
|
||||
|
@ -31,7 +31,16 @@ include(':mirai-api-http')
|
||||
include(':mirai-demos:mirai-demo-1')
|
||||
include(':mirai-demos:mirai-demo-gentleman')
|
||||
include(':mirai-demos')
|
||||
include(':mirai-demos:mirai-demo-android')
|
||||
|
||||
def keyProps = new Properties()
|
||||
def keyFile = file("local.properties")
|
||||
if (keyFile.exists()) keyFile.withInputStream { keyProps.load(it) }
|
||||
if (!keyProps.getProperty("sdk.dir", "").isEmpty()) {
|
||||
include(':mirai-demos:mirai-demo-android')
|
||||
project(':mirai-demos:mirai-demo-android').projectDir = file('mirai-demos/mirai-demo-android')
|
||||
} else {
|
||||
println("Android SDK 可能未安装. \n将不会加载模块 `mirai-demo-android`, 但这并不影响其他 demo 的加载 ")
|
||||
}
|
||||
|
||||
def javaVersion = System.getProperty("java.version")
|
||||
if (javaVersion.substring(0, javaVersion.indexOf(".")).toInteger() >= 11) {
|
||||
@ -42,6 +51,5 @@ if (javaVersion.substring(0, javaVersion.indexOf(".")).toInteger() >= 11) {
|
||||
|
||||
project(':mirai-demos:mirai-demo-1').projectDir = file('mirai-demos/mirai-demo-1')
|
||||
project(':mirai-demos:mirai-demo-gentleman').projectDir = file('mirai-demos/mirai-demo-gentleman')
|
||||
project(':mirai-demos:mirai-demo-android').projectDir = file('mirai-demos/mirai-demo-android')
|
||||
|
||||
enableFeaturePreview('GRADLE_METADATA')
|
Loading…
Reference in New Issue
Block a user