-
Notifications
You must be signed in to change notification settings - Fork 8
/
DevVersion.java
136 lines (124 loc) · 3.89 KB
/
DevVersion.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package javadoc.dev_utils;
import java.io.File;
import java.util.Properties;
import dev.utils.common.FileIOUtils;
import dev.utils.common.StringUtils;
/**
* detail: Dev 系列库版本读取
* @author Ttt
*/
final class DevVersion {
private DevVersion() {
}
// ==========
// = 版本信息 =
// ==========
// DevApp 版本号
static final String DEV_APP_VERSION;
// DevAssist 版本号
static final String DEV_ASSIST_VERSION;
// DevBase 版本号
static final String DEV_BASE_VERSION;
// DevBaseMVVM 版本号
static final String DEV_BASE_MVVM_VERSION;
// DevEngine 版本号
static final String DEV_ENGINE_VERSION;
// DevHttpCapture 版本号
static final String DEV_HTTP_CAPTURE_VERSION;
// DevHttpCaptureCompiler 版本号
static final String DEV_HTTP_CAPTURE_COMPILER_VERSION;
// DevHttpManager 版本号
static final String DEV_HTTP_MANAGER_VERSION;
// DevRetrofit 版本号
static final String DEV_RETROFIT_VERSION;
// DevWidget 版本号
static final String DEV_WIDGET_VERSION;
// DevEnvironment 版本号
static final String DEV_ENVIRONMENT_VERSION;
// DevJava 版本号
static final String DEV_JAVA_VERSION;
// ==========
// = 内部逻辑 =
// ==========
static {
File versionsFile = new File(
System.getProperty("user.dir"),
"versions.gradle"
);
// 版本配置属性
Properties prop = new Properties();
try {
prop.load(FileIOUtils.getFileInputStream(versionsFile));
} catch (Exception e) {
throw new RuntimeException(e);
}
// ===============
// = 初始化版本信息 =
// ===============
// DevApp 版本号
DEV_APP_VERSION = getProperty(
prop, "dev_app_versionName"
);
// DevAssist 版本号
DEV_ASSIST_VERSION = getProperty(
prop, "dev_assist_versionName"
);
// DevBase 版本号
DEV_BASE_VERSION = getProperty(
prop, "dev_base_versionName"
);
// DevBaseMVVM 版本号
DEV_BASE_MVVM_VERSION = getProperty(
prop, "dev_base_mvvm_versionName"
);
// DevEngine 版本号
DEV_ENGINE_VERSION = getProperty(
prop, "dev_engine_versionName"
);
// DevHttpCapture 版本号
DEV_HTTP_CAPTURE_VERSION = getProperty(
prop, "dev_http_capture_versionName"
);
// DevHttpCaptureCompiler 版本号
DEV_HTTP_CAPTURE_COMPILER_VERSION = getProperty(
prop, "dev_http_capture_compiler_version"
);
// DevHttpManager 版本号
DEV_HTTP_MANAGER_VERSION = getProperty(
prop, "dev_http_manager_versionName"
);
// DevRetrofit 版本号
DEV_RETROFIT_VERSION = getProperty(
prop, "dev_retrofit_versionName"
);
// DevWidget 版本号
DEV_WIDGET_VERSION = getProperty(
prop, "dev_widget_versionName"
);
// DevEnvironment 版本号
DEV_ENVIRONMENT_VERSION = getProperty(
prop, "dev_environment_version"
);
// DevJava 版本号
DEV_JAVA_VERSION = getProperty(
prop, "dev_java_version"
);
}
// 未知版本默认值
private static final String UNKNOWN = "x.y.z";
/**
* 获取对应 Key 版本信息
* @param prop 版本配置属性
* @param key Key
* @return 对应 Key 版本信息
*/
private static String getProperty(
final Properties prop,
final String key
) {
String version = prop.getProperty(key, UNKNOWN);
version = StringUtils.clearSEWiths(version, ",");
version = StringUtils.clearSEWiths(version, "\"");
return version;
}
}