2020-06-21 14:24:17 +08:00
|
|
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
2020-05-10 14:22:33 +08:00
|
|
|
import upload.Bintray
|
2020-06-21 14:24:17 +08:00
|
|
|
import java.text.SimpleDateFormat
|
2020-03-30 17:37:07 +08:00
|
|
|
import java.util.*
|
2020-02-27 13:18:33 +08:00
|
|
|
|
|
|
|
plugins {
|
2020-06-20 22:55:07 +08:00
|
|
|
kotlin("jvm") version Versions.kotlin
|
|
|
|
kotlin("plugin.serialization") version Versions.kotlin
|
2020-02-27 13:18:33 +08:00
|
|
|
id("java")
|
|
|
|
`maven-publish`
|
2020-06-20 22:55:07 +08:00
|
|
|
id("com.jfrog.bintray") version Versions.bintray
|
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-05-23 17:44:34 +08:00
|
|
|
sourceSets.all {
|
|
|
|
target.compilations.all {
|
|
|
|
kotlinOptions {
|
|
|
|
freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=enable"
|
|
|
|
jvmTarget = "1.8"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
languageSettings.apply {
|
|
|
|
enableLanguageFeature("InlineClasses")
|
|
|
|
progressiveMode = true
|
|
|
|
|
|
|
|
useExperimentalAnnotation("kotlin.Experimental")
|
|
|
|
useExperimentalAnnotation("kotlin.OptIn")
|
|
|
|
|
|
|
|
useExperimentalAnnotation("net.mamoe.mirai.utils.MiraiInternalAPI")
|
|
|
|
useExperimentalAnnotation("net.mamoe.mirai.utils.MiraiExperimentalAPI")
|
2020-06-28 07:43:58 +08:00
|
|
|
useExperimentalAnnotation("net.mamoe.mirai.console.utils.ConsoleExperimentalAPI")
|
2020-05-23 17:44:34 +08:00
|
|
|
useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
|
|
|
|
useExperimentalAnnotation("kotlin.experimental.ExperimentalTypeInference")
|
|
|
|
useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-05 09:45:54 +08:00
|
|
|
sourceSets {
|
2020-05-23 17:44:34 +08:00
|
|
|
getByName("test") {
|
|
|
|
languageSettings.apply {
|
|
|
|
languageVersion = "1.4"
|
|
|
|
}
|
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-06-20 22:55:07 +08:00
|
|
|
compileAndRuntime("net.mamoe:mirai-core:${Versions.core}")
|
2020-05-14 16:05:42 +08:00
|
|
|
compileAndRuntime(kotlin("stdlib"))
|
2020-03-04 22:15:46 +08:00
|
|
|
|
2020-05-22 19:33:46 +08:00
|
|
|
api("net.mamoe.yamlkt:yamlkt:0.3.1")
|
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-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-06-23 22:05:46 +08:00
|
|
|
ext {
|
|
|
|
// 傻逼 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
|
|
|
|
"net.mamoe:mirai-core-qqandroid" -> true
|
|
|
|
else -> false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.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 {
|
|
|
|
doLast {
|
2020-06-23 22:25:43 +08:00
|
|
|
return@doLast //
|
2020-06-21 14:24:17 +08:00
|
|
|
(compileKotlin as KotlinCompile).source.filter { it.name == "MiraiConsole.kt" }.single().let { file ->
|
|
|
|
file.writeText(file.readText()
|
|
|
|
.replace(Regex("""val buildDate: Date = Date\((.*)\) //(.*)""")) {
|
|
|
|
"""
|
2020-06-22 12:30:36 +08:00
|
|
|
val buildDate: Date = Date(${System.currentTimeMillis()}L) // ${SimpleDateFormat("yyyy-MM-dd HH:mm:ss").apply {
|
2020-06-21 14:24:17 +08:00
|
|
|
timeZone = TimeZone.getTimeZone("GMT+8")
|
|
|
|
}.format(Date())}
|
|
|
|
""".trimIndent()
|
|
|
|
}
|
|
|
|
.replace(Regex("""const val version: String = "(.*)"""")) {
|
|
|
|
"""
|
|
|
|
const val version: String = "${Versions.console}"
|
|
|
|
""".trimIndent()
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"compileKotlin" {
|
|
|
|
dependsOn(fillBuildConstants)
|
|
|
|
}
|
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
|
|
|
|
|
|
|
tasks.register("ensureBintrayAvailable") {
|
|
|
|
doLast {
|
|
|
|
if (!Bintray.isBintrayAvailable(project)) {
|
|
|
|
error("bintray isn't available. ")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Bintray.isBintrayAvailable(project)) {
|
|
|
|
bintray {
|
|
|
|
val keyProps = Properties()
|
|
|
|
val keyFile = file("../keys.properties")
|
|
|
|
if (keyFile.exists()) keyFile.inputStream().use { keyProps.load(it) }
|
|
|
|
if (keyFile.exists()) keyFile.inputStream().use { keyProps.load(it) }
|
|
|
|
|
|
|
|
user = Bintray.getUser(project)
|
|
|
|
key = Bintray.getKey(project)
|
|
|
|
setPublications("mavenJava")
|
|
|
|
setConfigurations("archives")
|
|
|
|
|
|
|
|
pkg.apply {
|
|
|
|
repo = "mirai"
|
|
|
|
name = "mirai-console"
|
|
|
|
setLicenses("AGPLv3")
|
|
|
|
publicDownloadNumbers = true
|
|
|
|
vcsUrl = "https://github.com/mamoe/mirai-console"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Suppress("DEPRECATION")
|
|
|
|
val sourcesJar by tasks.registering(Jar::class) {
|
|
|
|
classifier = "sources"
|
|
|
|
from(sourceSets.main.get().allSource)
|
|
|
|
}
|
|
|
|
|
|
|
|
publishing {
|
|
|
|
/*
|
|
|
|
repositories {
|
|
|
|
maven {
|
|
|
|
// change to point to your repo, e.g. http://my.org/repo
|
|
|
|
url = uri("$buildDir/repo")
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
publications {
|
|
|
|
register("mavenJava", MavenPublication::class) {
|
|
|
|
from(components["java"])
|
|
|
|
|
|
|
|
groupId = rootProject.group.toString()
|
|
|
|
artifactId = "mirai-console"
|
|
|
|
version = version
|
|
|
|
|
|
|
|
pom.withXml {
|
|
|
|
val root = asNode()
|
|
|
|
root.appendNode("description", description)
|
|
|
|
root.appendNode("name", project.name)
|
|
|
|
root.appendNode("url", "https://github.com/mamoe/mirai")
|
|
|
|
root.children().last()
|
|
|
|
}
|
|
|
|
|
|
|
|
artifact(sourcesJar.get())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-23 17:44:34 +08:00
|
|
|
} else println("bintray isn't available. NO PUBLICATIONS WILL BE SET")
|
|
|
|
|
|
|
|
// endregion
|