Configure HMPP project structure

This commit is contained in:
Him188 2022-05-17 09:43:09 +01:00
parent 0e1585e898
commit d96641dedb
12 changed files with 296 additions and 148 deletions

View File

@ -0,0 +1,151 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
*
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
import org.apache.tools.ant.taskdefs.condition.Os
import org.gradle.api.Project
import org.gradle.api.attributes.Attribute
import org.gradle.kotlin.dsl.get
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.MAIN_COMPILATION_NAME
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.TEST_COMPILATION_NAME
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
*
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
private val miraiPlatform = Attribute.of(
"net.mamoe.mirai.platform",
String::class.java
)
fun Project.configureHMPPJvm() {
extensions.getByType(KotlinMultiplatformExtension::class.java).apply {
jvm("jvmBase") {
attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.common) // avoid resolving by others
// attributes.attribute(miraiPlatform, "jvmBase")
}
if (isAndroidSDKAvailable) {
jvm("android") {
attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.androidJvm)
// publishAllLibraryVariants()
}
} else {
printAndroidNotInstalled()
}
jvm("jvm") {
}
val ideaActive = System.getProperty("idea.active") == "true" && System.getProperty("publication.test") != "true"
val nativeMainSets = mutableListOf<KotlinSourceSet>()
val nativeTestSets = mutableListOf<KotlinSourceSet>()
if (ideaActive) {
when {
Os.isFamily(Os.FAMILY_MAC) -> if (Os.isArch("aarch64")) macosArm64("native") else macosX64("native")
Os.isFamily(Os.FAMILY_WINDOWS) -> mingwX64("native")
else -> linuxX64("native")
}
} else {
// 1.6.0
val nativeTargets: List<String> = arrayOf(
// serialization doesn't support those commented targets
// "androidNativeArm32, androidNativeArm64, androidNativeX86, androidNativeX64",
"iosArm32, iosArm64, iosX64, iosSimulatorArm64",
"watchosArm32, watchosArm64, watchosX86, watchosX64, watchosSimulatorArm64",
"tvosArm64, tvosX64, tvosSimulatorArm64",
"macosX64, macosArm64",
"linuxMips32, linuxMipsel32, linuxX64",
"mingwX64",
// "wasm32" // linuxArm32Hfp, mingwX86
).flatMap { it.split(",") }.map { it.trim() }
presets.filter { it.name in nativeTargets }
.forEach { preset ->
val target = targetFromPreset(preset, preset.name)
nativeMainSets.add(target.compilations[MAIN_COMPILATION_NAME].kotlinSourceSets.first())
nativeTestSets.add(target.compilations[TEST_COMPILATION_NAME].kotlinSourceSets.first())
}
if (!ideaActive) {
configure(nativeMainSets) {
dependsOn(sourceSets.maybeCreate("nativeMain"))
}
configure(nativeTestSets) {
dependsOn(sourceSets.maybeCreate("nativeTest"))
}
}
}
// nativeTarget.apply {
// val myrust by compilations.getByName("main").cinterops.creating {
// headers(project.projectDir.resolve("untitled/myrust.h"))
// }
//
// binaries {
// sharedLib {
// linkerOpts("-v")
// linkerOpts("-L${project.projectDir.resolve("untitled/target/debug/").absolutePath}")
//// linkerOpts("-lmyrust")
// linkerOpts("-Wl,-undefined,dynamic_lookup") // resolve symbols in runtime
// baseName = "mykotlin"
// }
//
// executable {
//
// linkerOpts("-v")
// linkerOpts("-L${project.projectDir.resolve("untitled/target/debug/").absolutePath}")
//// linkerOpts("-lmyrust")
// linkerOpts("-Wl,-undefined,dynamic_lookup") // resolve symbols in runtime
// baseName = "KotlinExecutable"
// entryPoint = "main.main"
// }
// }
// }
val sourceSets = kotlinSourceSets.orEmpty()
val commonMain = sourceSets.single { it.name == "commonMain" }
val commonTest = sourceSets.single { it.name == "commonTest" }
val jvmBaseMain = this.sourceSets.maybeCreate("jvmBaseMain")
val jvmBaseTest = this.sourceSets.maybeCreate("jvmBaseTest")
val jvmMain = sourceSets.single { it.name == "jvmMain" }
val jvmTest = sourceSets.single { it.name == "jvmTest" }
val androidMain = sourceSets.single { it.name == "androidMain" }
val androidTest = sourceSets.single { it.name == "androidTest" }
val nativeMain = sourceSets.single { it.name == "nativeMain" }
val nativeTest = sourceSets.single { it.name == "nativeTest" }
jvmBaseMain.dependsOn(commonMain)
jvmBaseTest.dependsOn(commonTest)
jvmMain.dependsOn(jvmBaseMain)
androidMain.dependsOn(jvmBaseMain)
jvmTest.dependsOn(jvmBaseTest)
androidTest.dependsOn(commonTest)
nativeMain.dependsOn(commonMain)
nativeTest.dependsOn(commonTest)
}
}

