diff --git a/build.gradle b/build.gradle index 21ab1a4..1629e2c 100644 --- a/build.gradle +++ b/build.gradle @@ -43,9 +43,8 @@ final String proj_application_main = "${proj_package}.ServerMain" final String proj_version_base = VERSION final String proj_version_delta = VERSION_DELTA final boolean proj_version_use_delta = Boolean.parseBoolean(USE_DELTA) -String proj_version = proj_version_base -if (proj_version_use_delta) proj_version += "-δ${proj_version_delta}" -if (proj_git) proj_version += "+git.${proj_commit.substring(0, 8)}" + (proj_clean?"":".δ") +final String proj_version = proj_version_base + (proj_version_use_delta ? "-δ${proj_version_delta}" : "") +final String proj_version_full = proj_version + (proj_git ? "+git.${proj_commit.substring(0, 8)}" + (proj_clean?"":".δ") : "") final String proj_version_codename = CODENAME final long proj_code_time = proj_clean ? grgit.head().dateTime.toInstant().toEpochMilli() : System.currentTimeMillis() @@ -64,7 +63,7 @@ if (project.hasProperty("publishMvnRepoUrl")) { } group proj_group -version proj_version +version proj_version_full setArchivesBaseName proj_archive_name repositories { @@ -122,6 +121,7 @@ buildConfig { packageName(proj_package) buildConfigField('String', 'VERSION', "\"${proj_version}\"") + buildConfigField('String', 'VERSION_FULL', "\"${proj_version_full}\"") buildConfigField('String', 'VERSION_BASE', "\"${proj_version_base}\"") buildConfigField('String', 'VERSION_DELTA', proj_version_use_delta ? "\"${proj_version_delta}\"" : "null") buildConfigField('String', 'CODENAME', "\"${proj_version_codename}\"") diff --git a/gradle.properties b/gradle.properties index c8939ed..cdee59b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ MORNY_ARCHIVE_NAME = morny-coeur MORNY_CODE_STORE = https://github.com/Eyre-S/Coeur-Morny-Cono MORNY_COMMIT_PATH = https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s -VERSION = 1.0.0-alpha4.1 +VERSION = 1.0.0-alpha4.2 USE_DELTA = false VERSION_DELTA = diff --git a/src/main/java/cc/sukazyo/cono/morny/MornySystem.java b/src/main/java/cc/sukazyo/cono/morny/MornySystem.java index e15a81e..c00fc86 100644 --- a/src/main/java/cc/sukazyo/cono/morny/MornySystem.java +++ b/src/main/java/cc/sukazyo/cono/morny/MornySystem.java @@ -17,11 +17,23 @@ public class MornySystem { /** * 程序的语义化版本号. *
- * 这个版本号是完整(verbose)构建的——它包含了以下的 {@link #VERSION_BASE}, {@link #VERSION_DELTA}, - * 和简写的 {@link BuildConfig#COMMIT} 字段. + * 这个版本号包含了以下的 {@link #VERSION_BASE}, {@link #VERSION_DELTA} 字段, + * 但不包含作为附加属性的构建时的{@link BuildConfig#COMMIT git 状态}属性 + *
+ * 这个格式的版本号也是在 maven 包仓库中所使用的版本号 * @since 1.0.0-alpha4 */ @BuildConfigField @Nonnull public static final String VERSION = BuildConfig.VERSION; + /** + * 程序的完整语义化版本号. + *
+ * 包含了全部的 {@link #VERSION_BASE}, {@link #VERSION_DELTA}, 以及{@link BuildConfig#COMMIT git 状态}属性。 + * 虽然仍旧不包含{@link #CODENAME}属性 + *
+ * 这个格式的版本号也是 gradle 构建配置使用的版本号,也在普通打包时生成文件时使用 + * @since 1.0.0-alpha4.2 + */ + @BuildConfigField @Nonnull public static final String VERSION_FULL = BuildConfig.VERSION_FULL; /** * 程序的基础版本号. *
@@ -37,6 +49,9 @@ public class MornySystem { * {@link null} 作为值,表示这个字段没有被使用. *
* 版本 delta 会以 {@code -δversion-delta} 的形式附着在 {@link #VERSION_BASE} 之后. + * 两者合并后的版本号格式即为 {@link #VERSION} + *
+ * 在发行版本中一般不应该被使用. *
* 目前并不多被使用. * @since 1.0.0-alpha4 diff --git a/src/main/java/cc/sukazyo/cono/morny/ServerMain.java b/src/main/java/cc/sukazyo/cono/morny/ServerMain.java index d7c4b3a..d07d498 100644 --- a/src/main/java/cc/sukazyo/cono/morny/ServerMain.java +++ b/src/main/java/cc/sukazyo/cono/morny/ServerMain.java @@ -217,7 +217,7 @@ public class ServerMain { - version %s - Morny %s - <%s> [%d]""", - MornySystem.VERSION, + MornySystem.VERSION_FULL, MornySystem.CODENAME.toUpperCase(), MornySystem.getJarMd5(), BuildConfig.CODE_TIMESTAMP )); diff --git a/src/test/java/cc/sukazyo/cono/morny/MornyCLI.java b/src/test/java/cc/sukazyo/cono/morny/MornyCLI.java index c26fca6..ef788b2 100644 --- a/src/test/java/cc/sukazyo/cono/morny/MornyCLI.java +++ b/src/test/java/cc/sukazyo/cono/morny/MornyCLI.java @@ -9,7 +9,7 @@ public class MornyCLI { public static void main (String[] args) { Scanner line = new Scanner(System.in); - System.out.print("$ java -jar morny-coeur-"+BuildConfig.VERSION+".jar " ); + System.out.print("$ java -jar morny-coeur-"+MornySystem.VERSION_FULL+".jar " ); String x = line.nextLine(); ServerMain.main(UniversalCommand.format(x));