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
|
|
|
|
import java.text.SimpleDateFormat
|
2020-08-22 20:13:05 +08:00
|
|
|
import java.time.Instant
|
2020-08-01 13:04:32 +08:00
|
|
|
import java.util.Date
|
|
|
|
import java.util.TimeZone
|
2020-02-27 13:18:33 +08:00
|
|
|
|
|
|
|
plugins {
|
2020-08-16 23:21:11 +08:00
|
|
|
kotlin("jvm")
|
|
|
|
kotlin("plugin.serialization")
|
2020-08-28 20:07:02 +08:00
|
|
|
kotlin("kapt")
|
2020-02-27 13:18:33 +08:00
|
|
|
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-02-27 13:18:33 +08:00
|
|
|
}
|
|
|
|
|
2020-06-20 22:55:07 +08:00
|
|
|
version = Versions.console
|
2020-05-23 17:44:34 +08:00
|
|
|
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()
|
|
|
|
|
2020-05-23 17:44:34 +08:00
|
|
|
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
|
2020-05-23 17:44:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
languageSettings.apply {
|
|
|
|
enableLanguageFeature("InlineClasses")
|
|
|
|
progressiveMode = true
|
|
|
|
|
|
|
|
useExperimentalAnnotation("kotlin.Experimental")
|
2020-09-02 07:45:31 +08:00
|
|
|
useExperimentalAnnotation("kotlin.RequiresOptIn")
|
2020-05-23 17:44:34 +08:00
|
|
|
|
|
|
|
useExperimentalAnnotation("net.mamoe.mirai.utils.MiraiInternalAPI")
|
|
|
|
useExperimentalAnnotation("net.mamoe.mirai.utils.MiraiExperimentalAPI")
|
2020-07-24 20:11:10 +08:00
|
|
|
useExperimentalAnnotation("net.mamoe.mirai.console.ConsoleFrontEndImplementation")
|
2020-08-16 23:21:11 +08:00
|
|
|
useExperimentalAnnotation("net.mamoe.mirai.console.util.ConsoleExperimentalAPI")
|
2020-05-23 17:44:34 +08:00
|
|
|
useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
|
|
|
|
useExperimentalAnnotation("kotlin.experimental.ExperimentalTypeInference")
|
|
|
|
useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
|
2020-08-19 22:25:42 +08:00
|
|
|
useExperimentalAnnotation("kotlinx.serialization.ExperimentalSerializationApi")
|
2020-08-23 16:36:49 +08:00
|
|
|
useExperimentalAnnotation("net.mamoe.mirai.console.util.ConsoleInternalAPI")
|
2020-05-23 17:44:34 +08:00
|
|
|
}
|
|
|
|
}
|
2020-03-05 09:45:54 +08:00
|
|
|
}
|
2020-05-14 16:05:42 +08:00
|
|
|
|
2020-02-27 13:18:33 +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
|
|
|
|
2020-08-31 22:30:28 +08:00
|
|
|
implementation("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
|
|
|
|
2020-07-19 22:45:06 +08:00
|
|
|
api("com.vdurmont:semver4j:3.1.0")
|
|
|
|
|
2020-07-31 16:35:41 +08:00
|
|
|
//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}")
|
2020-05-23 17:44:34 +08:00
|
|
|
testApi(kotlin("stdlib-jdk8"))
|
2020-05-14 15:33:10 +08:00
|
|
|
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")
|
2020-08-28 20:07:02 +08:00
|
|
|
|
|
|
|
|
|
|
|
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-19 22:45:06 +08:00
|
|
|
|
2020-07-11 19:26:31 +08:00
|
|
|
ext.apply {
|
2020-06-23 22:05:46 +08:00
|
|
|
// 傻逼 compileAndRuntime 没 exclude 掉
|
2020-06-23 22:18:49 +08:00
|
|
|
// 傻逼 gradle 第二次配置 task 会覆盖掉第一次的配置
|
2020-06-23 22:05:46 +08:00
|
|
|
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
|
2020-06-23 22:05:46 +08:00
|
|
|
"net.mamoe:mirai-core-qqandroid" -> true
|
|
|
|
else -> false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-07-11 19:26:31 +08:00
|
|
|
set("shadowJar", x)
|
2020-06-23 22:05:46 +08:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-02-27 13:18:33 +08:00
|
|
|
}
|
|
|
|
|
2020-05-23 17:44:34 +08:00
|
|
|
// region PUBLISHING
|
2020-05-10 14:22:33 +08:00
|
|
|
|
2020-06-28 11:45:21 +08:00
|
|
|
setupPublishing("mirai-console")
|
2020-05-23 17:44:34 +08:00
|
|
|
|
|
|
|
// endregion
|