mirror of
https://github.com/Eyre-S/Coeur-Morny-Cono.git
synced 2024-11-22 03:04:54 +08:00
将 GradleProjectConfigures 变更为使用 BuildConfig 工具,添加了 version_delta
- archiveBaseName 更名为 'morny-coeur' - 现在在 getJarMd5 时遇到文件读写错误不会再输出错误堆栈信息了 - gradle 基本的参数化
This commit is contained in:
parent
c2de1b8748
commit
e3c273b370
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,6 +11,7 @@
|
||||
/build/
|
||||
/bin/
|
||||
.project
|
||||
lcoal.properties
|
||||
|
||||
# debug dir
|
||||
/run/
|
||||
|
64
build.gradle
64
build.gradle
@ -1,16 +1,33 @@
|
||||
import java.nio.charset.Charset
|
||||
import java.nio.charset.StandardCharsets
|
||||
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'java-library'
|
||||
id 'maven-publish'
|
||||
id 'application'
|
||||
id 'com.github.johnrengelman.shadow' version '7.1.0'
|
||||
id 'com.github.gmazzo.buildconfig' version '3.1.0'
|
||||
}
|
||||
|
||||
group 'cc.sukazyo'
|
||||
version VERSION
|
||||
project.ext.archiveBaseName = 'Coeur_Morny_Cono'
|
||||
project.ext.artifactId = 'morny-coeur'
|
||||
mainClassName = 'cc.sukazyo.cono.morny.ServerMain'
|
||||
final String proj_group = 'cc.sukazyo'
|
||||
final String proj_package = "${proj_group}.cono.morny"
|
||||
final String proj_archive_name = MORNY_ARCHIVE_NAME
|
||||
|
||||
final String proj_version_base = VERSION
|
||||
final String proj_version_delta = VERSION_DELTA
|
||||
final String proj_version_use_delta = Boolean.parseBoolean(VERSION_DELTA)
|
||||
final String proj_version = proj_version_base + (proj_version_use_delta ? "-δ${proj_version_delta}" : "")
|
||||
final String proj_version_codename = CODENAME
|
||||
|
||||
final JavaVersion proj_java = JavaVersion.VERSION_17
|
||||
final Charset proj_file_encoding = StandardCharsets.UTF_8
|
||||
|
||||
group proj_group
|
||||
version proj_version
|
||||
project.ext.archiveBaseName = proj_archive_name
|
||||
project.ext.artifactId = proj_archive_name
|
||||
mainClassName = "${proj_package}.ServerMain"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@ -31,47 +48,44 @@ dependencies {
|
||||
|
||||
}
|
||||
|
||||
task updateVersionCode {
|
||||
ant.replaceregexp(match:'VERSION = ["a-zA-Z0-9.\\-_+@]+;', replace:"VERSION = \"$project.version\";", flags:'g', byline:true) {
|
||||
fileset(dir: 'src/main/java/cc/sukazyo/cono/morny', includes: 'GradleProjectConfigures.java')
|
||||
}
|
||||
ant.replaceregexp(match:'CODENAME = ["a-zA-Z0-9]+;', replace:"CODENAME = \"${CODENAME}\";", flags:'g', byline:true) {
|
||||
fileset(dir: 'src/main/java/cc/sukazyo/cono/morny', includes: 'GradleProjectConfigures.java')
|
||||
}
|
||||
ant.replaceregexp(match:'COMPILE_TIMESTAMP = [0-9]+L;', replace:"COMPILE_TIMESTAMP = ${System.currentTimeMillis()}L;", flags:'g', byline:true) {
|
||||
fileset(dir: 'src/main/java/cc/sukazyo/cono/morny', includes: 'GradleProjectConfigures.java')
|
||||
}
|
||||
}
|
||||
|
||||
compileJava.dependsOn updateVersionCode
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
java {
|
||||
|
||||
sourceCompatibility JavaVersion.VERSION_17
|
||||
targetCompatibility JavaVersion.VERSION_17
|
||||
sourceCompatibility proj_java
|
||||
targetCompatibility proj_java
|
||||
|
||||
withSourcesJar()
|
||||
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = "UTF-8"
|
||||
options.encoding = proj_file_encoding.name()
|
||||
}
|
||||
|
||||
tasks.withType(Javadoc) {
|
||||
options.encoding = 'UTF-8'
|
||||
options.docEncoding = 'UTF-8'
|
||||
options.charSet = 'UTF-8'
|
||||
options.encoding = proj_file_encoding.name()
|
||||
options.docEncoding = proj_file_encoding.name()
|
||||
options.charSet = proj_file_encoding.name()
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
buildConfig {
|
||||
|
||||
packageName(proj_package)
|
||||
|
||||
buildConfigField('String', 'VERSION', "\"${proj_version}\"")
|
||||
buildConfigField('String', 'VERSION_DELTA', "\"${proj_version_delta}\"")
|
||||
buildConfigField('String', 'CODENAME', "\"${proj_version_codename}\"")
|
||||
buildConfigField('long', 'COMPILE_TIMESTAMP', "${System.currentTimeMillis()}L")
|
||||
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveBaseName.set("${project.ext.archiveBaseName}")
|
||||
archiveVersion.set("${project.version}")
|
||||
|
@ -1,6 +1,11 @@
|
||||
## Core
|
||||
|
||||
VERSION = 1.0.0-alpha1
|
||||
MORNY_ARCHIVE_NAME = morny-coeur
|
||||
|
||||
VERSION = 1.0.0-alpha2
|
||||
|
||||
USE_DELTA = true
|
||||
VERSION_DELTA = 11061900
|
||||
|
||||
CODENAME = beiping
|
||||
|
||||
|
@ -1,10 +0,0 @@
|
||||
package cc.sukazyo.cono.morny;
|
||||
|
||||
/**
|
||||
* the final field that will be updated by gradle automatically.
|
||||
*/
|
||||
public class GradleProjectConfigures {
|
||||
public static final String VERSION = "1.0.0-alpha1";
|
||||
public static final String CODENAME = "beiping";
|
||||
public static final long COMPILE_TIMESTAMP = 1667581079623L;
|
||||
}
|
@ -16,7 +16,7 @@ public class MornySystem {
|
||||
* 程序的语义化版本号<br>
|
||||
* 会由 gradle 任务 {@code updateVersionCode} 更新
|
||||
*/
|
||||
public static final String VERSION = GradleProjectConfigures.VERSION;
|
||||
public static final String VERSION = BuildConfig.VERSION;
|
||||
|
||||
/**
|
||||
* Morny Coeur 当前的版本代号.<br>
|
||||
@ -26,7 +26,7 @@ public class MornySystem {
|
||||
* <br>
|
||||
* 会由 gradle 任务 {@code updateVersionCode} 更新
|
||||
*/
|
||||
public static final String CODENAME = GradleProjectConfigures.CODENAME;
|
||||
public static final String CODENAME = BuildConfig.CODENAME;
|
||||
|
||||
/**
|
||||
* 获取程序 jar 文件的 md5-hash 值<br>
|
||||
@ -43,7 +43,6 @@ public class MornySystem {
|
||||
try {
|
||||
return FileUtils.getMD5Three(MornyCoeur.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
|
||||
} catch (IOException | URISyntaxException e) {
|
||||
e.printStackTrace(System.out);
|
||||
return "<non-jar-runtime>";
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace(System.out);
|
||||
|
@ -192,8 +192,8 @@ public class ServerMain {
|
||||
%s [UTC]""",
|
||||
MornySystem.VERSION, MornySystem.CODENAME.toUpperCase(),
|
||||
MornySystem.getJarMd5(),
|
||||
GradleProjectConfigures.COMPILE_TIMESTAMP,
|
||||
CommonFormat.formatDate(GradleProjectConfigures.COMPILE_TIMESTAMP, 0)
|
||||
BuildConfig.COMPILE_TIMESTAMP,
|
||||
CommonFormat.formatDate(BuildConfig.COMPILE_TIMESTAMP, 0)
|
||||
));
|
||||
return;
|
||||
|
||||
@ -207,7 +207,7 @@ public class ServerMain {
|
||||
- version %s (%s)(%d)
|
||||
- Morny %s""",
|
||||
MornySystem.VERSION,
|
||||
MornySystem.getJarMd5(), GradleProjectConfigures.COMPILE_TIMESTAMP,
|
||||
MornySystem.getJarMd5(), BuildConfig.COMPILE_TIMESTAMP,
|
||||
MornySystem.CODENAME.toUpperCase()
|
||||
));
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package cc.sukazyo.cono.morny.bot.command;
|
||||
|
||||
import cc.sukazyo.cono.morny.GradleProjectConfigures;
|
||||
import cc.sukazyo.cono.morny.BuildConfig;
|
||||
import cc.sukazyo.cono.morny.MornyCoeur;
|
||||
import cc.sukazyo.cono.morny.MornySystem;
|
||||
import cc.sukazyo.cono.morny.data.MornyJrrp;
|
||||
@ -249,8 +249,8 @@ public class MornyCommands {
|
||||
escapeHtml(MornySystem.CODENAME.toUpperCase()),
|
||||
escapeHtml(MornySystem.VERSION),
|
||||
escapeHtml(MornySystem.getJarMd5()),
|
||||
GradleProjectConfigures.COMPILE_TIMESTAMP,
|
||||
escapeHtml(formatDate(GradleProjectConfigures.COMPILE_TIMESTAMP, 0))
|
||||
BuildConfig.COMPILE_TIMESTAMP,
|
||||
escapeHtml(formatDate(BuildConfig.COMPILE_TIMESTAMP, 0))
|
||||
)
|
||||
).replyToMessageId(event.message().messageId()).parseMode(ParseMode.HTML));
|
||||
}
|
||||
@ -310,8 +310,8 @@ public class MornyCommands {
|
||||
escapeHtml(MornySystem.VERSION),
|
||||
escapeHtml(MornySystem.CODENAME),
|
||||
escapeHtml(MornySystem.getJarMd5()),
|
||||
escapeHtml(formatDate(GradleProjectConfigures.COMPILE_TIMESTAMP, 0)),
|
||||
GradleProjectConfigures.COMPILE_TIMESTAMP,
|
||||
escapeHtml(formatDate(BuildConfig.COMPILE_TIMESTAMP, 0)),
|
||||
BuildConfig.COMPILE_TIMESTAMP,
|
||||
// continuous
|
||||
escapeHtml(formatDuration(System.currentTimeMillis() - MornyCoeur.coeurStartTimestamp)),
|
||||
System.currentTimeMillis() - MornyCoeur.coeurStartTimestamp,
|
||||
|
@ -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-"+GradleProjectConfigures.VERSION+".jar " );
|
||||
System.out.print("$ java -jar morny-coeur-"+BuildConfig.VERSION+".jar " );
|
||||
String x = line.nextLine();
|
||||
ServerMain.main(UniversalCommand.format(x));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user