在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):tmiyamon/gradle-config开源软件地址(OpenSource Url):https://github.com/tmiyamon/gradle-config开源编程语言(OpenSource Language):Groovy 88.4%开源软件介绍(OpenSource Introduction):Gradle Config PluginThis plugin helps you to easily handle variant specific settings with yaml format. Usagebuildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.com.tmiyamon:gradle-config:0.2.1"
}
}
apply plugin: 'com.android.application'
apply plugin: "com.tmiyamon.config" Build script snippet for new, incubating, plugin mechanism introduced in Gradle 2.1:
Settings classThe entries in config yaml will be available in
Nested entries are supported:
Config filesConfig entries are generated from:
The lower one overwrites upper one deeply. The purpose of loading settings files with suffix
Accessing Configuration SettingsConsider the following config files. config/default.yml size: 1
server: google.com config/debug.yml size: 2
server: google.com
section:
size: 3
servers: [ {name: yahoo.com}, {name: amazon.com} ] Notice that the variant specific config entries overwrite the common entries. Settings.size // => 2
Settings.server // => google.com Notice that object member notation is maintained even in nested entries. Settings.section.size // => 3 Notice array notation and object member notation is maintained. Settings.section.servers.get(0).name // => yahoo.com
Settings.section.servers.get(1).name // => amazon.com TypeConsider this config file: string_entry: string
int_entry: 1
double_entry: 1.0
date_entry: 2001-11-23 15:03:17
list_entry:
- 1
- 2
failed_list_entry:
- 1
- 'test'
object_entry:
entry_a: 1
entry_b: 2
list_of_map_entry:
- a: 'a1'
b: 'b1'
- a: 'a2'
b: 'b2' The snakeyaml library this plugin uses provides the following basic type conversions: Integer i = Settings.int_entry;
String s = Settings.string_entry;
Double d = Settings.double_entry;
Date da = Settings.date_entry;
List<Integer> list = Settings.list_entry; The list with mixed type elements are not supported and throw an exception.
The nested map entries are converted a generated class to achieve dot access. Settings.ObjectEntry oe = Settings.object_entry;
Integer entryA = object_entry.entry_a;
Integer entryB = object_entry.entry_b; Also, the list of map are supported. List<Settings.ListOfMapEntryElement> entries = Settings.list_of_map_entry; Known issuesNot found Settings classSometimes Android Studio does not detect generated Settings class. When you fact to this problem, License
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论