Merge remote-tracking branch 'origin/master'

# Conflicts:
#	gradle.properties
This commit is contained in:
jiahua.liu 2020-03-26 22:05:25 +08:00
commit 099e76b188
9 changed files with 108 additions and 77 deletions

View File

@ -0,0 +1,7 @@
plugins {
`kotlin-dsl`
}
repositories {
jcenter()
}

View File

@ -0,0 +1,46 @@
import org.gradle.kotlin.dsl.DependencyHandlerScope
/*
* Copyright 2020 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/master/LICENSE
*/
object Versions {
object Mirai {
const val core = "0.30.0"
const val console = "0.3.6"
const val consoleWrapper = "0.1.3"
}
object Kotlin {
const val stdlib = "1.4-M1"
const val coroutines = "1.3.5-1.4-M1"
const val atomicFU = "0.14.2-1.4-M1"
const val serialization = "0.20.0-1.4-M1"
const val ktor = "1.3.2-1.4-M1"
const val io = "0.1.16"
const val coroutinesIo = "0.1.16"
const val dokka = "0.10.1"
}
object Android {
const val androidGradlePlugin = "3.5.3"
}
object Publishing {
const val bintray = "1.8.4-jetbrains-3"
}
}
@Suppress("unused")
fun DependencyHandlerScope.kotlinx(id: String, version: String) = "org.jetbrains.kotlinx:kotlinx-$id:$version"
@Suppress("unused")
fun DependencyHandlerScope.ktor(id: String, version: String = Versions.Kotlin.ktor) = "io.ktor:ktor-$id:$version"

View File

