Skip to content

Commit b61a174

Browse files
author
ShalMing
committed
build: 升级版本号至 0.3.3并添加版本动态获取功能
- 在 api/pom.xml 中将版本号从 0.3.2 修改为 0.3.3 - 新增 version.properties 文件,用于存储版本号 - 新增 VersionUtils 工具类,用于动态获取版本号 - 在 UserAgentInterceptor 中使用 VersionUtils 替代硬编码版本号 - 更新 example/pom.xml 中的 coze-api 依赖版本为 0.3.3
1 parent 47e0c35 commit b61a174

5 files changed

Lines changed: 36 additions & 3 deletions

File tree

api/pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
</parent>
4444

4545
<artifactId>coze-api</artifactId>
46-
<version>0.3.2</version>
46+
<version>0.3.3</version>
4747

4848
<scm>
4949
<connection>scm:git:git://github.com/coze-dev/coze-java.git</connection>
@@ -193,6 +193,12 @@
193193

194194

195195
<build>
196+
<resources>
197+
<resource>
198+
<directory>src/main/resources</directory>
199+
<filtering>true</filtering>
200+
</resource>
201+
</resources>
196202
<plugins>
197203

198204
<!-- Javadoc plugin -->

api/src/main/java/com/coze/openapi/service/utils/UserAgentInterceptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public Response intercept(Chain chain) throws IOException {
2424
return chain.proceed(request);
2525
}
2626

27-
public static final String VERSION = "0.3.2";
27+
public static final String VERSION = VersionUtils.getVersion();
2828
private static final ObjectMapper objectMapper = new ObjectMapper();
2929

3030
/** 获取操作系统版本 */
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.coze.openapi.service.utils;
2+
3+
import java.io.InputStream;
4+
import java.util.Properties;
5+
6+
public class VersionUtils {
7+
private static final String VERSION = readVersion();
8+
9+
private static String readVersion() {
10+
Properties prop = new Properties();
11+
try (InputStream input =
12+
VersionUtils.class.getClassLoader().getResourceAsStream("version.properties")) {
13+
if (input != null) {
14+
prop.load(input);
15+
return prop.getProperty("sdk.version", "unknown");
16+
}
17+
} catch (Exception e) {
18+
// ignore
19+
}
20+
return "unknown";
21+
}
22+
23+
public static String getVersion() {
24+
return VERSION;
25+
}
26+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sdk.version=${project.version}

example/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<dependency>
1717
<groupId>com.coze</groupId>
1818
<artifactId>coze-api</artifactId>
19-
<version>0.3.2</version>
19+
<version>0.3.3</version>
2020
</dependency>
2121
</dependencies>
2222
</project>

0 commit comments

Comments
 (0)