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

140 lines
4.7 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")
kotlin("kapt")
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-08-20 20:24:08 +08:00
freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=enable"
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-08-16 23:21:11 +08:00
useExperimentalAnnotation("net.mamoe.mirai.console.util.ConsoleExperimentalAPI")
useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
useExperimentalAnnotation("kotlin.experimental.ExperimentalTypeInference")
useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
useExperimentalAnnotation("kotlinx.serialization.ExperimentalSerializationApi")
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-08-25 22:43:31 +08:00
implementation("net.mamoe:mirai-core:${Versions.core}")
2020-03-04 22:15:46 +08:00
2020-08-19 21:03:34 +08:00
implementation(kotlinx("serialization-core", Versions.serialization))
2020-08-01 22:19:06 +08:00
implementation(kotlin("reflect"))
2020-08-01 13:04:32 +08:00
api("net.mamoe.yamlkt:yamlkt:${Versions.yamlkt}")
2020-08-19 21:03:34 +08:00
implementation("org.jetbrains.kotlinx:atomicfu:${Versions.atomicFU}")
2020-05-11 13:22:09 +08:00
api("org.jetbrains:annotations:19.0.0")
2020-06-20 22:55:07 +08:00
api(kotlinx("coroutines-jdk8", Versions.coroutines))
2020-05-11 13:22:09 +08:00
api("com.vdurmont:semver4j:3.1.0")
//api(kotlinx("collections-immutable", Versions.collectionsImmutable))
2020-08-19 21:03:34 +08:00
testApi(kotlinx("serialization-core", Versions.serialization))
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
testImplementation("org.junit.jupiter:junit-jupiter-api:5.2.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.2.0")
val autoService = "1.0-rc7"
kapt("com.google.auto.service", "auto-service", autoService)
compileOnly("com.google.auto.service", "auto-service-annotations", autoService)
2020-06-17 13:25:28 +08:00
}
2020-07-11 19:26:31 +08:00
ext.apply {
// 傻逼 compileAndRuntime 没 exclude 掉
// 傻逼 gradle 第二次配置 task 会覆盖掉第一次的配置
val x: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar.() -> Unit = {
dependencyFilter.exclude {
when ("${it.moduleGroup}:${it.moduleName}") {
"net.mamoe:mirai-core" -> true
2020-08-25 22:43:31 +08:00
"org.jetbrains.kotlin:kotlin-stdlib" -> true
"org.jetbrains.kotlin:kotlin-stdlib-jdk8" -> true
"net.mamoe:mirai-core-qqandroid" -> true
else -> false
}
}
}
2020-07-11 19:26:31 +08:00
set("shadowJar", x)
}
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(${
Instant.now().getEpochSecond()
})"""
}
2020-08-22 20:13:05 +08:00
.replace(
2020-09-02 08:24:17 +08:00
Regex("""val version: Semver = Semver\(".*", Semver.SemverType.LOOSE\)""")
) { """val version: Semver = Semver("${project.version}", Semver.SemverType.LOOSE)""" }
2020-08-20 12:52:41 +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