mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-25 03:30:15 +08:00
Automatically generate VersionConstants.kt
This commit is contained in:
parent
9711c5eb3e
commit
fe46ea4740
1
tools/gradle-plugin/.gitignore
vendored
Normal file
1
tools/gradle-plugin/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
src/main/kotlin/VersionConstants.kt
|
@ -111,22 +111,14 @@ tasks {
|
|||||||
val fillBuildConstants by registering {
|
val fillBuildConstants by registering {
|
||||||
group = "mirai"
|
group = "mirai"
|
||||||
doLast {
|
doLast {
|
||||||
projectDir.resolve("src").walk().filter { it.name == "VersionConstants.kt" }.single()
|
projectDir.resolve("src/main/kotlin/VersionConstants.kt").apply { createNewFile() }
|
||||||
.let { file ->
|
.writeText(
|
||||||
file.writeText(
|
projectDir.resolve("src/main/kotlin/VersionConstants.kt.template").readText()
|
||||||
file.readText()
|
.replace("$\$CONSOLE_VERSION$$", Versions.console)
|
||||||
.replace(
|
.replace("$\$CORE_VERSION$$", Versions.core)
|
||||||
Regex("""const val CONSOLE_VERSION = ".*"""")
|
|
||||||
) {
|
|
||||||
"""const val CONSOLE_VERSION = "${Versions.console}""""
|
|
||||||
}
|
|
||||||
.replace(
|
|
||||||
Regex("""const val CORE_VERSION = ".*"""")
|
|
||||||
) { """const val CORE_VERSION = "${Versions.core}"""" }
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
compileKotlin.dependsOn(fillBuildConstants)
|
compileKotlin.dependsOn(fillBuildConstants)
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,6 @@
|
|||||||
package net.mamoe.mirai.console.gradle
|
package net.mamoe.mirai.console.gradle
|
||||||
|
|
||||||
internal object VersionConstants {
|
internal object VersionConstants {
|
||||||
const val CONSOLE_VERSION = "2.8.0" // value is written here automatically during build
|
const val CONSOLE_VERSION = "$$CONSOLE_VERSION$$" // value is written here automatically during build
|
||||||
const val CORE_VERSION = "2.8.0" // value is written here automatically during build
|
const val CORE_VERSION = "$$CORE_VERSION$$" // value is written here automatically during build
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user