[6.4.0]
[gradle Flavors 切换]
This commit is contained in:
102
app/build.gradle
102
app/build.gradle
@@ -142,49 +142,9 @@ android {
|
||||
flavorDimensions "project","vehicle" ,"role", "env"
|
||||
productFlavors {
|
||||
|
||||
mogo {
|
||||
dimension "project"
|
||||
buildConfigField 'boolean', 'secure', "true"
|
||||
buildConfigField 'String', 'URLs', "\"${readFileToJson("mogo").replace("\"", "\\\"")}\""
|
||||
buildConfigField 'String', 'mediaUrlConfig', "\"${readMediaUrlConfigFromJsonFile("mogo").replace("\"", "\\\"")}\""
|
||||
buildConfigField 'String', 'musicUrlConfig', "\"${readMusicUrlConfigFromJsonFile("mogo").replace("\"", "\\\"")}\""
|
||||
}
|
||||
yantai {
|
||||
dimension "project"
|
||||
buildConfigField 'boolean', 'secure', "false"
|
||||
buildConfigField 'String', 'URLs', "\"${readFileToJson("yantai").replace("\"", "\\\"")}\""
|
||||
buildConfigField 'String', 'mediaUrlConfig', "\"${readMediaUrlConfigFromJsonFile("yantai").replace("\"", "\\\"")}\""
|
||||
buildConfigField 'String', 'musicUrlConfig', "\"${readMusicUrlConfigFromJsonFile("yantai").replace("\"", "\\\"")}\""
|
||||
}
|
||||
|
||||
dali {
|
||||
dimension "project"
|
||||
buildConfigField 'boolean', 'secure', "true"
|
||||
buildConfigField 'String', 'URLs', "\"${readFileToJson("dali").replace("\"", "\\\"")}\""
|
||||
buildConfigField 'String', 'mediaUrlConfig', "\"${readMediaUrlConfigFromJsonFile("dali").replace("\"", "\\\"")}\""
|
||||
buildConfigField 'String', 'musicUrlConfig', "\"${readMusicUrlConfigFromJsonFile("dali").replace("\"", "\\\"")}\""
|
||||
}
|
||||
saas {
|
||||
dimension "project"
|
||||
buildConfigField 'boolean', 'secure', "true"
|
||||
buildConfigField 'String', 'URLs', "\"${readFileToJson("saas").replace("\"", "\\\"")}\""
|
||||
buildConfigField 'String', 'mediaUrlConfig', "\"${readMediaUrlConfigFromJsonFile("saas").replace("\"", "\\\"")}\""
|
||||
buildConfigField 'String', 'musicUrlConfig', "\"${readMusicUrlConfigFromJsonFile("saas").replace("\"", "\\\"")}\""
|
||||
}
|
||||
// 配置网络环境,QA、线上、演示
|
||||
qa {
|
||||
dimension "env"
|
||||
buildConfigField 'int', 'NET_ENV', '2'
|
||||
}
|
||||
online {
|
||||
dimension "env"
|
||||
buildConfigField 'int', 'NET_ENV', '3'
|
||||
}
|
||||
demo {
|
||||
dimension "env"
|
||||
buildConfigField 'int', 'NET_ENV', '4'
|
||||
}
|
||||
}
|
||||
apply from: "./script/projectFlavors/project.gradle"
|
||||
|
||||
apply from: "./script/roleFlavors/driver.gradle"
|
||||
apply from: "./script/roleFlavors/passenger.gradle"
|
||||
apply from: "./script/roleFlavors/driverpassenger.gradle"
|
||||
@@ -391,64 +351,6 @@ def variantName() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取各车型宣传视频本地配置
|
||||
* @param env
|
||||
* @return
|
||||
*/
|
||||
Object readMediaUrlConfigFromJsonFile(env){
|
||||
try {
|
||||
// 加载config.json 文件
|
||||
File file = new File("${rootDir}/app/config/MediaUrlConfig.json")
|
||||
def jsonSlurper = new JsonSlurper()
|
||||
// 解析json
|
||||
def config = jsonSlurper.parse(file)
|
||||
def flavorNames = variantVehicleName()
|
||||
def jsonOutput = new JsonOutput()
|
||||
def getKey = flavorNames
|
||||
config.get(env).each {key, value ->
|
||||
// 匹配flavor对应的 json
|
||||
if(flavorNames.toLowerCase().contains(key)){
|
||||
getKey = key
|
||||
return true
|
||||
}
|
||||
}
|
||||
return jsonOutput.toJson(config.get(env).get(getKey))
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取各车型宣传视频本地配置
|
||||
* @param env
|
||||
* @return
|
||||
*/
|
||||
Object readMusicUrlConfigFromJsonFile(env){
|
||||
try {
|
||||
// 加载config.json 文件
|
||||
File file = new File("${rootDir}/app/config/MusicUrlConfig.json")
|
||||
def jsonSlurper = new JsonSlurper()
|
||||
// 解析json
|
||||
def config = jsonSlurper.parse(file)
|
||||
def flavorNames = variantVehicleName()
|
||||
def jsonOutput = new JsonOutput()
|
||||
def getKey = flavorNames
|
||||
config.get(env).each {key, value ->
|
||||
// 匹配flavor对应的 json
|
||||
if(flavorNames.toLowerCase().contains(key)){
|
||||
getKey = key
|
||||
return true
|
||||
}
|
||||
}
|
||||
return jsonOutput.toJson(config.get(env).get(getKey))
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
def variantVehicleName() {
|
||||
if(gradle.startParameter.taskNames.size()>0) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"mogo": {
|
||||
"shuttlepassengerb1": {
|
||||
"b1passenger": {
|
||||
"medias": [
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg",
|
||||
@@ -64,71 +64,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"buspassengerb1": {
|
||||
"medias": [
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg",
|
||||
"fileType": 1,
|
||||
"coverImageUrl": "",
|
||||
"title": "1"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png",
|
||||
"fileType": 1,
|
||||
"coverImageUrl": "",
|
||||
"title": "2"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357557335/3.mp4",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png",
|
||||
"title": "3"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg",
|
||||
"fileType": 1,
|
||||
"coverImageUrl": "",
|
||||
"title": "4"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg",
|
||||
"title": "5"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676358660379/6.m4v",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg",
|
||||
"title": "6"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360154589/7.jpg",
|
||||
"fileType": 1,
|
||||
"coverImageUrl": "",
|
||||
"title": "7"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360185500/8.jpg",
|
||||
"fileType": 1,
|
||||
"coverImageUrl": "",
|
||||
"title": "8"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png",
|
||||
"fileType": 1,
|
||||
"coverImageUrl": "",
|
||||
"title": "9"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png",
|
||||
"title": "10"
|
||||
}
|
||||
]
|
||||
},
|
||||
"shuttlepassengerb2": {
|
||||
"b2passenger": {
|
||||
"medias": [
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681716116231/6923474a99a1983c9a0410ad3357888d.mov",
|
||||
@@ -144,7 +80,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"taxiunmannedpassengerocht1t2": {
|
||||
"t1t2passengeroch": {
|
||||
"medias": [
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v",
|
||||
@@ -172,7 +108,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"charterpassengerm1": {
|
||||
"m1passenger": {
|
||||
"medias": [
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v",
|
||||
@@ -202,7 +138,7 @@
|
||||
}
|
||||
},
|
||||
"dali": {
|
||||
"shuttlepassengerb1": {
|
||||
"b1passenger": {
|
||||
"medias": [
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg",
|
||||
@@ -266,71 +202,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"buspassengerb1": {
|
||||
"medias": [
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg",
|
||||
"fileType": 1,
|
||||
"coverImageUrl": "",
|
||||
"title": "1"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png",
|
||||
"fileType": 1,
|
||||
"coverImageUrl": "",
|
||||
"title": "2"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357557335/3.mp4",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png",
|
||||
"title": "3"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg",
|
||||
"fileType": 1,
|
||||
"coverImageUrl": "",
|
||||
"title": "4"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg",
|
||||
"title": "5"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676358660379/6.m4v",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg",
|
||||
"title": "6"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360154589/7.jpg",
|
||||
"fileType": 1,
|
||||
"coverImageUrl": "",
|
||||
"title": "7"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360185500/8.jpg",
|
||||
"fileType": 1,
|
||||
"coverImageUrl": "",
|
||||
"title": "8"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png",
|
||||
"fileType": 1,
|
||||
"coverImageUrl": "",
|
||||
"title": "9"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png",
|
||||
"title": "10"
|
||||
}
|
||||
]
|
||||
},
|
||||
"shuttlepassengerb2": {
|
||||
"b2passenger": {
|
||||
"medias": [
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681716116231/6923474a99a1983c9a0410ad3357888d.mov",
|
||||
@@ -346,7 +218,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"taxiunmannedpassengerochdt1t2": {
|
||||
"t1t2passengerochd": {
|
||||
"medias": [
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v",
|
||||
@@ -374,7 +246,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"charterpassengerm1": {
|
||||
"m1passenger": {
|
||||
"medias": [
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v",
|
||||
@@ -404,7 +276,7 @@
|
||||
}
|
||||
},
|
||||
"yantai": {
|
||||
"shuttlepassengerb1": {
|
||||
"b1passenger": {
|
||||
"medias": [
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681210971943/yangmadou.mp4",
|
||||
@@ -420,23 +292,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"buspassengerb1": {
|
||||
"medias": [
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681210971943/yangmadou.mp4",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1680774790614/yangmadao_photo.jpg",
|
||||
"title": "1"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681210971943/yangmadou.mp4",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1680774790614/yangmadao_photo.jpg",
|
||||
"title": "2"
|
||||
}
|
||||
]
|
||||
},
|
||||
"shuttlepassengerb2": {
|
||||
"b2passenger": {
|
||||
"medias": [
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681716116231/6923474a99a1983c9a0410ad3357888d.mov",
|
||||
@@ -452,7 +308,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"taxiunmannedpassengerocht1t2": {
|
||||
"t1t2passengeroch": {
|
||||
"medias": [
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v",
|
||||
@@ -480,7 +336,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"charterpassengerm1": {
|
||||
"m1passenger": {
|
||||
"medias": [
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v",
|
||||
@@ -510,7 +366,7 @@
|
||||
}
|
||||
},
|
||||
"saas": {
|
||||
"shuttlepassengerb1": {
|
||||
"b1passenger": {
|
||||
"medias": [
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg",
|
||||
@@ -574,71 +430,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"buspassengerochb1": {
|
||||
"medias": [
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357256102/1.jpg",
|
||||
"fileType": 1,
|
||||
"coverImageUrl": "",
|
||||
"title": "1"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png",
|
||||
"fileType": 1,
|
||||
"coverImageUrl": "",
|
||||
"title": "2"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357557335/3.mp4",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357382357/2.png",
|
||||
"title": "3"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg",
|
||||
"fileType": 1,
|
||||
"coverImageUrl": "",
|
||||
"title": "4"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357834634/5.m4v",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg",
|
||||
"title": "5"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676358660379/6.m4v",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676357598483/4.jpg",
|
||||
"title": "6"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360154589/7.jpg",
|
||||
"fileType": 1,
|
||||
"coverImageUrl": "",
|
||||
"title": "7"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360185500/8.jpg",
|
||||
"fileType": 1,
|
||||
"coverImageUrl": "",
|
||||
"title": "8"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png",
|
||||
"fileType": 1,
|
||||
"coverImageUrl": "",
|
||||
"title": "9"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360274126/10.mp4",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1676360224773/9.png",
|
||||
"title": "10"
|
||||
}
|
||||
]
|
||||
},
|
||||
"shuttlepassengerb2": {
|
||||
"b2passenger": {
|
||||
"medias": [
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1681716116231/6923474a99a1983c9a0410ad3357888d.mov",
|
||||
@@ -654,7 +446,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"taxiunmannedpassengerocht1t2": {
|
||||
"t1t2passengeroch": {
|
||||
"medias": [
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v",
|
||||
@@ -682,7 +474,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"charterpassengerm1": {
|
||||
"m1passenger": {
|
||||
"medias": [
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"mogo": {
|
||||
"taxipassengerocht1t2": {
|
||||
"t1t2passengeroch": {
|
||||
"musics": [
|
||||
{
|
||||
"id": "1",
|
||||
@@ -124,7 +124,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"charterpassengerm1": {
|
||||
"m1passenger": {
|
||||
"musics": [
|
||||
{
|
||||
"id": "1",
|
||||
@@ -250,7 +250,7 @@
|
||||
}
|
||||
},
|
||||
"dali": {
|
||||
"charterpassengerm1": {
|
||||
"m1passenger": {
|
||||
"musics": [
|
||||
{
|
||||
"id": "1",
|
||||
@@ -376,7 +376,7 @@
|
||||
}
|
||||
},
|
||||
"yantai": {
|
||||
"charterpassengerm1": {
|
||||
"m1passenger": {
|
||||
"musics": [
|
||||
{
|
||||
"id": "1",
|
||||
@@ -502,7 +502,7 @@
|
||||
}
|
||||
},
|
||||
"saas": {
|
||||
"taxiunmannedpassengerocht1t2": {
|
||||
"t1t2passengeroch": {
|
||||
"musics": [
|
||||
{
|
||||
"id": "1",
|
||||
@@ -626,7 +626,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"charterpassengerm1": {
|
||||
"m1passenger": {
|
||||
"musics": [
|
||||
{
|
||||
"id": "1",
|
||||
|
||||
48
app/script/projectFlavors/project.gradle
Normal file
48
app/script/projectFlavors/project.gradle
Normal file
@@ -0,0 +1,48 @@
|
||||
apply from: "./script/utils.gradle"
|
||||
|
||||
|
||||
project.android.productFlavors {
|
||||
mogo {
|
||||
dimension "project"
|
||||
buildConfigField 'boolean', 'secure', "true"
|
||||
buildConfigField 'String', 'URLs', "\"${readFileToJson("mogo").replace("\"", "\\\"")}\""
|
||||
buildConfigField 'String', 'mediaUrlConfig', "\"${readMediaUrlConfigFromJsonFile("mogo").replace("\"", "\\\"")}\""
|
||||
buildConfigField 'String', 'musicUrlConfig', "\"${readMusicUrlConfigFromJsonFile("mogo").replace("\"", "\\\"")}\""
|
||||
}
|
||||
yantai {
|
||||
dimension "project"
|
||||
buildConfigField 'boolean', 'secure', "false"
|
||||
buildConfigField 'String', 'URLs', "\"${readFileToJson("yantai").replace("\"", "\\\"")}\""
|
||||
buildConfigField 'String', 'mediaUrlConfig', "\"${readMediaUrlConfigFromJsonFile("yantai").replace("\"", "\\\"")}\""
|
||||
buildConfigField 'String', 'musicUrlConfig', "\"${readMusicUrlConfigFromJsonFile("yantai").replace("\"", "\\\"")}\""
|
||||
}
|
||||
|
||||
dali {
|
||||
dimension "project"
|
||||
buildConfigField 'boolean', 'secure', "true"
|
||||
buildConfigField 'String', 'URLs', "\"${readFileToJson("dali").replace("\"", "\\\"")}\""
|
||||
buildConfigField 'String', 'mediaUrlConfig', "\"${readMediaUrlConfigFromJsonFile("dali").replace("\"", "\\\"")}\""
|
||||
buildConfigField 'String', 'musicUrlConfig', "\"${readMusicUrlConfigFromJsonFile("dali").replace("\"", "\\\"")}\""
|
||||
}
|
||||
saas {
|
||||
dimension "project"
|
||||
buildConfigField 'boolean', 'secure', "true"
|
||||
buildConfigField 'String', 'URLs', "\"${readFileToJson("saas").replace("\"", "\\\"")}\""
|
||||
buildConfigField 'String', 'mediaUrlConfig', "\"${readMediaUrlConfigFromJsonFile("saas").replace("\"", "\\\"")}\""
|
||||
buildConfigField 'String', 'musicUrlConfig', "\"${readMusicUrlConfigFromJsonFile("saas").replace("\"", "\\\"")}\""
|
||||
}
|
||||
|
||||
// 配置网络环境,QA、线上、演示
|
||||
qa {
|
||||
dimension "env"
|
||||
buildConfigField 'int', 'NET_ENV', '2'
|
||||
}
|
||||
online {
|
||||
dimension "env"
|
||||
buildConfigField 'int', 'NET_ENV', '3'
|
||||
}
|
||||
demo {
|
||||
dimension "env"
|
||||
buildConfigField 'int', 'NET_ENV', '4'
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,67 @@
|
||||
import groovy.json.JsonOutput
|
||||
import groovy.json.JsonSlurper
|
||||
|
||||
/**
|
||||
* 读取各车型宣传视频本地配置
|
||||
* @param env
|
||||
* @return
|
||||
*/
|
||||
Object readMediaUrlConfigFromJsonFile(env){
|
||||
try {
|
||||
// 加载config.json 文件
|
||||
File file = new File("${rootDir}/app/config/MediaUrlConfig.json")
|
||||
def jsonSlurper = new JsonSlurper()
|
||||
// 解析json
|
||||
def config = jsonSlurper.parse(file)
|
||||
def flavorNames = variantVehicleName()
|
||||
def jsonOutput = new JsonOutput()
|
||||
def getKey = flavorNames
|
||||
config.get(env).each {key, value ->
|
||||
// 匹配flavor对应的 json
|
||||
println "--------${flavorNames.toLowerCase()}---------${key}"
|
||||
if(flavorNames.toLowerCase().contains(key)){
|
||||
getKey = key
|
||||
return true
|
||||
}
|
||||
}
|
||||
return jsonOutput.toJson(config.get(env).get(getKey))
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 读取各车型宣传视频本地配置
|
||||
* @param env
|
||||
* @return
|
||||
*/
|
||||
Object readMusicUrlConfigFromJsonFile(env){
|
||||
try {
|
||||
// 加载config.json 文件
|
||||
File file = new File("${rootDir}/app/config/MusicUrlConfig.json")
|
||||
def jsonSlurper = new JsonSlurper()
|
||||
// 解析json
|
||||
def config = jsonSlurper.parse(file)
|
||||
def flavorNames = variantVehicleName()
|
||||
def jsonOutput = new JsonOutput()
|
||||
def getKey = flavorNames
|
||||
config.get(env).each {key, value ->
|
||||
// 匹配flavor对应的 json
|
||||
if(flavorNames.toLowerCase().contains(key)){
|
||||
getKey = key
|
||||
return true
|
||||
}
|
||||
}
|
||||
return jsonOutput.toJson(config.get(env).get(getKey))
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
boolean isCurrentDriver(String flavors) {
|
||||
if(isDriver() && isCurrentFlavors(flavors)){
|
||||
return true
|
||||
@@ -48,4 +112,6 @@ ext {
|
||||
isCurrentFlavors = this.&isCurrentFlavors
|
||||
isCurrentDriver = this.&isCurrentDriver
|
||||
isCurrentPassenger = this.&isCurrentPassenger
|
||||
readMediaUrlConfigFromJsonFile = this.&readMediaUrlConfigFromJsonFile
|
||||
readMusicUrlConfigFromJsonFile = this.&readMusicUrlConfigFromJsonFile
|
||||
}
|
||||
Reference in New Issue
Block a user