mirror of
https://github.com/HighCapable/SweetProperty.git
synced 2025-09-05 18:25:35 +08:00
docs: update guide
This commit is contained in:
@@ -70,11 +70,6 @@ sweetProperty {
|
|||||||
// 启用功能
|
// 启用功能
|
||||||
// 你可以分别对 "sourcesCode"、"buildScript" 进行设置
|
// 你可以分别对 "sourcesCode"、"buildScript" 进行设置
|
||||||
isEnable = true
|
isEnable = true
|
||||||
// 设置属性配置文件名称
|
|
||||||
// 一般情况下不需要修改此设置,错误的文件名将导致获取到空键值内容
|
|
||||||
// 如果你有一个自定义名称的属性键值文件,你可以修改这里的设置
|
|
||||||
// 注意:建议为每个项目单独配置,而不是在全局中修改,以防发生问题
|
|
||||||
propertiesFileName = "gradle.properties"
|
|
||||||
// 是否启用排除非字符串类型键值内容
|
// 是否启用排除非字符串类型键值内容
|
||||||
// 默认启用,启用后将从属性键值中排除不是字符串类型的键值及内容
|
// 默认启用,启用后将从属性键值中排除不是字符串类型的键值及内容
|
||||||
// 这可以排除例如一些系统环境变量的配置或内存中的数据
|
// 这可以排除例如一些系统环境变量的配置或内存中的数据
|
||||||
@@ -90,6 +85,18 @@ sweetProperty {
|
|||||||
// 默认启用,启用后将自动识别属性键值内容中的 ${...} 内容并进行替换
|
// 默认启用,启用后将自动识别属性键值内容中的 ${...} 内容并进行替换
|
||||||
// 注意:插值的内容仅会从当前 (当前配置文件) 属性键值列表进行查找
|
// 注意:插值的内容仅会从当前 (当前配置文件) 属性键值列表进行查找
|
||||||
isEnableValueInterpolation = true
|
isEnableValueInterpolation = true
|
||||||
|
// 设置属性配置文件名称数组
|
||||||
|
// 属性配置文件将根据你设置的文件名称自动从当前根项目、子项目以及用户目录的根目录进行获取
|
||||||
|
// 你可以添加多组属性配置文件名称,将按照顺序依次进行读取
|
||||||
|
// 一般情况下不需要修改此设置,错误的文件名将导致获取到空键值内容
|
||||||
|
// 你可以配置 "isAddDefault" 参数来决定是否添加默认的 "gradle.properties" 文件名称
|
||||||
|
// 如果你有一个或多个自定义名称的属性键值文件,你可以修改这里的设置
|
||||||
|
// 注意:建议为每个项目单独配置,而不是在全局中修改,以防发生问题
|
||||||
|
propertiesFileNames(
|
||||||
|
"some_other_1.properties",
|
||||||
|
"some_other_2.properties",
|
||||||
|
isAddDefault = true
|
||||||
|
)
|
||||||
// 设置固定存在的属性键值数组
|
// 设置固定存在的属性键值数组
|
||||||
// 在这里可以设置一些一定存在的键值,这些键值无论能否从属性键值中得到都会进行生成
|
// 在这里可以设置一些一定存在的键值,这些键值无论能否从属性键值中得到都会进行生成
|
||||||
// 这些键值在属性键值存在时使用属性键值的内容,不存在时使用这里设置的内容
|
// 这些键值在属性键值存在时使用属性键值的内容,不存在时使用这里设置的内容
|
||||||
@@ -111,6 +118,21 @@ sweetProperty {
|
|||||||
"exclude.some.key1",
|
"exclude.some.key1",
|
||||||
"exclude.some.key2"
|
"exclude.some.key2"
|
||||||
)
|
)
|
||||||
|
// 设置需要包含的属性键值名称数组
|
||||||
|
// 在这里可以设置一些你希望从已知的属性键值中包含的键值名称
|
||||||
|
// 这些键值在属性键值存在它们时被包含,未被包含的键值不会出现在生成的代码中
|
||||||
|
// 你可以传入 Regex 或使用 String.toRegex 以使用正则功能
|
||||||
|
includeKeys(
|
||||||
|
"include.some.key1",
|
||||||
|
"include.some.key2"
|
||||||
|
)
|
||||||
|
// 设置属性键值规则数组
|
||||||
|
// 你可以设置一组键值规则,使用 "createValueRule" 创建新的规则,用于解析得到的键值内容
|
||||||
|
// 这些键值规则在属性键值存在它们时被应用
|
||||||
|
keyValuesRules(
|
||||||
|
"some.key1" to createValueRule { if (it.contains("_")) it.replace("_", "-") else it },
|
||||||
|
"some.key2" to createValueRule { "$it-value" }
|
||||||
|
)
|
||||||
// 设置从何处生成属性键值
|
// 设置从何处生成属性键值
|
||||||
// 默认为 "CURRENT_PROJECT" 和 "ROOT_PROJECT"
|
// 默认为 "CURRENT_PROJECT" 和 "ROOT_PROJECT"
|
||||||
// 你可以使用以下类型来进行设置
|
// 你可以使用以下类型来进行设置
|
||||||
|
@@ -73,11 +73,6 @@ sweetProperty {
|
|||||||
// Enable functionality
|
// Enable functionality
|
||||||
// You can set "sourcesCode" and "buildScript" respectively
|
// You can set "sourcesCode" and "buildScript" respectively
|
||||||
isEnable = true
|
isEnable = true
|
||||||
// Set properties name
|
|
||||||
// In general, you don't need to modify this setting, the wrong file name will lead to getting empty key-values content
|
|
||||||
// If you have a properties file with a custom name, you can modify the settings here
|
|
||||||
// Note: It is recommended to configure each project individually, rather than modifying globally, in case of problems
|
|
||||||
propertiesFileName = "gradle.properties"
|
|
||||||
// Whether to enable the exclusion of non-string type key-values content
|
// Whether to enable the exclusion of non-string type key-values content
|
||||||
// Enabled by default, when enabled, key-values and content that are not string types will be excluded from the properties key-values
|
// Enabled by default, when enabled, key-values and content that are not string types will be excluded from the properties key-values
|
||||||
// This can exclude e.g. configuration of some system environment variables or data in memory
|
// This can exclude e.g. configuration of some system environment variables or data in memory
|
||||||
@@ -96,7 +91,20 @@ sweetProperty {
|
|||||||
// will be automatically recognized and replaced
|
// will be automatically recognized and replaced
|
||||||
// Note: The interpolated content will only be searching from the current (current configuration file) properties key-values list
|
// Note: The interpolated content will only be searching from the current (current configuration file) properties key-values list
|
||||||
isEnableValueInterpolation = true
|
isEnableValueInterpolation = true
|
||||||
// Set a fixed attribute key-value array
|
// Set properties names array
|
||||||
|
// The properties file will be automatically obtained from the root directory of
|
||||||
|
// the current root project, subproject and user directory according to the file name you set
|
||||||
|
// You can add multiple sets of properties file names, which will be read in order
|
||||||
|
// In general, you don't need to modify this setting, the wrong file name will lead to getting empty key-values content
|
||||||
|
// You can configure the "isAddDefault" parameter to decide whether to add the default "gradle.properties" file name
|
||||||
|
// If you have one or more properties files with custom names, you can modify the settings here
|
||||||
|
// Note: It is recommended to configure each project individually, rather than modifying globally, in case of problems
|
||||||
|
propertiesFileNames(
|
||||||
|
"some_other_1.properties",
|
||||||
|
"some_other_2.properties",
|
||||||
|
isAddDefault = true
|
||||||
|
)
|
||||||
|
// Set fixed properties key-values array
|
||||||
// Here you can set some key values that must exist,
|
// Here you can set some key values that must exist,
|
||||||
// and these key values will be generated regardless of whether they can be obtained from the properties key-values
|
// and these key values will be generated regardless of whether they can be obtained from the properties key-values
|
||||||
// These key-values use the content of the properties key-values when the properties key-values exists,
|
// These key-values use the content of the properties key-values when the properties key-values exists,
|
||||||
@@ -110,7 +118,7 @@ sweetProperty {
|
|||||||
"permanent.some.key1" to "some_value_1",
|
"permanent.some.key1" to "some_value_1",
|
||||||
"permanent.some.key2" to "some_value_2"
|
"permanent.some.key2" to "some_value_2"
|
||||||
)
|
)
|
||||||
// Set an array of properties key-values names that need to be excluded
|
// Set properties key-values array names that need to be excluded
|
||||||
// Here you can set some key names that you want to exclude from the known properties keys
|
// Here you can set some key names that you want to exclude from the known properties keys
|
||||||
// These keys are excluded when they exist in the properties keys and will not appear in the generated code
|
// These keys are excluded when they exist in the properties keys and will not appear in the generated code
|
||||||
// Note: If you exclude the key-values set in "permanentKeyValues",
|
// Note: If you exclude the key-values set in "permanentKeyValues",
|
||||||
@@ -120,6 +128,22 @@ sweetProperty {
|
|||||||
"exclude.some.key1",
|
"exclude.some.key1",
|
||||||
"exclude.some.key2"
|
"exclude.some.key2"
|
||||||
)
|
)
|
||||||
|
// Set properties key-values array names that need to be included
|
||||||
|
// Here you can set some key-values names that you want to include from known properties keys
|
||||||
|
// These keys are included when the properties key-values exists
|
||||||
|
// Key-values that are not included will not appear in the generated code
|
||||||
|
// You can pass in a Regex or use String.toRegex to use the regex function
|
||||||
|
includeKeys(
|
||||||
|
"include.some.key1",
|
||||||
|
"include.some.key2"
|
||||||
|
)
|
||||||
|
// Set properties key-values rules array
|
||||||
|
// You can set a set of key-values rules and use "createValueRule" to create new rules for parsing the obtained value content
|
||||||
|
// These key-values rules are applied when the properties key-values exists
|
||||||
|
keyValuesRules(
|
||||||
|
"some.key1" to createValueRule { if (it.contains("_")) it.replace("_", "-") else it },
|
||||||
|
"some.key2" to createValueRule { "$it-value" }
|
||||||
|
)
|
||||||
// Set where to generate properties key-values
|
// Set where to generate properties key-values
|
||||||
// Defaults to "CURRENT_PROJECT" and "ROOT_PROJECT"
|
// Defaults to "CURRENT_PROJECT" and "ROOT_PROJECT"
|
||||||
// You can use the following types to set
|
// You can use the following types to set
|
||||||
|
Reference in New Issue
Block a user