mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-27 00:30:17 +08:00
Fix build tasks for buildDate, cleanup
This commit is contained in:
parent
218fb2bdcc
commit
98224cfe5e
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
|
import java.time.Instant
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.TimeZone
|
import java.util.TimeZone
|
||||||
|
|
||||||
@ -112,20 +113,14 @@ tasks {
|
|||||||
.let { file ->
|
.let { file ->
|
||||||
file.writeText(
|
file.writeText(
|
||||||
file.readText()
|
file.readText()
|
||||||
.replace(Regex("""val buildDate: Date = Date\((.*)\) //(.*)""")) {
|
.replace(
|
||||||
"""
|
"""val buildDate: Instant = Instant.ofEpochSecond(0)""",
|
||||||
val buildDate: Date = Date(${System.currentTimeMillis()}L) // ${
|
"""val buildDate: Instant = Instant.ofEpochSecond(${Instant.now().getEpochSecond()})"""
|
||||||
SimpleDateFormat("yyyy-MM-dd HH:mm:ss").apply {
|
)
|
||||||
timeZone = TimeZone.getTimeZone("GMT+8")
|
.replace(
|
||||||
}.format(Date())
|
"""val version: Semver = Semver("0", Semver.SemverType.LOOSE)""",
|
||||||
}
|
"""val version: Semver = Semver("${project.version}", Semver.SemverType.LOOSE)"""
|
||||||
""".trimIndent()
|
)
|
||||||
}
|
|
||||||
.replace(Regex("""const val version: String = "(.*)"""")) {
|
|
||||||
"""
|
|
||||||
const val version: String = "${Versions.console}"
|
|
||||||
""".trimIndent()
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@ import java.time.Instant
|
|||||||
|
|
||||||
internal object MiraiConsoleBuildConstants { // auto-filled on build (task :mirai-console:fillBuildConstants)
|
internal object MiraiConsoleBuildConstants { // auto-filled on build (task :mirai-console:fillBuildConstants)
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
val buildDate: Instant = Instant.ofEpochMilli(1597935352287L) // 2020-08-20 22:55:52
|
val buildDate: Instant = Instant.ofEpochSecond(0)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
val version: Semver = Semver("1.0-M2-1")
|
val version: Semver = Semver("0", Semver.SemverType.LOOSE)
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,9 @@ import net.mamoe.mirai.console.util.ConsoleInput
|
|||||||
import net.mamoe.mirai.console.util.ConsoleInternalAPI
|
import net.mamoe.mirai.console.util.ConsoleInternalAPI
|
||||||
import net.mamoe.mirai.utils.*
|
import net.mamoe.mirai.utils.*
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.text.SimpleDateFormat
|
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
import java.time.ZoneId
|
||||||
|
import java.time.format.DateTimeFormatter
|
||||||
import kotlin.coroutines.CoroutineContext
|
import kotlin.coroutines.CoroutineContext
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,7 +76,8 @@ internal object MiraiConsoleImplementationBridge : CoroutineScope, MiraiConsoleI
|
|||||||
|
|
||||||
@OptIn(ConsoleExperimentalAPI::class)
|
@OptIn(ConsoleExperimentalAPI::class)
|
||||||
internal fun doStart() {
|
internal fun doStart() {
|
||||||
val buildDateFormatted = SimpleDateFormat("yyyy-MM-dd").format(buildDate)
|
val buildDateFormatted =
|
||||||
|
buildDate.atZone(ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
|
||||||
mainLogger.info { "Starting mirai-console..." }
|
mainLogger.info { "Starting mirai-console..." }
|
||||||
mainLogger.info { "Backend: version $version, built on $buildDateFormatted." }
|
mainLogger.info { "Backend: version $version, built on $buildDateFormatted." }
|
||||||
mainLogger.info { frontEndDescription.render() }
|
mainLogger.info { frontEndDescription.render() }
|
||||||
@ -83,6 +85,7 @@ internal object MiraiConsoleImplementationBridge : CoroutineScope, MiraiConsoleI
|
|||||||
if (coroutineContext[Job] == null) {
|
if (coroutineContext[Job] == null) {
|
||||||
throw IllegalMiraiConsoleImplementationError("The coroutineContext given to MiraiConsole must have a Job in it.")
|
throw IllegalMiraiConsoleImplementationError("The coroutineContext given to MiraiConsole must have a Job in it.")
|
||||||
}
|
}
|
||||||
|
|
||||||
MiraiConsole.job.invokeOnCompletion {
|
MiraiConsole.job.invokeOnCompletion {
|
||||||
Bot.botInstances.forEach { kotlin.runCatching { it.close() }.exceptionOrNull()?.let(mainLogger::error) }
|
Bot.botInstances.forEach { kotlin.runCatching { it.close() }.exceptionOrNull()?.let(mainLogger::error) }
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ import java.io.PrintStream
|
|||||||
*/
|
*/
|
||||||
object MiraiConsolePureLoader {
|
object MiraiConsolePureLoader {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun main(args: Array<String>?) {
|
fun main(args: Array<String>) {
|
||||||
startup()
|
startup()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user