[m1]
[1.0.2] [url 修改]
This commit is contained in:
@@ -223,10 +223,12 @@ android {
|
||||
|
||||
mogo {
|
||||
dimension "project"
|
||||
buildConfigField 'String', 'URLs', "\"${readFileToJson("mogo").replace("\"", "\\\"")}\""
|
||||
}
|
||||
|
||||
dali {
|
||||
dimension "project"
|
||||
buildConfigField 'String', 'URLs', "\"${readFileToJson("dali").replace("\"", "\\\"")}\""
|
||||
}
|
||||
|
||||
// 空业务 主要是给鹰眼使用
|
||||
@@ -278,7 +280,6 @@ android {
|
||||
apply from: "./productFlavors/fOchSweeper.gradle"
|
||||
apply from: "./productFlavors/fMultiDisplayOchBus.gradle"
|
||||
apply from: "./productFlavors/fMultiDisplayOchTaxi.gradle"
|
||||
apply from: "./productFlavors/urlConfig.gradle"
|
||||
apply from: "./productFlavors/flavorsFilterConfig.gradle"
|
||||
|
||||
packagingOptions {
|
||||
@@ -466,3 +467,43 @@ boolean isReleaseBuild() {
|
||||
return false
|
||||
}
|
||||
|
||||
Object readFileToJson(env){
|
||||
try {
|
||||
// 加载config.json 文件
|
||||
File file = new File("${rootDir}/app/urlConfig.json")
|
||||
def jsonSlurper = new JsonSlurper()
|
||||
// 解析json
|
||||
def config = jsonSlurper.parse(file)
|
||||
def flavorNames = variantName()
|
||||
def jsonOutput = new JsonOutput()
|
||||
config.each {key, value ->
|
||||
// 匹配flavor对应的 json
|
||||
if(flavorNames.toLowerCase().contains(key)){
|
||||
return jsonOutput.toJson(value.get(env))
|
||||
}
|
||||
}
|
||||
// 保底原则
|
||||
return jsonOutput.toJson(config.get(env).get(flavorNames))
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
def variantName() {
|
||||
if(gradle.startParameter.taskNames.size()>0) {
|
||||
def taskName = gradle.startParameter.taskNames[0]
|
||||
if (taskName.endsWith("Qa")) {
|
||||
return "qa"
|
||||
} else if (taskName.endsWith("Online")) {
|
||||
return "online"
|
||||
} else if (taskName.endsWith("Demo")) {
|
||||
return "demo"
|
||||
} else {
|
||||
return "qa"
|
||||
}
|
||||
}else {
|
||||
return "qa"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
import groovy.json.JsonOutput
|
||||
import groovy.json.JsonSlurper
|
||||
|
||||
project.android.applicationVariants.all { variant ->
|
||||
def flavorName = variant.flavorName
|
||||
if (flavorName.startsWith("dali")) {//大理环境
|
||||
if (flavorName.endsWith("Qa")) {
|
||||
buildConfigField 'String', 'URLs', "\"${readFileToJson("dali", "qa").replace("\"", "\\\"")}\""
|
||||
} else if (flavorName.endsWith("Online")) {
|
||||
buildConfigField 'String', 'URLs', "\"${readFileToJson("dali", "online").replace("\"", "\\\"")}\""
|
||||
} else if (flavorName.endsWith("Demo")) {
|
||||
buildConfigField 'String', 'URLs', "\"${readFileToJson("dali", "demo").replace("\"", "\\\"")}\""
|
||||
}
|
||||
} else { // mogo环境
|
||||
if (flavorName.endsWith("Qa")) {
|
||||
buildConfigField 'String', 'URLs', "\"${readFileToJson("mogo", "qa").replace("\"", "\\\"")}\""
|
||||
} else if (flavorName.endsWith("Online")) {
|
||||
buildConfigField 'String', 'URLs', "\"${readFileToJson("mogo", "online").replace("\"", "\\\"")}\""
|
||||
} else if (flavorName.endsWith("Demo")) {
|
||||
buildConfigField 'String', 'URLs', "\"${readFileToJson("mogo", "demo").replace("\"", "\\\"")}\""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Object readFileToJson(project, env) {
|
||||
try {
|
||||
// 加载config.json 文件
|
||||
File file = new File("${rootDir}/app/urlConfig.json")
|
||||
def jsonSlurper = new JsonSlurper()
|
||||
// 解析json
|
||||
def config = jsonSlurper.parse(file)
|
||||
def jsonOutput = new JsonOutput()
|
||||
config.each { key, value ->
|
||||
// 匹配flavor对应的 json
|
||||
if (project.toLowerCase().contains(key)) {
|
||||
return jsonOutput.toJson(value.get(env))
|
||||
}
|
||||
}
|
||||
// 保底原则
|
||||
return jsonOutput.toJson(config.get("mogo").get(env))
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -24,21 +24,21 @@
|
||||
},
|
||||
"dali": {
|
||||
"qa": {
|
||||
"och_url": "https://tech-qa.zhidaohulian.com",
|
||||
"och_url": "https://och-a.zhidaozhixing.com",
|
||||
"shuttle_url": "https://och-a.zhidaozhixing.com",
|
||||
"passport_url": "https://och-a.zhidaozhixing.com/arch/passport/",
|
||||
"socket_base_url": "https://och-a.zhidaozhixing.com/arch/push/",
|
||||
"socket_tech_url": "https://och-a.zhidaozhixing.com/arch/"
|
||||
},
|
||||
"online": {
|
||||
"och_url": "https://tech-qa.zhidaohulian.com",
|
||||
"och_url": "https://och-a.zhidaozhixing.com",
|
||||
"shuttle_url": "https://och-a.zhidaozhixing.com",
|
||||
"passport_url": "https://och-a.zhidaozhixing.com/arch/passport/",
|
||||
"socket_base_url": "https://och-a.zhidaozhixing.com/arch/push/",
|
||||
"socket_tech_url": "https://och-a.zhidaozhixing.com/arch/"
|
||||
},
|
||||
"demo": {
|
||||
"och_url": "https://tech-qa.zhidaohulian.com",
|
||||
"och_url": "https://och-a.zhidaozhixing.com",
|
||||
"shuttle_url": "https://och-a.zhidaozhixing.com",
|
||||
"passport_url": "https://och-a.zhidaozhixing.com/arch/passport/",
|
||||
"socket_base_url": "https://och-a.zhidaozhixing.com/arch/push/",
|
||||
|
||||
Reference in New Issue
Block a user