Console Wrapper

This commit is contained in:
jiahua.liu 2020-03-06 16:34:17 +08:00
parent 48e92a2ed9
commit 46216e5ab6
3 changed files with 65 additions and 28 deletions

View File

@ -7,6 +7,7 @@ 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 ktorVersion: String by rootProject.ext
@ -33,6 +34,9 @@ kotlin {
}
}
}
val serializationVersion: String by rootProject.ext
dependencies {
api(kotlin("stdlib", kotlinVersion))
@ -40,6 +44,31 @@ dependencies {
api(ktor("client-core-jvm", ktorVersion))
api(ktor("client-cio", ktorVersion))
api(kotlin("reflect"))
api(group = "com.alibaba", name = "fastjson", version = "1.2.62")
api(group = "org.yaml", name = "snakeyaml", version = "1.25")
api(group = "com.moandjiezana.toml", name = "toml4j", version = "0.7.2")
api(kotlin("stdlib", kotlinVersion))
api(kotlin("serialization", kotlinVersion))
api(kotlin("reflect", kotlinVersion))
api(kotlinx("coroutines-io-jvm", coroutinesIoVersion))
api(kotlinx("coroutines-core", coroutinesVersion))
api(kotlinx("serialization-runtime", serializationVersion))
api("org.jetbrains.kotlinx:atomicfu:$atomicFuVersion")
api("org.bouncycastle:bcprov-jdk15on:1.64")
api(ktor("http-cio", ktorVersion))
api(ktor("http-jvm", ktorVersion))
api(ktor("io-jvm", ktorVersion))
api(ktor("client-core-jvm", ktorVersion))
api(ktor("client-cio", ktorVersion))
api(ktor("network", ktorVersion))
}
val miraiConsoleWrapperVersion: String by project.ext

View File

@ -17,6 +17,7 @@ import io.ktor.utils.io.ByteReadChannel
import io.ktor.utils.io.jvm.javaio.copyTo
import kotlinx.coroutines.*
import java.io.File
import java.net.URLClassLoader
import kotlin.system.exitProcess
@ -46,18 +47,26 @@ object WrapperMain {
ConsoleUpdator.versionCheck(type)
}
}
println("Dependency needed:")
runBlocking {
LibManager.downloadIfNeeded()
}
println("Version check complete, starting Mirai")
MiraiClassLoader(
CoreUpdator.getCore()!!,
CoreUpdator.getProtocolLib()!!,
ConsoleUpdator.getFile()!!,
this.javaClass.classLoader
).loadClass(
"net.mamoe.mirai.console.pure.MiraiConsolePureLoader"
).getMethod("main", Array<String>(0) {"null"}.javaClass)
.invoke(null,args)
}
}
class MiraiClassLoader(
val core:File,
val protocol: File,
val console: File
){
}
core:File,
protocol: File,
console: File,
parent: ClassLoader
): URLClassLoader(arrayOf(
core.toURI().toURL(),
protocol.toURI().toURL(),
console.toURI().toURL()
), parent)

View File

@ -50,29 +50,28 @@ dependencies {
// compileOnly("net.mamoe:mirai-core-qqandroid-jvm:$miraiVersion")
api(group = "com.alibaba", name = "fastjson", version = "1.2.62")
api(group = "org.yaml", name = "snakeyaml", version = "1.25")
api(group = "com.moandjiezana.toml", name = "toml4j", version = "0.7.2")
compileOnly(group = "com.alibaba", name = "fastjson", version = "1.2.62")
compileOnly(group = "org.yaml", name = "snakeyaml", version = "1.25")
compileOnly(group = "com.moandjiezana.toml", name = "toml4j", version = "0.7.2")
api(kotlin("stdlib", kotlinVersion))
api(kotlin("serialization", kotlinVersion))
compileOnly(kotlin("stdlib", kotlinVersion))
compileOnly(kotlin("serialization", kotlinVersion))
compileOnly(kotlin("reflect", kotlinVersion))
api(kotlin("reflect", kotlinVersion))
compileOnly(kotlinx("coroutines-io-jvm", coroutinesIoVersion))
compileOnly(kotlinx("coroutines-core", coroutinesVersion))
compileOnly(kotlinx("serialization-runtime", serializationVersion))
compileOnly("org.jetbrains.kotlinx:atomicfu:$atomicFuVersion")
api(kotlinx("coroutines-io-jvm", coroutinesIoVersion))
api(kotlinx("coroutines-core", coroutinesVersion))
api(kotlinx("serialization-runtime", serializationVersion))
api("org.jetbrains.kotlinx:atomicfu:$atomicFuVersion")
compileOnly("org.bouncycastle:bcprov-jdk15on:1.64")
api("org.bouncycastle:bcprov-jdk15on:1.64")
api(ktor("http-cio", ktorVersion))
api(ktor("http-jvm", ktorVersion))
api(ktor("io-jvm", ktorVersion))
api(ktor("client-core-jvm", ktorVersion))
api(ktor("client-cio", ktorVersion))
api(ktor("network", ktorVersion))
compileOnly(ktor("http-cio", ktorVersion))
compileOnly(ktor("http-jvm", ktorVersion))
compileOnly(ktor("io-jvm", ktorVersion))
compileOnly(ktor("client-core-jvm", ktorVersion))
compileOnly(ktor("client-cio", ktorVersion))
compileOnly(ktor("network", ktorVersion))
}
val miraiConsoleVersion: String by project.ext