@ -1,18 +1,20 @@
plugins { plugins {
id("kotlinx-serialization") id("kotlinx-serialization")
id("org.openjfx.javafxplugin") version "0.0.8" // id("org.openjfx.javafxplugin") version "0.0.8"
id("kotlin") id("kotlin")
id("java") id("java")
} }
javafx { //javafx {
version = "13.0.2" // version = "13.0.2"
modules = listOf("javafx.controls") // modules = listOf("javafx.controls")
//mainClassName = "Application" // //mainClassName = "Application"
} //}
apply(plugin = "com.github.johnrengelman.shadow") apply(plugin = "com.github.johnrengelman.shadow")
version = Versions.Mirai.console
tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>() { tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>() {
manifest { manifest {
attributes["Main-Class"] = "net.mamoe.mirai.console.graphical.MiraiGraphicalLoader" attributes["Main-Class"] = "net.mamoe.mirai.console.graphical.MiraiGraphicalLoader"
@ -43,7 +45,7 @@ dependencies {
api(project(":mirai-console")) api(project(":mirai-console"))
api(group = "no.tornado", name = "tornadofx", version = "1.7.19") api(group = "no.tornado", name = "tornadofx", version = "1.7.19")
api(group = "com.jfoenix", name = "jfoenix", version = "9.0.8") api(group = "com.jfoenix", name = "jfoenix", version = "8.0.8")
testApi(group = "org.yaml", name = "snakeyaml", version = "1.25") testApi(group = "org.yaml", name = "snakeyaml", version = "1.25")
} }

View File

@ -17,6 +17,7 @@ internal fun EventTarget.jfxTabPane(op: JFXTabPane.() -> Unit = {}) = JFXTabPane
internal fun EventTarget.jfxButton(text: String = "", graphic: Node? = null, op: Button.() -> Unit = {}) = internal fun EventTarget.jfxButton(text: String = "", graphic: Node? = null, op: Button.() -> Unit = {}) =
JFXButton(text).attachTo(this, op) { JFXButton(text).attachTo(this, op) {
if (graphic != null) it.graphic = graphic if (graphic != null) it.graphic = graphic
it.buttonType = JFXButton.ButtonType.RAISED
} }
fun EventTarget.jfxTextfield(value: String? = null, op: JFXTextField.() -> Unit = {}) = fun EventTarget.jfxTextfield(value: String? = null, op: JFXTextField.() -> Unit = {}) =

View File

@ -7,6 +7,7 @@ plugins {
apply(plugin = "com.github.johnrengelman.shadow") apply(plugin = "com.github.johnrengelman.shadow")
version = Versions.Mirai.console
tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>() { tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>() {
manifest { manifest {

View File

@ -1,21 +1,10 @@
plugins { plugins {
id("kotlin") kotlin("jvm")
kotlin("plugin.serialization")
} }
apply(plugin = "com.github.johnrengelman.shadow") apply(plugin = "com.github.johnrengelman.shadow")
val kotlinVersion: String by rootProject.ext
val coroutinesVersion: String by rootProject.ext
val coroutinesIoVersion: String by rootProject.ext
val atomicFuVersion: String by rootProject.ext
val kotlinXIoVersion: String by rootProject.ext
val ktorVersion: String by rootProject.ext
fun kotlinx(id: String, version: String) = "org.jetbrains.kotlinx:kotlinx-$id:$version"
fun ktor(id: String, version: String) = "io.ktor:ktor-$id:$version"
tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> { tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
manifest { manifest {
attributes["Main-Class"] = "net.mamoe.mirai.console.wrapper.WrapperMain" attributes["Main-Class"] = "net.mamoe.mirai.console.wrapper.WrapperMain"
@ -23,8 +12,6 @@ tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
} }
val miraiVersion: String by rootProject.ext
kotlin { kotlin {
sourceSets { sourceSets {
all { all {
@ -36,15 +23,13 @@ kotlin {
} }
} }
val serializationVersion: String by rootProject.ext
dependencies { dependencies {
//core && protocol //core && protocol
api(kotlin("stdlib", kotlinVersion)) api(kotlin("stdlib", Versions.Kotlin.stdlib))
api(kotlin("serialization", kotlinVersion)) api(kotlin("serialization", Versions.Kotlin.stdlib))
api(kotlin("reflect", kotlinVersion)) api(kotlin("reflect", Versions.Kotlin.stdlib))
api(kotlinx("coroutines-core-common", coroutinesVersion)) api(kotlinx("coroutines-core", Versions.Kotlin.coroutines))
api(kotlinx("serialization-runtime-common", serializationVersion)) api(kotlinx("serialization-runtime-common", serializationVersion))
api(kotlinx("serialization-protobuf-common", serializationVersion)) api(kotlinx("serialization-protobuf-common", serializationVersion))
api(kotlinx("io", kotlinXIoVersion)) api(kotlinx("io", kotlinXIoVersion))
@ -73,7 +58,7 @@ dependencies {
api(kotlinx("serialization-runtime", serializationVersion)) api(kotlinx("serialization-runtime", serializationVersion))
//for slf4j[ktor used] //for slf4j[ktor used]
// api(group = "org.apache.cassandra", name = "cassandra-all", version = "0.8.1") // api(group = "org.apache.cassandra", name = "cassandra-all", version = "0.8.1")
//mirai-console //mirai-console
api(group = "com.alibaba", name = "fastjson", version = "1.2.62") api(group = "com.alibaba", name = "fastjson", version = "1.2.62")
@ -84,7 +69,6 @@ dependencies {
} }
val miraiConsoleWrapperVersion: String by project.ext version = Versions.Mirai.consoleWrapper
version = miraiConsoleWrapperVersion
description = "Console with plugin support for mirai" description = "Console with plugin support for mirai"

View File

@ -1,33 +1,15 @@
import java.util.* import java.util.*
plugins { plugins {
id("kotlinx-serialization") kotlin("jvm")
id("kotlin") kotlin("plugin.serialization")
id("java") id("java")
`maven-publish` `maven-publish`
id("com.jfrog.bintray") id("com.jfrog.bintray")
} }
apply(plugin = "com.github.johnrengelman.shadow") apply(plugin = "com.github.johnrengelman.shadow")
val kotlinVersion: String by rootProject.ext
val atomicFuVersion: String by rootProject.ext
val coroutinesVersion: String by rootProject.ext
val kotlinXIoVersion: String by rootProject.ext
val coroutinesIoVersion: String by rootProject.ext
val klockVersion: String by rootProject.ext
val ktorVersion: String by rootProject.ext
val serializationVersion: String by rootProject.ext
fun kotlinx(id: String, version: String) = "org.jetbrains.kotlinx:kotlinx-$id:$version"
fun ktor(id: String, version: String) = "io.ktor:ktor-$id:$version"
val miraiVersion: String by rootProject.ext
kotlin { kotlin {
sourceSets { sourceSets {
all { all {
@ -39,8 +21,8 @@ kotlin {
} }
} }
dependencies { dependencies {
compileOnly("net.mamoe:mirai-core-jvm:$miraiVersion") compileOnly("net.mamoe:mirai-core-jvm:${Versions.Mirai.core}")
compileOnly("net.mamoe:mirai-core-qqandroid-jvm:$miraiVersion") compileOnly("net.mamoe:mirai-core-qqandroid-jvm:${Versions.Mirai.core}")
compileOnly(group = "com.alibaba", name = "fastjson", version = "1.2.62") compileOnly(group = "com.alibaba", name = "fastjson", version = "1.2.62")
@ -48,23 +30,23 @@ dependencies {
compileOnly(group = "com.moandjiezana.toml", name = "toml4j", version = "0.7.2") compileOnly(group = "com.moandjiezana.toml", name = "toml4j", version = "0.7.2")
compileOnly(kotlin("stdlib", kotlinVersion)) compileOnly(kotlin("stdlib", Versions.Kotlin.stdlib))
compileOnly(kotlin("serialization", kotlinVersion)) compileOnly(kotlin("serialization", Versions.Kotlin.stdlib))
compileOnly(kotlin("reflect", kotlinVersion)) compileOnly(kotlin("reflect", Versions.Kotlin.stdlib))
compileOnly(kotlinx("coroutines-io-jvm", coroutinesIoVersion)) compileOnly(kotlinx("coroutines-io-jvm", Versions.Kotlin.coroutinesIo))
compileOnly(kotlinx("coroutines-core", coroutinesVersion)) compileOnly(kotlinx("coroutines-core", Versions.Kotlin.coroutines))
compileOnly(kotlinx("serialization-runtime", serializationVersion)) compileOnly(kotlinx("serialization-runtime", Versions.Kotlin.serialization))
compileOnly("org.jetbrains.kotlinx:atomicfu:$atomicFuVersion") compileOnly("org.jetbrains.kotlinx:atomicfu:${Versions.Kotlin.atomicFU}")
compileOnly("org.bouncycastle:bcprov-jdk15on:1.64") compileOnly("org.bouncycastle:bcprov-jdk15on:1.64")
compileOnly(ktor("http-cio", ktorVersion)) compileOnly(ktor("http-cio"))
compileOnly(ktor("http-jvm", ktorVersion)) compileOnly(ktor("http-jvm"))
compileOnly(ktor("io-jvm", ktorVersion)) compileOnly(ktor("io-jvm"))
compileOnly(ktor("client-core-jvm", ktorVersion)) compileOnly(ktor("client-core-jvm"))
compileOnly(ktor("client-cio", ktorVersion)) compileOnly(ktor("client-cio"))
compileOnly(ktor("network", ktorVersion)) compileOnly(ktor("network"))
} }
val miraiConsoleVersion: String by project.ext val miraiConsoleVersion: String by project.ext

View File

@ -41,7 +41,7 @@ abstract class AbstractCommandSender : CommandSender {
internal val builder = StringBuilder() internal val builder = StringBuilder()
override fun appendMessage(message: String) { override fun appendMessage(message: String) {
builder.append(message).append("\n") builder.appendln(message)
} }
internal open suspend fun flushMessage() { internal open suspend fun flushMessage() {

View File

@ -28,18 +28,26 @@ include(':mirai-console-wrapper')
try{ try{
def javaVersion = System.getProperty("java.version") def javaVersion = System.getProperty("java.version")
def versionPos = javaVersion.indexOf(".") def versionPos = javaVersion.indexOf(".")
if (versionPos==-1) versionPos = javaVersion.indexOf("-") def javaVersionNum = javaVersion.substring(0, 1).toInteger()
if (versionPos==-1){
println("jdk version unknown") if (javaVersion.startsWith("1.")) {
}else{ javaVersionNum = javaVersion.substring(2, 3).toInteger()
def javaVersionNum = javaVersion.substring(0, versionPos).toInteger() } else {
if (javaVersionNum >= 11) { if (versionPos==-1) versionPos = javaVersion.indexOf("-")
include(':mirai-console-graphical') if (versionPos==-1){
} else { println("jdk version unknown")
println("jdk版本为 "+ javaVersionNum) }else{
println("当前使用的 JDK 版本为 ${System.getProperty("java.version")}, 最低需要 JDK 11 才能引入模块 `:mirai-console-graphical`") javaVersionNum = javaVersion.substring(0, versionPos).toInteger()
} }
} }
if (javaVersionNum <= 8) {
include(':mirai-console-graphical')
} else {
println("jdk版本为 "+ javaVersionNum)
println("当前使用的 JDK 版本为 ${System.getProperty("java.version")}, 模块 `:mirai-console-graphical`不支持JDK 9+\n" +
"请使用OracleJDK 1.8 或使用OpenJDK 1.8并添加Java Fx依赖")
}
}catch(Exception ignored){ }catch(Exception ignored){
println("无法确定 JDK 版本, 将不会引入 `:mirai-console-graphical`") println("无法确定 JDK 版本, 将不会引入 `:mirai-console-graphical`")
} }