diff --git a/build.gradle.kts b/build.gradle.kts index 729d05a..7cac0f7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,6 +3,7 @@ plugins { kotlin("jvm") version kotlinVersion kotlin("plugin.serialization") version kotlinVersion + id("com.github.gmazzo.buildconfig") version "3.1.0" id("net.mamoe.mirai-console") version "2.16.0" } @@ -16,6 +17,14 @@ repositories { mavenCentral() } +buildConfig { + className("BuildConstants") + packageName("org.example.mirai.plugin") + useKotlinOutput() + + buildConfigField("String", "VERSION", "\"${project.version}\"") +} + mirai { noTestCore = true setupConsoleTestRuntime { diff --git a/src/main/java/org/example/mirai/plugin/JavaPluginMain.java b/src/main/java/org/example/mirai/plugin/JavaPluginMain.java index a32d52e..9bc2922 100644 --- a/src/main/java/org/example/mirai/plugin/JavaPluginMain.java +++ b/src/main/java/org/example/mirai/plugin/JavaPluginMain.java @@ -35,7 +35,7 @@ public final class JavaPluginMain extends JavaPlugin { public static final JavaPluginMain INSTANCE = new JavaPluginMain(); private JavaPluginMain() { - super(new JvmPluginDescriptionBuilder("org.example.mirai-example", "0.1.0") + super(new JvmPluginDescriptionBuilder("org.example.mirai-example", BuildConstants.VERSION) .info("EG") .build()); } diff --git a/src/main/kotlin/PluginMain.kt b/src/main/kotlin/PluginMain.kt index c5fcbab..3097302 100644 --- a/src/main/kotlin/PluginMain.kt +++ b/src/main/kotlin/PluginMain.kt @@ -36,7 +36,7 @@ object PluginMain : KotlinPlugin( JvmPluginDescription( id = "org.example.mirai-example", name = "插件示例", - version = "0.1.0" + version = BuildConstants.VERSION ) { author("作者名称或联系方式") info(