Skip to content

Commit d133988

Browse files
committed
build: v1.0.0
1 parent e559bea commit d133988

File tree

4 files changed

+75
-3
lines changed

4 files changed

+75
-3
lines changed

pom.xml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>top.naccl</groupId>
88
<artifactId>Java2Doc</artifactId>
9-
<version>0.0.1</version>
9+
<version>${java2doc.version}</version>
1010

1111
<properties>
1212
<java.version>1.8</java.version>
@@ -77,6 +77,24 @@
7777

7878
<build>
7979
<plugins>
80+
<plugin>
81+
<groupId>org.codehaus.mojo</groupId>
82+
<artifactId>properties-maven-plugin</artifactId>
83+
<version>1.0.0</version>
84+
<executions>
85+
<execution>
86+
<phase>initialize</phase>
87+
<goals>
88+
<goal>read-project-properties</goal>
89+
</goals>
90+
<configuration>
91+
<files>
92+
<file>${project.basedir}/src/main/resources/app.properties</file>
93+
</files>
94+
</configuration>
95+
</execution>
96+
</executions>
97+
</plugin>
8098
<plugin>
8199
<groupId>org.apache.maven.plugins</groupId>
82100
<artifactId>maven-assembly-plugin</artifactId>

src/main/java/top/naccl/Cli.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import top.naccl.engine.DocumentType;
1111
import top.naccl.engine.TemplateEngineType;
1212
import top.naccl.execute.DocumentExecute;
13+
import top.naccl.util.PropertiesUtils;
1314

1415
import java.util.Arrays;
1516

@@ -28,7 +29,7 @@ public class Cli {
2829
/**
2930
* 用法提示
3031
*/
31-
private static final String USAGE = "java -jar java2doc.jar -p path1[;path2;path3;...] [-n <projectname>] [-v <version>] [-d <desc>] [-o <outputdir>] [-f <filename>] [-t <doctype>]";
32+
private static final String USAGE = "java -jar Java2Doc-" + PropertiesUtils.getVersion() + ".jar -p path1[;path2;path3;...] [-n <projectname>] [-v <version>] [-d <desc>] [-o <outputdir>] [-f <filename>] [-t <doctype>]";
3233
/**
3334
* 命令行参数列表
3435
*/
@@ -99,7 +100,7 @@ private CommandLine initCli(String[] args) throws ParseException {
99100
* 打印帮助信息
100101
*/
101102
private void printHelp() {
102-
new HelpFormatter().printHelp(150, USAGE, null, options, null);
103+
new HelpFormatter().printHelp(120, USAGE, null, options, null);
103104
}
104105

105106
/**
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package top.naccl.util;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
5+
import java.io.IOException;
6+
import java.io.InputStream;
7+
import java.util.Properties;
8+
9+
/**
10+
* 配置文件工具类
11+
*
12+
* @author: Naccl
13+
* @date: 2022-04-21
14+
*/
15+
@Slf4j
16+
public class PropertiesUtils {
17+
/**
18+
* 配置文件
19+
*/
20+
private static Properties properties;
21+
22+
/**
23+
* 加载配置文件
24+
*/
25+
static {
26+
properties = new Properties();
27+
try (InputStream inputStream = PropertiesUtils.class.getClassLoader().getResourceAsStream("app.properties")) {
28+
properties.load(inputStream);
29+
} catch (IOException e) {
30+
log.error("An exception occurred during the loading of app.properties", e);
31+
}
32+
}
33+
34+
/**
35+
* 获取配置文件中的值
36+
*
37+
* @param key 配置文件中的key
38+
* @return 配置文件中的value
39+
*/
40+
public static String getProperty(String key) {
41+
return properties.getProperty(key);
42+
}
43+
44+
/**
45+
* 获取版本号
46+
*
47+
* @return 版本号
48+
*/
49+
public static String getVersion() {
50+
return properties.getProperty("java2doc.version");
51+
}
52+
}

src/main/resources/app.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
java2doc.version=1.0.0

0 commit comments

Comments
 (0)