将带有 git 的 version 更名为 version-full,原先的 version 去除 git 等附加属性,作为 maven 包版本使用

This commit is contained in:
A.C.Sukazyo Eyre 2022-11-09 12:03:17 +08:00
parent 48a8fd9daa
commit 837ec178d3
Signed by: Eyre_S
GPG Key ID: C17CE40291207874
5 changed files with 24 additions and 9 deletions

View File

@ -43,9 +43,8 @@ final String proj_application_main = "${proj_package}.ServerMain"
final String proj_version_base = VERSION final String proj_version_base = VERSION
final String proj_version_delta = VERSION_DELTA final String proj_version_delta = VERSION_DELTA
final boolean proj_version_use_delta = Boolean.parseBoolean(USE_DELTA) final boolean proj_version_use_delta = Boolean.parseBoolean(USE_DELTA)
String proj_version = proj_version_base final String proj_version = proj_version_base + (proj_version_use_delta ? "-δ${proj_version_delta}" : "")
if (proj_version_use_delta) proj_version += "-δ${proj_version_delta}" final String proj_version_full = proj_version + (proj_git ? "+git.${proj_commit.substring(0, 8)}" + (proj_clean?"":".δ") : "")
if (proj_git) proj_version += "+git.${proj_commit.substring(0, 8)}" + (proj_clean?"":".δ")
final String proj_version_codename = CODENAME final String proj_version_codename = CODENAME
final long proj_code_time = proj_clean ? grgit.head().dateTime.toInstant().toEpochMilli() : System.currentTimeMillis() 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 group proj_group
version proj_version version proj_version_full
setArchivesBaseName proj_archive_name setArchivesBaseName proj_archive_name
repositories { repositories {
@ -122,6 +121,7 @@ buildConfig {
packageName(proj_package) packageName(proj_package)
buildConfigField('String', 'VERSION', "\"${proj_version}\"") buildConfigField('String', 'VERSION', "\"${proj_version}\"")
buildConfigField('String', 'VERSION_FULL', "\"${proj_version_full}\"")
buildConfigField('String', 'VERSION_BASE', "\"${proj_version_base}\"") buildConfigField('String', 'VERSION_BASE', "\"${proj_version_base}\"")
buildConfigField('String', 'VERSION_DELTA', proj_version_use_delta ? "\"${proj_version_delta}\"" : "null") buildConfigField('String', 'VERSION_DELTA', proj_version_use_delta ? "\"${proj_version_delta}\"" : "null")
buildConfigField('String', 'CODENAME', "\"${proj_version_codename}\"") buildConfigField('String', 'CODENAME', "\"${proj_version_codename}\"")

View File

@ -5,7 +5,7 @@ MORNY_ARCHIVE_NAME = morny-coeur
MORNY_CODE_STORE = https://github.com/Eyre-S/Coeur-Morny-Cono MORNY_CODE_STORE = https://github.com/Eyre-S/Coeur-Morny-Cono
MORNY_COMMIT_PATH = https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s 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 USE_DELTA = false
VERSION_DELTA = VERSION_DELTA =

View File

@ -17,11 +17,23 @@ public class MornySystem {
/** /**
* 程序的语义化版本号. * 程序的语义化版本号.
* <p> * <p>
* 这个版本号是完整(verbose)构建的它包含了以下的 {@link #VERSION_BASE}, {@link #VERSION_DELTA}, * 这个版本号包含了以下的 {@link #VERSION_BASE}, {@link #VERSION_DELTA} 字段
* 和简写的 {@link BuildConfig#COMMIT} 字段. * 但不包含作为附加属性的构建时的{@link BuildConfig#COMMIT git 状态}属性
* <p>
* 这个格式的版本号也是在 maven 包仓库中所使用的版本号
* @since 1.0.0-alpha4 * @since 1.0.0-alpha4
*/ */
@BuildConfigField @Nonnull public static final String VERSION = BuildConfig.VERSION; @BuildConfigField @Nonnull public static final String VERSION = BuildConfig.VERSION;
/**
* 程序的完整语义化版本号.
* <p>
* 包含了全部的 {@link #VERSION_BASE}, {@link #VERSION_DELTA}, 以及{@link BuildConfig#COMMIT git 状态}属性
* <small>虽然仍旧不包含{@link #CODENAME}属性</small>
* <p>
* 这个格式的版本号也是 gradle 构建配置使用的版本号也在普通打包时生成文件时使用
* @since 1.0.0-alpha4.2
*/
@BuildConfigField @Nonnull public static final String VERSION_FULL = BuildConfig.VERSION_FULL;
/** /**
* 程序的基础版本号. * 程序的基础版本号.
* <p> * <p>
@ -37,6 +49,9 @@ public class MornySystem {
* {@link null} 作为值表示这个字段没有被使用. * {@link null} 作为值表示这个字段没有被使用.
* <p> * <p>
* 版本 delta 会以 {@code -δversion-delta} 的形式附着在 {@link #VERSION_BASE} 之后. * 版本 delta 会以 {@code -δversion-delta} 的形式附着在 {@link #VERSION_BASE} 之后.
* 两者合并后的版本号格式即为 {@link #VERSION}
* <p>
* 在发行版本中一般不应该被使用.
* <p> * <p>
* <small>目前并不多被使用.</small> * <small>目前并不多被使用.</small>
* @since 1.0.0-alpha4 * @since 1.0.0-alpha4

View File

@ -217,7 +217,7 @@ public class ServerMain {
- version %s - version %s
- Morny %s - Morny %s
- <%s> [%d]""", - <%s> [%d]""",
MornySystem.VERSION, MornySystem.VERSION_FULL,
MornySystem.CODENAME.toUpperCase(), MornySystem.CODENAME.toUpperCase(),
MornySystem.getJarMd5(), BuildConfig.CODE_TIMESTAMP MornySystem.getJarMd5(), BuildConfig.CODE_TIMESTAMP
)); ));

View File

@ -9,7 +9,7 @@ public class MornyCLI {
public static void main (String[] args) { public static void main (String[] args) {
Scanner line = new Scanner(System.in); 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(); String x = line.nextLine();
ServerMain.main(UniversalCommand.format(x)); ServerMain.main(UniversalCommand.format(x));