mirai/backend/mirai-console/build.gradle.kts

116 lines
4.0 KiB
Plaintext
Raw Normal View History

2020-08-01 13:04:32 +08:00
@file:Suppress("UnusedImport")
2020-06-21 14:24:17 +08:00
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2020-08-22 20:13:05 +08:00
import java.time.Instant
plugins {
2020-08-16 23:21:11 +08:00
kotlin("jvm")
kotlin("plugin.serialization")
id("java")
`maven-publish`
2020-06-28 11:45:21 +08:00
id("com.jfrog.bintray")
2020-08-16 23:21:11 +08:00
id("net.mamoe.kotlin-jvm-blocking-bridge")
}
2020-06-20 22:55:07 +08:00
version = Versions.console
description = "Console backend for mirai"
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType(JavaCompile::class.java) {
options.encoding = "UTF8"
}
2020-03-05 09:45:54 +08:00
kotlin {
2020-07-11 19:26:31 +08:00
explicitApiWarning()
sourceSets.all {
target.compilations.all {
kotlinOptions {
jvmTarget = "1.8"
2020-09-04 20:49:15 +08:00
freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all"
2020-08-16 23:21:11 +08:00
//useIR = true
}
}
languageSettings.apply {
enableLanguageFeature("InlineClasses")
progressiveMode = true
useExperimentalAnnotation("kotlin.Experimental")
2020-09-02 07:45:31 +08:00
useExperimentalAnnotation("kotlin.RequiresOptIn")
useExperimentalAnnotation("net.mamoe.mirai.utils.MiraiInternalAPI")
useExperimentalAnnotation("net.mamoe.mirai.utils.MiraiExperimentalAPI")
useExperimentalAnnotation("net.mamoe.mirai.console.ConsoleFrontEndImplementation")
2020-09-12 16:11:53 +08:00
useExperimentalAnnotation("net.mamoe.mirai.console.util.ConsoleExperimentalApi")
useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
useExperimentalAnnotation("kotlin.experimental.ExperimentalTypeInference")
useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
useExperimentalAnnotation("kotlinx.serialization.ExperimentalSerializationApi")
2020-09-12 16:11:53 +08:00
useExperimentalAnnotation("net.mamoe.mirai.console.util.ConsoleInternalApi")
}
}
2020-03-05 09:45:54 +08:00
}
2020-05-14 16:05:42 +08:00
dependencies {
2020-09-20 00:28:57 +08:00
compileAndTestRuntime("net.mamoe:mirai-core:${Versions.core}")
compileAndTestRuntime(kotlin("stdlib", Versions.kotlinStdlib))
compileAndTestRuntime(kotlin("stdlib-jdk8", Versions.kotlinStdlib))
2020-03-04 22:15:46 +08:00
2020-09-20 00:28:57 +08:00
compileAndTestRuntime("org.jetbrains.kotlinx:atomicfu:${Versions.atomicFU}")
compileAndTestRuntime(kotlinx("coroutines-core", Versions.coroutines))
compileAndTestRuntime(kotlinx("serialization-core", Versions.serialization))
2020-11-08 11:10:46 +08:00
compileAndTestRuntime(kotlinx("serialization-json", Versions.serialization))
2020-09-20 00:28:57 +08:00
compileAndTestRuntime(kotlin("reflect"))
2020-08-01 13:04:32 +08:00
smartImplementation("net.mamoe.yamlkt:yamlkt:${Versions.yamlkt}")
smartImplementation("org.jetbrains:annotations:19.0.0")
2020-09-20 00:28:57 +08:00
smartApi(kotlinx("coroutines-jdk8", Versions.coroutines))
2020-06-20 22:55:07 +08:00
testApi("net.mamoe:mirai-core-qqandroid:${Versions.core}")
testApi(kotlin("stdlib-jdk8"))
testApi(kotlin("test"))
testApi(kotlin("test-junit5"))
2020-06-17 13:25:28 +08:00
2020-09-20 00:28:57 +08:00
testApi("org.junit.jupiter:junit-jupiter-api:5.2.0")
2020-06-17 13:25:28 +08:00
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.2.0")
}
2020-06-17 13:25:28 +08:00
tasks {
"test"(Test::class) {
useJUnitPlatform()
}
2020-06-21 14:24:17 +08:00
val compileKotlin by getting {}
val fillBuildConstants by registering {
2020-07-11 20:04:18 +08:00
group = "mirai"
2020-06-21 14:24:17 +08:00
doLast {
2020-08-20 12:52:41 +08:00
(compileKotlin as KotlinCompile).source.filter { it.name == "MiraiConsoleBuildConstants.kt" }.single()
.let { file ->
file.writeText(
file.readText()
2020-08-22 20:13:05 +08:00
.replace(
2020-09-02 08:24:17 +08:00
Regex("""val buildDate: Instant = Instant.ofEpochSecond\(.*\)""")
) {
"""val buildDate: Instant = Instant.ofEpochSecond(${
2020-09-20 00:28:57 +08:00
Instant.now().epochSecond
2020-09-02 08:24:17 +08:00
})"""
}
2020-08-22 20:13:05 +08:00
.replace(
2020-09-26 23:51:00 +08:00
Regex("""const val versionConst:\s+String\s+=\s+".*"""")
) { """const val versionConst: String = "${project.version}"""" }
2020-08-20 12:52:41 +08:00
)
2020-09-20 00:28:57 +08:00
}
2020-06-21 14:24:17 +08:00
}
}
}
// region PUBLISHING
2020-05-10 14:22:33 +08:00
2020-06-28 11:45:21 +08:00
setupPublishing("mirai-console")
// endregion