Commit 27819d73 authored by Him188's avatar Him188

Better Android SDK checking

parent ddeb174a
......@@ -15,6 +15,15 @@ buildscript {
}
}
def keyProps = new Properties()
def keyFile = file("local.properties")
if (keyFile.exists()) keyFile.withInputStream { keyProps.load(it) }
if (!keyProps.getProperty("sdk.dir", "").isEmpty()) {
project.ext.set("isAndroidSDKAvailable", true)
} else {
project.ext.set("isAndroidSDKAvailable", false)
}
allprojects {
group = "net.mamoe"
version = getProperty("mirai_version")
......
@file:Suppress("UNUSED_VARIABLE")
import java.util.Properties
plugins {
kotlin("multiplatform")
......@@ -32,11 +31,8 @@ description = "QQ protocol library"
version = rootProject.ext.get("mirai_version")!!.toString()
kotlin {
val keyProps = Properties()
val keyFile = file("../local.properties")
if (keyFile.exists()) keyProps.load(keyFile.inputStream())
if (keyProps.getProperty("sdk.dir", "").isNotEmpty()) {
val isAndroidSDKAvailable: Boolean by project
if (isAndroidSDKAvailable) {
android("android") {
publishAllLibraryVariants()
project.android {
......@@ -57,7 +53,13 @@ kotlin {
println(
"""Android SDK 可能未安装.
$name 的 Android 目标编译将不会进行.
这不会影响 Android 以外的平台的编译, 因此 JVM 等平台相关的编译和测试均能正常进行.
这不会影响 Android 以外的平台的编译.
""".trimIndent()
)
println(
"""Android SDK might not be installed.
Android target of $name will not be compiled.
It does no influence on the compilation of other platforms.
""".trimIndent()
)
}
......
@file:Suppress("UNUSED_VARIABLE")
import java.util.Properties
plugins {
kotlin("multiplatform")
......@@ -32,10 +31,8 @@ description = "QQ protocol library"
version = rootProject.ext.get("mirai_version")!!.toString()
kotlin {
val keyProps = Properties()
val keyFile = file("../local.properties")
if (keyFile.exists()) keyProps.load(keyFile.inputStream())
if (keyProps.getProperty("sdk.dir", "").isNotEmpty()) {
val isAndroidSDKAvailable: Boolean by project
if (isAndroidSDKAvailable) {
android("android") {
publishAllLibraryVariants()
project.android {
......@@ -56,7 +53,13 @@ kotlin {
println(
"""Android SDK 可能未安装.
$name 的 Android 目标编译将不会进行.
这不会影响 Android 以外的平台的编译, 因此 JVM 等平台相关的编译和测试均能正常进行.
这不会影响 Android 以外的平台的编译.
""".trimIndent()
)
println(
"""Android SDK might not be installed.
Android target of $name will not be compiled.
It does no influence on the compilation of other platforms.
""".trimIndent()
)
}
......
@file:Suppress("UNUSED_VARIABLE")
import java.util.*
plugins {
kotlin("multiplatform")
id("kotlinx-atomicfu")
......@@ -32,10 +30,8 @@ fun ktor(id: String, version: String) = "io.ktor:ktor-$id:$version"
description = "QQ protocol library"
kotlin {
val keyProps = Properties()
val keyFile = file("../local.properties")
if (keyFile.exists()) keyProps.load(keyFile.inputStream())
if (keyProps.getProperty("sdk.dir", "").isNotEmpty()) {
val isAndroidSDKAvailable: Boolean by project
if (isAndroidSDKAvailable) {
android("android") {
publishAllLibraryVariants()
project.android {
......@@ -56,7 +52,13 @@ kotlin {
println(
"""Android SDK 可能未安装.
$name 的 Android 目标编译将不会进行.
这不会影响 Android 以外的平台的编译, 因此 JVM 等平台相关的编译和测试均能正常进行.
这不会影响 Android 以外的平台的编译.
""".trimIndent()
)
println(
"""Android SDK might not be installed.
Android target of $name will not be compiled.
It does no influence on the compilation of other platforms.
""".trimIndent()
)
}
......
......@@ -21,6 +21,17 @@ pluginManagement {
rootProject.name = 'mirai'
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 的加载 ")
println("Android SDK might not be installed. \nModule `mirai-demo-android` will not be included, but other demos will not be influenced")
}
include(':mirai-core')
include(':mirai-core-timpc')
include(':mirai-core-qqandroid')
......@@ -32,16 +43,6 @@ include(':mirai-demos:mirai-demo-1')
include(':mirai-demos:mirai-demo-gentleman')
include(':mirai-demos')
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) {
include(':mirai-debug')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment