mirror of
https://github.com/mamoe/mirai.git
synced 2025-04-02 21:30:18 +08:00
[build] Do not apply Android-relevant plugins if Android target is not enabled
This commit is contained in:
parent
438b58c717
commit
2ef89d2b3f
@ -43,6 +43,7 @@ plugins {
|
|||||||
id("com.gradle.plugin-publish") version "1.1.0" apply false
|
id("com.gradle.plugin-publish") version "1.1.0" apply false
|
||||||
id("org.jetbrains.kotlinx.binary-compatibility-validator") version Versions.binaryValidator apply false
|
id("org.jetbrains.kotlinx.binary-compatibility-validator") version Versions.binaryValidator apply false
|
||||||
id("com.android.library") apply false
|
id("com.android.library") apply false
|
||||||
|
id("de.mannodermaus.android-junit5") version "1.8.2.1" apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
osDetector = osdetector
|
osDetector = osdetector
|
||||||
|
@ -34,7 +34,7 @@ val ENABLE_ANDROID_INSTRUMENTED_TESTS by projectLazy {
|
|||||||
val Project.usingAndroidInstrumentedTests
|
val Project.usingAndroidInstrumentedTests
|
||||||
get() = ENABLE_ANDROID_INSTRUMENTED_TESTS && isAndroidSdkAvailable
|
get() = ENABLE_ANDROID_INSTRUMENTED_TESTS && isAndroidSdkAvailable
|
||||||
|
|
||||||
fun Project.configureAndroidTarget() {
|
fun Project.configureAndroidTarget(androidNamespace: String) {
|
||||||
if (ENABLE_ANDROID_INSTRUMENTED_TESTS && !isAndroidSdkAvailable) {
|
if (ENABLE_ANDROID_INSTRUMENTED_TESTS && !isAndroidSdkAvailable) {
|
||||||
if (!ProjectAndroidSdkAvailability.tryFixAndroidSdk(this)) {
|
if (!ProjectAndroidSdkAvailability.tryFixAndroidSdk(this)) {
|
||||||
printAndroidNotInstalled()
|
printAndroidNotInstalled()
|
||||||
@ -43,7 +43,7 @@ fun Project.configureAndroidTarget() {
|
|||||||
|
|
||||||
extensions.getByType(KotlinMultiplatformExtension::class.java).apply {
|
extensions.getByType(KotlinMultiplatformExtension::class.java).apply {
|
||||||
if (project.usingAndroidInstrumentedTests) {
|
if (project.usingAndroidInstrumentedTests) {
|
||||||
configureAndroidTargetWithSdk()
|
configureAndroidTargetWithSdk(androidNamespace)
|
||||||
} else {
|
} else {
|
||||||
configureAndroidTargetWithJvm()
|
configureAndroidTargetWithJvm()
|
||||||
}
|
}
|
||||||
@ -82,7 +82,12 @@ private fun Project.configureAndroidTargetWithJvm() {
|
|||||||
private const val PROP_MIRAI_ANDROID_SDK_KIND = "mirai.android.sdk.kind"
|
private const val PROP_MIRAI_ANDROID_SDK_KIND = "mirai.android.sdk.kind"
|
||||||
|
|
||||||
@Suppress("UnstableApiUsage")
|
@Suppress("UnstableApiUsage")
|
||||||
private fun Project.configureAndroidTargetWithSdk() {
|
private fun Project.configureAndroidTargetWithSdk(androidNamespace: String) {
|
||||||
|
apply(plugin = "com.android.library")
|
||||||
|
apply(plugin = "de.mannodermaus.android-junit5")
|
||||||
|
extensions.getByType(LibraryExtension::class).apply {
|
||||||
|
namespace = androidNamespace
|
||||||
|
}
|
||||||
extensions.getByType(KotlinMultiplatformExtension::class.java).apply {
|
extensions.getByType(KotlinMultiplatformExtension::class.java).apply {
|
||||||
android {
|
android {
|
||||||
if (IDEA_ACTIVE) {
|
if (IDEA_ACTIVE) {
|
||||||
|
@ -164,7 +164,7 @@ const val JVM_TOOLCHAIN_VERSION = 8
|
|||||||
*
|
*
|
||||||
* @see configureNativeTargetsHierarchical
|
* @see configureNativeTargetsHierarchical
|
||||||
*/
|
*/
|
||||||
fun Project.configureJvmTargetsHierarchical() {
|
fun Project.configureJvmTargetsHierarchical(androidNamespace: String) {
|
||||||
extensions.getByType(KotlinMultiplatformExtension::class.java).apply {
|
extensions.getByType(KotlinMultiplatformExtension::class.java).apply {
|
||||||
val commonMain by sourceSets.getting
|
val commonMain by sourceSets.getting
|
||||||
val commonTest by sourceSets.getting
|
val commonTest by sourceSets.getting
|
||||||
@ -200,7 +200,7 @@ fun Project.configureJvmTargetsHierarchical() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isTargetEnabled("android")) {
|
if (isTargetEnabled("android")) {
|
||||||
configureAndroidTarget()
|
configureAndroidTarget(androidNamespace)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isTargetEnabled("jvm")) {
|
if (isTargetEnabled("jvm")) {
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
plugins {
|
plugins {
|
||||||
kotlin("multiplatform")
|
kotlin("multiplatform")
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
id("com.android.library")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
version = Versions.console
|
version = Versions.console
|
||||||
@ -22,12 +21,8 @@ kotlin {
|
|||||||
explicitApi()
|
explicitApi()
|
||||||
apply(plugin = "explicit-api")
|
apply(plugin = "explicit-api")
|
||||||
|
|
||||||
configureJvmTargetsHierarchical()
|
configureJvmTargetsHierarchical("net.mamoe.mirai.compiler.annotations")
|
||||||
configureNativeTargetsHierarchical(project)
|
configureNativeTargetsHierarchical(project)
|
||||||
}
|
}
|
||||||
|
|
||||||
configureMppPublishing()
|
configureMppPublishing()
|
||||||
|
|
||||||
android {
|
|
||||||
namespace = "net.mamoe.mirai.compiler.annotations"
|
|
||||||
}
|
|
@ -12,7 +12,6 @@ import BinaryCompatibilityConfigurator.configureBinaryValidators
|
|||||||
import shadow.relocateCompileOnly
|
import shadow.relocateCompileOnly
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.library")
|
|
||||||
kotlin("multiplatform")
|
kotlin("multiplatform")
|
||||||
kotlin("plugin.serialization")
|
kotlin("plugin.serialization")
|
||||||
|
|
||||||
@ -31,7 +30,7 @@ kotlin {
|
|||||||
explicitApi()
|
explicitApi()
|
||||||
apply(plugin = "explicit-api")
|
apply(plugin = "explicit-api")
|
||||||
|
|
||||||
configureJvmTargetsHierarchical()
|
configureJvmTargetsHierarchical("net.mamoe.mirai")
|
||||||
|
|
||||||
configureNativeTargetsHierarchical(project)
|
configureNativeTargetsHierarchical(project)
|
||||||
|
|
||||||
@ -125,7 +124,3 @@ configureBinaryValidators(setOf("jvm", "android").filterTargets())
|
|||||||
// licenseFromGitHubProject("AGPLv3", "dev")
|
// licenseFromGitHubProject("AGPLv3", "dev")
|
||||||
// publishPlatformArtifactsInRootModule = "jvm"
|
// publishPlatformArtifactsInRootModule = "jvm"
|
||||||
//}
|
//}
|
||||||
|
|
||||||
android {
|
|
||||||
namespace = "net.mamoe.mirai"
|
|
||||||
}
|
|
@ -12,7 +12,6 @@
|
|||||||
import shadow.relocateImplementation
|
import shadow.relocateImplementation
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.library")
|
|
||||||
kotlin("multiplatform")
|
kotlin("multiplatform")
|
||||||
kotlin("plugin.serialization")
|
kotlin("plugin.serialization")
|
||||||
|
|
||||||
@ -28,7 +27,7 @@ kotlin {
|
|||||||
explicitApi()
|
explicitApi()
|
||||||
apply(plugin = "explicit-api")
|
apply(plugin = "explicit-api")
|
||||||
|
|
||||||
configureJvmTargetsHierarchical()
|
configureJvmTargetsHierarchical("net.mamoe.mirai.utils")
|
||||||
configureNativeTargetsHierarchical(project)
|
configureNativeTargetsHierarchical(project)
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
@ -108,8 +107,4 @@ configureMppPublishing()
|
|||||||
// developer("Mamoe Technologies", email = "support@mamoe.net", url = "https://github.com/mamoe")
|
// developer("Mamoe Technologies", email = "support@mamoe.net", url = "https://github.com/mamoe")
|
||||||
// licenseFromGitHubProject("AGPLv3", "dev")
|
// licenseFromGitHubProject("AGPLv3", "dev")
|
||||||
// publishPlatformArtifactsInRootModule = "jvm"
|
// publishPlatformArtifactsInRootModule = "jvm"
|
||||||
//}
|
//}
|
||||||
|
|
||||||
android {
|
|
||||||
namespace = "net.mamoe.mirai.utils"
|
|
||||||
}
|
|
@ -16,7 +16,6 @@ import shadow.relocateCompileOnly
|
|||||||
import shadow.relocateImplementation
|
import shadow.relocateImplementation
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.library")
|
|
||||||
kotlin("multiplatform")
|
kotlin("multiplatform")
|
||||||
id("kotlinx-atomicfu")
|
id("kotlinx-atomicfu")
|
||||||
kotlin("plugin.serialization")
|
kotlin("plugin.serialization")
|
||||||
@ -24,7 +23,6 @@ plugins {
|
|||||||
id("me.him188.kotlin-dynamic-delegation")
|
id("me.him188.kotlin-dynamic-delegation")
|
||||||
// id("me.him188.maven-central-publish")
|
// id("me.him188.maven-central-publish")
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
id("de.mannodermaus.android-junit5") version "1.8.2.1"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
description = "Mirai Protocol implementation for QQ Android"
|
description = "Mirai Protocol implementation for QQ Android"
|
||||||
@ -33,7 +31,7 @@ kotlin {
|
|||||||
explicitApi()
|
explicitApi()
|
||||||
apply(plugin = "explicit-api")
|
apply(plugin = "explicit-api")
|
||||||
|
|
||||||
configureJvmTargetsHierarchical()
|
configureJvmTargetsHierarchical("net.mamoe.mirai.internal")
|
||||||
configureNativeTargetsHierarchical(project)
|
configureNativeTargetsHierarchical(project)
|
||||||
configureNativeTargetBinaries(project) // register native binaries for mirai-core only
|
configureNativeTargetBinaries(project) // register native binaries for mirai-core only
|
||||||
|
|
||||||
@ -270,7 +268,3 @@ configureBinaryValidators(setOf("jvm", "android").filterTargets())
|
|||||||
// licenseFromGitHubProject("AGPLv3", "dev")
|
// licenseFromGitHubProject("AGPLv3", "dev")
|
||||||
// publishPlatformArtifactsInRootModule = "jvm"
|
// publishPlatformArtifactsInRootModule = "jvm"
|
||||||
//}
|
//}
|
||||||
|
|
||||||
android {
|
|
||||||
namespace = "net.mamoe.mirai.internal"
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user