Преглед изворни кода

自动获取jar的版本号进行banner的打印

everywhere.z пре 2 година
родитељ
комит
1555cd9441
2 измењених фајлова са 22 додато и 1 уклоњено
  1. 10 1
      liteflow-core/src/main/java/com/yomahub/liteflow/util/LOGOPrinter.java
  2. 12 0
      pom.xml

+ 10 - 1
liteflow-core/src/main/java/com/yomahub/liteflow/util/LOGOPrinter.java

@@ -13,7 +13,7 @@ public class LOGOPrinter {
 	/**
 	 * LiteFlow 当前版本号
 	 */
-	private static final String VERSION_NO = "v2.9.0";
+	private static final String VERSION_NO = getVersion();
 
 	public static void print() {
 		StringBuilder str = new StringBuilder("\n");
@@ -29,4 +29,13 @@ public class LOGOPrinter {
 		str.append("================================================================================================\n");
 		LOG.info(str.toString());
 	}
+
+	private static String getVersion(){
+		Package pkg = LOGOPrinter.class.getPackage();
+		return (pkg != null) ? pkg.getImplementationVersion() : null;
+	}
+
+	public static void main(String[] args) {
+		System.out.println(getVersion());
+	}
 }

+ 12 - 0
pom.xml

@@ -234,6 +234,18 @@
 
 	<build>
 		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-jar-plugin</artifactId>
+				<version>3.2.2</version>
+				<configuration>
+					<archive>
+						<manifest>
+							<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+						</manifest>
+					</archive>
+				</configuration>
+			</plugin>
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-surefire-plugin</artifactId>