View File

@ -19,6 +19,7 @@ import org.gradle.kotlin.dsl.*
import org.jetbrains.kotlin.gradle.dsl.* import org.jetbrains.kotlin.gradle.dsl.*
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
@ -56,6 +57,7 @@ fun Project.preConfigureJvmTarget() {
targetCompatibility = defaultVer.toString() targetCompatibility = defaultVer.toString()
} }
} }
fun Project.configureJvmTarget() { fun Project.configureJvmTarget() {
val defaultVer = jvmVersion() val defaultVer = jvmVersion()
@ -125,7 +127,7 @@ fun Project.configureKotlinTestSettings() {
when { when {
sourceSet.name == "commonTest" -> { sourceSet.name == "commonTest" -> {
if (target?.platformType == KotlinPlatformType.jvm || target?.platformType == KotlinPlatformType.androidJvm) { if (isJvmLikePlatform(target)) {
configureJvmTest(sourceSet) configureJvmTest(sourceSet)
} else { } else {
sourceSet.dependencies { sourceSet.dependencies {
@ -135,7 +137,9 @@ fun Project.configureKotlinTestSettings() {
} }
} }
sourceSet.name.contains("test", ignoreCase = true) -> { sourceSet.name.contains("test", ignoreCase = true) -> {
configureJvmTest(sourceSet) if (isJvmLikePlatform(target)) {
configureJvmTest(sourceSet)
}
} }
} }
} }
@ -143,6 +147,9 @@ fun Project.configureKotlinTestSettings() {
} }
} }
private fun isJvmLikePlatform(target: KotlinTarget?) =
target?.platformType == KotlinPlatformType.jvm || target?.platformType == KotlinPlatformType.androidJvm
val testExperimentalAnnotations = arrayOf( val testExperimentalAnnotations = arrayOf(
"kotlin.ExperimentalUnsignedTypes", "kotlin.ExperimentalUnsignedTypes",
"kotlin.time.ExperimentalTime", "kotlin.time.ExperimentalTime",

View File

@ -58,7 +58,7 @@ object Versions {
const val junit = "5.7.2" const val junit = "5.7.2"
const val yamlkt = "0.10.2" const val yamlkt = "0.11.0"
const val intellijGradlePlugin = "1.5.3" const val intellijGradlePlugin = "1.5.3"
// const val kotlinIntellijPlugin = "211-1.5.20-release-284-IJ7442.40" // keep to newest as kotlinCompiler // const val kotlinIntellijPlugin = "211-1.5.20-release-284-IJ7442.40" // keep to newest as kotlinCompiler
@ -72,23 +72,20 @@ fun kotlinx(id: String, version: String) = "org.jetbrains.kotlinx:kotlinx-$id:$v
@Suppress("unused") @Suppress("unused")
fun ktor(id: String, version: String = Versions.ktor) = "io.ktor:ktor-$id:$version" fun ktor(id: String, version: String = Versions.ktor) = "io.ktor:ktor-$id:$version"
val `kotlinx-coroutines-core` = kotlinx("coroutines-core", Versions.coroutines)
// Why using `-jvm`?
// All target platforms are JVM. Root modules like 'coroutines-core' will be resolved to 'coroutines-common' for commonMain,
// which make IDE code analysis not working.
val `kotlinx-coroutines-core-jvm` = kotlinx("coroutines-core-jvm", Versions.coroutines)
val `kotlinx-coroutines-jdk8` = kotlinx("coroutines-jdk8", Versions.coroutines) val `kotlinx-coroutines-jdk8` = kotlinx("coroutines-jdk8", Versions.coroutines)
val `kotlinx-coroutines-swing` = kotlinx("coroutines-swing", Versions.coroutines) val `kotlinx-coroutines-swing` = kotlinx("coroutines-swing", Versions.coroutines)
val `kotlinx-coroutines-debug` = kotlinx("coroutines-debug", Versions.coroutines) val `kotlinx-coroutines-debug` = kotlinx("coroutines-debug", Versions.coroutines)
val `kotlinx-serialization-core-jvm` = kotlinx("serialization-core-jvm", Versions.serialization) val `kotlinx-serialization-core` = kotlinx("serialization-core", Versions.serialization)
val `kotlinx-serialization-json-jvm` = kotlinx("serialization-json-jvm", Versions.serialization) val `kotlinx-serialization-json` = kotlinx("serialization-json", Versions.serialization)
val `kotlinx-serialization-protobuf-jvm` = kotlinx("serialization-protobuf-jvm", Versions.serialization) val `kotlinx-serialization-protobuf` = kotlinx("serialization-protobuf", Versions.serialization)
const val `kotlinx-atomicfu-jvm` = "org.jetbrains.kotlinx:atomicfu-jvm:${Versions.atomicFU}" const val `kotlinx-atomicfu` = "org.jetbrains.kotlinx:atomicfu:${Versions.atomicFU}"
val `kotlinx-io-common` = kotlinx("io", Versions.io)
val `kotlinx-io-jvm` = kotlinx("io-jvm", Versions.io) val `kotlinx-io-jvm` = kotlinx("io-jvm", Versions.io)
val `kotlinx-io-native` = kotlinx("io-macosx64", Versions.io)
fun KotlinDependencyHandler.implementationKotlinxIoJvm() { fun KotlinDependencyHandler.implementationKotlinxIo(module: String) {
implementation(`kotlinx-io-jvm`) { implementation(module) {
/* /*
| +--- org.jetbrains.kotlinx:kotlinx-io-jvm:0.1.16 | +--- org.jetbrains.kotlinx:kotlinx-io-jvm:0.1.16
| | +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.60 -> 1.5.30 (*) | | +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.60 -> 1.5.30 (*)
@ -103,17 +100,17 @@ fun KotlinDependencyHandler.implementationKotlinxIoJvm() {
} }
} }
val `kotlinx-coroutines-io-jvm` = kotlinx("coroutines-io-jvm", Versions.coroutinesIo) val `kotlinx-coroutines-io` = kotlinx("coroutines-io", Versions.coroutinesIo)
val `ktor-serialization` = ktor("serialization", Versions.ktor) val `ktor-serialization` = ktor("serialization", Versions.ktor)
val `ktor-client-core-jvm` = ktor("client-core-jvm", Versions.ktor) val `ktor-client-core` = ktor("client-core-jvm", Versions.ktor)
val `ktor-client-cio-jvm` = ktor("client-cio-jvm", Versions.ktor) val `ktor-client-cio` = ktor("client-cio-jvm", Versions.ktor)
val `ktor-client-okhttp` = ktor("client-okhttp", Versions.ktor) val `ktor-client-okhttp` = ktor("client-okhttp", Versions.ktor)
val `ktor-client-android` = ktor("client-android", Versions.ktor) val `ktor-client-android` = ktor("client-android", Versions.ktor)
val `ktor-client-logging-jvm` = ktor("client-logging-jvm", Versions.ktor) val `ktor-client-logging` = ktor("client-logging-jvm", Versions.ktor)
val `ktor-network-jvm` = ktor("network-jvm", Versions.ktor) val `ktor-network` = ktor("network-jvm", Versions.ktor)
val `ktor-client-serialization-jvm` = ktor("client-serialization-jvm", Versions.ktor) val `ktor-client-serialization` = ktor("client-serialization-jvm", Versions.ktor)
const val `logback-classic` = "ch.qos.logback:logback-classic:" + Versions.logback const val `logback-classic` = "ch.qos.logback:logback-classic:" + Versions.logback
@ -141,7 +138,7 @@ const val `kotlin-test-junit5` = "org.jetbrains.kotlin:kotlin-test-junit5:${Vers
//const val `mirai-core` = "net.mamoe:mirai-core:${Versions.core}" //const val `mirai-core` = "net.mamoe:mirai-core:${Versions.core}"
//const val `mirai-core-utils` = "net.mamoe:mirai-core-utils:${Versions.core}" //const val `mirai-core-utils` = "net.mamoe:mirai-core-utils:${Versions.core}"
const val `yamlkt-jvm` = "net.mamoe.yamlkt:yamlkt:${Versions.yamlkt}" const val `yamlkt` = "net.mamoe.yamlkt:yamlkt:${Versions.yamlkt}"
const val `jetbrains-annotations` = "org.jetbrains:annotations:19.0.0" const val `jetbrains-annotations` = "org.jetbrains:annotations:19.0.0"

View File

@ -1,12 +1,11 @@
# #
# Copyright 2019-2021 Mamoe Technologies and contributors. # Copyright 2019-2022 Mamoe Technologies and contributors.
# #
# 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. # 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
# Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. # Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
# #
# https://github.com/mamoe/mirai/blob/master/LICENSE # https://github.com/mamoe/mirai/blob/dev/LICENSE
# #
# style guide
kotlin.code.style=official kotlin.code.style=official
# config # config
kotlin.incremental.multiplatform=true kotlin.incremental.multiplatform=true
@ -15,6 +14,7 @@ org.gradle.parallel=true
org.gradle.vfs.watch=true org.gradle.vfs.watch=true
kotlin.mpp.enableGranularSourceSetsMetadata=true kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.native.enableDependencyPropagation=false kotlin.native.enableDependencyPropagation=false
#kotlin.mpp.enableCompatibilityMetadataVariant=true
#kotlin.mpp.enableGranularSourceSetsMetadata=true #kotlin.mpp.enableGranularSourceSetsMetadata=true
systemProp.org.gradle.internal.publish.checksums.insecure=true systemProp.org.gradle.internal.publish.checksums.insecure=true
gnsp.disableApplyOnlyOnRootProjectEnforcement=true gnsp.disableApplyOnlyOnRootProjectEnforcement=true

View File

@ -33,15 +33,15 @@ dependencies {
api(project(":mirai-console-terminal")) api(project(":mirai-console-terminal"))
api(`kotlin-stdlib-jdk8`) api(`kotlin-stdlib-jdk8`)
api(`kotlinx-atomicfu-jvm`) api(`kotlinx-atomicfu`)
api(`kotlinx-coroutines-core-jvm`) api(`kotlinx-coroutines-core`)
api(`kotlinx-serialization-core-jvm`) api(`kotlinx-serialization-core`)
api(`kotlinx-serialization-json-jvm`) api(`kotlinx-serialization-json`)
api(`kotlin-reflect`) api(`kotlin-reflect`)
api(`kotlin-test-junit5`) api(`kotlin-test-junit5`)
api(`yamlkt-jvm`) api(`yamlkt`)
api(`jetbrains-annotations`) api(`jetbrains-annotations`)
api(`caller-finder`) api(`caller-finder`)
api(`kotlinx-coroutines-jdk8`) api(`kotlinx-coroutines-jdk8`)

View File

@ -1,18 +1,18 @@
/* /*
* Copyright 2019-2021 Mamoe Technologies and contributors. * Copyright 2019-2022 Mamoe Technologies and contributors.
* *
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
* *
* https://github.com/mamoe/mirai/blob/master/LICENSE * https://github.com/mamoe/mirai/blob/dev/LICENSE
*/ */
@file:Suppress("UnusedImport") @file:Suppress("UnusedImport")
import BinaryCompatibilityConfigurator.configureBinaryValidator import BinaryCompatibilityConfigurator.configureBinaryValidator
import BinaryCompatibilityConfigurator.configureBinaryValidators import java.time.Instant
import java.time.* import java.time.ZoneId
import java.time.format.* import java.time.format.DateTimeFormatter
plugins { plugins {
kotlin("jvm") kotlin("jvm")
@ -45,15 +45,15 @@ dependencies {
compileAndTestRuntime(project(":mirai-core-utils")) compileAndTestRuntime(project(":mirai-core-utils"))
compileAndTestRuntime(`kotlin-stdlib-jdk8`) compileAndTestRuntime(`kotlin-stdlib-jdk8`)
compileAndTestRuntime(`kotlinx-atomicfu-jvm`) compileAndTestRuntime(`kotlinx-atomicfu`)
compileAndTestRuntime(`kotlinx-coroutines-core-jvm`) compileAndTestRuntime(`kotlinx-coroutines-core`)
compileAndTestRuntime(`kotlinx-serialization-core-jvm`) compileAndTestRuntime(`kotlinx-serialization-core`)
compileAndTestRuntime(`kotlinx-serialization-json-jvm`) compileAndTestRuntime(`kotlinx-serialization-json`)
compileAndTestRuntime(`kotlin-reflect`) compileAndTestRuntime(`kotlin-reflect`)
implementation(project(":mirai-console-compiler-annotations")) implementation(project(":mirai-console-compiler-annotations"))
smartImplementation(`yamlkt-jvm`) smartImplementation(`yamlkt`)
smartImplementation(`jetbrains-annotations`) smartImplementation(`jetbrains-annotations`)
smartImplementation(`caller-finder`) smartImplementation(`caller-finder`)
smartImplementation(`maven-resolver-api`) smartImplementation(`maven-resolver-api`)

View File

@ -1,16 +1,14 @@
/* /*
* Copyright 2019-2021 Mamoe Technologies and contributors. * Copyright 2019-2022 Mamoe Technologies and contributors.
* *
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
* *
* https://github.com/mamoe/mirai/blob/master/LICENSE * https://github.com/mamoe/mirai/blob/dev/LICENSE
*/ */
@file:Suppress("UnusedImport") @file:Suppress("UnusedImport")
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
plugins { plugins {
kotlin("multiplatform") kotlin("multiplatform")
`maven-publish` `maven-publish`
@ -22,15 +20,7 @@ description = "Mirai Console compiler annotations"
kotlin { kotlin {
explicitApi() explicitApi()
jvm("android") { configureHMPPJvm()
attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.androidJvm)
}
jvm("common") {
attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.common)
}
jvm("jvm")
} }
configureMppPublishing() configureMppPublishing()

View File

@ -9,7 +9,6 @@
@file:Suppress("UNUSED_VARIABLE") @file:Suppress("UNUSED_VARIABLE")
import BinaryCompatibilityConfigurator.configureBinaryValidators import BinaryCompatibilityConfigurator.configureBinaryValidators
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
plugins { plugins {
kotlin("multiplatform") kotlin("multiplatform")
@ -27,41 +26,22 @@ description = "Mirai API module"
kotlin { kotlin {
explicitApi() explicitApi()
configureHMPPJvm()
if (isAndroidSDKAvailable) {
jvm("android") {
attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.androidJvm)
}
} else {
printAndroidNotInstalled()
}
jvm("common") {
attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.common)
}
jvm("jvm")
sourceSets { sourceSets {
val commonMain by getting { val commonMain by getting {
dependencies { dependencies {
api(kotlin("reflect")) api(kotlin("reflect"))
api(`kotlinx-serialization-core-jvm`) api(`kotlinx-serialization-core`)
api(`kotlinx-serialization-json-jvm`) api(`kotlinx-serialization-json`)
api(`kotlinx-coroutines-core-jvm`) // don't remove it, otherwise IDE will complain api(`kotlinx-coroutines-core`) // don't remove it, otherwise IDE will complain
api(`kotlinx-coroutines-jdk8`)
api(`ktor-client-okhttp`)
implementation(project(":mirai-core-utils")) implementation(project(":mirai-core-utils"))
implementation(project(":mirai-console-compiler-annotations")) implementation(project(":mirai-console-compiler-annotations"))
implementation(`kotlinx-serialization-protobuf-jvm`) implementation(`kotlinx-serialization-protobuf`)
implementation(`jetbrains-annotations`) implementation(`kotlinx-atomicfu`)
implementation(`log4j-api`) implementationKotlinxIo(`kotlinx-io-common`)
implementation(`kotlinx-atomicfu-jvm`)
implementationKotlinxIoJvm()
compileOnly(`slf4j-api`)
} }
} }
@ -71,6 +51,17 @@ kotlin {
} }
} }
val jvmBaseMain by getting {
dependencies {
api(`ktor-client-okhttp`)
api(`kotlinx-coroutines-jdk8`)
implementation(`jetbrains-annotations`)
implementation(`log4j-api`)
compileOnly(`slf4j-api`)
implementationKotlinxIo(`kotlinx-io-jvm`)
}
}
if (isAndroidSDKAvailable) { if (isAndroidSDKAvailable) {
val androidMain by getting { val androidMain by getting {
dependsOn(commonMain) dependsOn(commonMain)
@ -90,6 +81,12 @@ kotlin {
runtimeOnly(files("build/classes/kotlin/jvm/test")) // classpath is not properly set by IDE runtimeOnly(files("build/classes/kotlin/jvm/test")) // classpath is not properly set by IDE
} }
} }
val nativeMain by getting {
dependencies {
implementationKotlinxIo(`kotlinx-io-native`)
}
}
} }
} }

View File

@ -1,16 +1,14 @@
/* /*
* Copyright 2019-2021 Mamoe Technologies and contributors. * Copyright 2019-2022 Mamoe Technologies and contributors.
* *
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
* *
* https://github.com/mamoe/mirai/blob/master/LICENSE * https://github.com/mamoe/mirai/blob/dev/LICENSE
*/ */
@file:Suppress("UNUSED_VARIABLE") @file:Suppress("UNUSED_VARIABLE")
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
plugins { plugins {
kotlin("multiplatform") kotlin("multiplatform")
kotlin("plugin.serialization") kotlin("plugin.serialization")
@ -25,38 +23,31 @@ description = "mirai-core utilities"
kotlin { kotlin {
explicitApi() explicitApi()
if (isAndroidSDKAvailable) { configureHMPPJvm()
jvm("android") {
attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.androidJvm)
// publishAllLibraryVariants()
}
} else {
printAndroidNotInstalled()
}
jvm("common") {
attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.common)
}
jvm("jvm")
sourceSets { sourceSets {
val commonMain by getting { val commonMain by getting {
dependencies { dependencies {
api(kotlin("reflect")) api(kotlin("reflect"))
api(`kotlinx-serialization-core-jvm`) api(`kotlinx-serialization-core`)
api(`kotlinx-serialization-json-jvm`) api(`kotlinx-serialization-json`)
api(`kotlinx-coroutines-core-jvm`) api(`kotlinx-coroutines-core`)
implementation(`kotlinx-atomicfu-jvm`) implementation(`kotlinx-atomicfu`)
implementation(`kotlinx-serialization-protobuf-jvm`) implementation(`kotlinx-serialization-protobuf`)
implementationKotlinxIoJvm() implementationKotlinxIo(`kotlinx-io-common`)
} }
} }
val commonTest by getting { val commonTest by getting {
dependencies { dependencies {
api(`yamlkt-jvm`) api(yamlkt)
}
}
val jvmBaseMain by getting {
dependencies {
implementationKotlinxIo(`kotlinx-io-jvm`)
} }
} }
@ -77,6 +68,12 @@ kotlin {
runtimeOnly(files("build/classes/kotlin/jvm/test")) // classpath is not properly set by IDE runtimeOnly(files("build/classes/kotlin/jvm/test")) // classpath is not properly set by IDE
} }
} }
val nativeMain by getting {
dependencies {
implementationKotlinxIo(`kotlinx-io-native`)
}
}
} }
} }

View File

@ -0,0 +1,18 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
*
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
package net.mamoe.mirai.utils
public actual fun String.decodeBase64(): ByteArray {
TODO("Not yet implemented")
}
public actual fun ByteArray.encodeBase64(): String {
TODO("Not yet implemented")
}

View File

@ -10,7 +10,6 @@
@file:Suppress("UNUSED_VARIABLE") @file:Suppress("UNUSED_VARIABLE")
import BinaryCompatibilityConfigurator.configureBinaryValidators import BinaryCompatibilityConfigurator.configureBinaryValidators
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
plugins { plugins {
kotlin("multiplatform") kotlin("multiplatform")
@ -23,54 +22,40 @@ plugins {
description = "Mirai Protocol implementation for QQ Android" description = "Mirai Protocol implementation for QQ Android"
afterEvaluate {
tasks.getByName("compileKotlinCommon").enabled = false
tasks.getByName("compileTestKotlinCommon").enabled = false
tasks.getByName("compileCommonMainKotlinMetadata").enabled = false
tasks.getByName("compileKotlinMetadata").enabled = false
}
kotlin { kotlin {
explicitApi() explicitApi()
if (isAndroidSDKAvailable) { configureHMPPJvm()
jvm("android") {
attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.androidJvm)
}
} else {
printAndroidNotInstalled()
}
jvm("common") {
attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.common)
}
jvm("jvm")
sourceSets.apply { sourceSets.apply {
val commonMain by getting { val commonMain by getting {
dependencies { dependencies {
api(project(":mirai-core-api")) api(project(":mirai-core-api"))
api(`kotlinx-serialization-core-jvm`) api(`kotlinx-serialization-core`)
api(`kotlinx-serialization-json-jvm`) api(`kotlinx-serialization-json`)
api(`kotlinx-coroutines-core-jvm`) api(`kotlinx-coroutines-core`)
implementation(project(":mirai-core-utils")) implementation(project(":mirai-core-utils"))
implementation(`kotlinx-serialization-protobuf-jvm`) implementation(`kotlinx-serialization-protobuf`)
implementation(`kotlinx-atomicfu-jvm`) implementation(`kotlinx-atomicfu`)
implementation(`netty-all`) implementationKotlinxIo(`kotlinx-io-common`)
implementation(`log4j-api`)
implementation(bouncycastle)
implementationKotlinxIoJvm()
} }
} }
commonTest { commonTest {
dependencies { dependencies {
implementation(kotlin("script-runtime")) implementation(kotlin("script-runtime"))
api(`yamlkt-jvm`) api(yamlkt)
}
}
val jvmBaseMain by getting {
dependencies {
implementation(bouncycastle)
implementation(`log4j-api`)
implementation(`netty-all`)
implementationKotlinxIo(`kotlinx-io-jvm`)
} }
} }
@ -105,6 +90,12 @@ kotlin {
// implementation("net.mamoe:mirai-login-solver-selenium:1.0-dev-14") // implementation("net.mamoe:mirai-login-solver-selenium:1.0-dev-14")
} }
} }
val nativeMain by getting {
dependencies {
implementationKotlinxIo(`kotlinx-io-native`)
}
}
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2019-2021 Mamoe Technologies and contributors. * Copyright 2019-2022 Mamoe Technologies and contributors.
* *
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
@ -15,8 +15,8 @@ plugins {
} }
dependencies { dependencies {
implementation(`kotlinx-serialization-core-jvm`) implementation(`kotlinx-serialization-core`)
implementation(`kotlinx-serialization-json-jvm`) implementation(`kotlinx-serialization-json`)
} }
fun Project.newExec(name: String, type: String, conf: JavaExec.() -> Unit) { fun Project.newExec(name: String, type: String, conf: JavaExec.() -> Unit) {