mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-04 10:39:15 +08:00
Remove MiraiConsoleBuildConstants from git and generate it everytime on build
This commit is contained in:
parent
d904cd9992
commit
41b424c555
1
mirai-console/backend/mirai-console/.gitignore
vendored
Normal file
1
mirai-console/backend/mirai-console/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
src/internal/MiraiConsoleBuildConstants.kt
|
@ -11,8 +11,8 @@
|
||||
|
||||
import BinaryCompatibilityConfigurator.configureBinaryValidator
|
||||
import BinaryCompatibilityConfigurator.configureBinaryValidators
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import java.time.Instant
|
||||
import java.time.*
|
||||
import java.time.format.*
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
@ -53,29 +53,22 @@ dependencies {
|
||||
}
|
||||
|
||||
tasks {
|
||||
val compileKotlin by getting {}
|
||||
|
||||
register("fillBuildConstants") {
|
||||
val task = register("generateBuildConstants") {
|
||||
group = "mirai"
|
||||
doLast {
|
||||
(compileKotlin as KotlinCompile).source.filter { it.name == "MiraiConsoleBuildConstants.kt" }.single()
|
||||
.let { file ->
|
||||
file.writeText(
|
||||
file.readText()
|
||||
.replace(
|
||||
Regex("""val buildDate: Instant = Instant.ofEpochSecond\(.*\)""")
|
||||
) {
|
||||
"""val buildDate: Instant = Instant.ofEpochSecond(${
|
||||
Instant.now().epochSecond
|
||||
})"""
|
||||
}
|
||||
.replace(
|
||||
Regex("""const val versionConst:\s+String\s+=\s+".*"""")
|
||||
) { """const val versionConst: String = "${project.version}"""" }
|
||||
)
|
||||
}
|
||||
val now = Instant.now()
|
||||
project.file("src/internal/MiraiConsoleBuildConstants.kt").writeText(
|
||||
project.file("src/internal/MiraiConsoleBuildConstants.kt.template").readText()
|
||||
.replace("GENERATION_DATE", now.atZone(ZoneId.systemDefault()).format(DateTimeFormatter.ISO_LOCAL_DATE_TIME))
|
||||
.replace("BUILD_DATE", now.epochSecond.toString())
|
||||
.replace("VERSION_CONSTANT", project.version.toString())
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
getByName("compileKotlin").dependsOn(task)
|
||||
}
|
||||
}
|
||||
|
||||
configurePublishing("mirai-console")
|
||||
|
@ -7,15 +7,19 @@
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
/*
|
||||
* Important: This file is generated on build by Gradle task 'generateBuildConstants', on GENERATION_DATE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.console.internal
|
||||
|
||||
import net.mamoe.mirai.console.util.SemVersion
|
||||
import java.time.Instant
|
||||
|
||||
internal object MiraiConsoleBuildConstants { // auto-filled on build (task :mirai-console:fillBuildConstants)
|
||||
internal object MiraiConsoleBuildConstants {
|
||||
@JvmStatic
|
||||
val buildDate: Instant = Instant.ofEpochSecond(1628666895)
|
||||
const val versionConst: String = "2.7.0"
|
||||
val buildDate: Instant = Instant.ofEpochSecond(BUILD_DATE)
|
||||
const val versionConst: String = "VERSION_CONSTANT"
|
||||
|
||||
@JvmStatic
|
||||
val version: SemVersion = SemVersion(versionConst)
|
Loading…
Reference in New Issue
Block a user