[2.13.2]
[gradle] [添加业务线模式、业务线可以配置url]
This commit is contained in:
106
app/build.gradle
106
app/build.gradle
@@ -1,4 +1,7 @@
|
|||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
|
import groovy.json.JsonSlurper
|
||||||
|
import groovy.json.JsonOutput
|
||||||
|
|
||||||
|
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
apply plugin: 'com.alibaba.arouter'
|
apply plugin: 'com.alibaba.arouter'
|
||||||
@@ -193,7 +196,7 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flavorDimensions "product", "basic", "env"
|
flavorDimensions "business","product", "basic", "env"
|
||||||
|
|
||||||
productFlavors {
|
productFlavors {
|
||||||
// launcher app
|
// launcher app
|
||||||
@@ -208,18 +211,33 @@ android {
|
|||||||
buildConfigField 'String', 'MAP_SDK_VERSION', "\"${MAP_SDK_VERSION}\""
|
buildConfigField 'String', 'MAP_SDK_VERSION', "\"${MAP_SDK_VERSION}\""
|
||||||
buildConfigField 'String', 'MAP_SDK_OPT_VERSION', "\"${MAP_SDK_OPERATION_VERSION}\""
|
buildConfigField 'String', 'MAP_SDK_OPT_VERSION', "\"${MAP_SDK_OPERATION_VERSION}\""
|
||||||
}
|
}
|
||||||
|
busbase {
|
||||||
|
dimension "business"
|
||||||
|
}
|
||||||
|
taxibase {
|
||||||
|
dimension "business"
|
||||||
|
}
|
||||||
|
sweeper {
|
||||||
|
dimension "business"
|
||||||
|
}
|
||||||
|
shuttle{
|
||||||
|
dimension "business"
|
||||||
|
}
|
||||||
// 配置网络环境,QA、线上、演示
|
// 配置网络环境,QA、线上、演示
|
||||||
qa {
|
qa {
|
||||||
dimension "env"
|
dimension "env"
|
||||||
buildConfigField 'int', 'NET_ENV', '2'
|
buildConfigField 'int', 'NET_ENV', '2'
|
||||||
|
buildConfigField 'String', 'URLs', "\"${readFileToJson("qa").replace("\"","\\\"")}\""
|
||||||
}
|
}
|
||||||
online {
|
online {
|
||||||
dimension "env"
|
dimension "env"
|
||||||
buildConfigField 'int', 'NET_ENV', '3'
|
buildConfigField 'int', 'NET_ENV', '3'
|
||||||
|
buildConfigField 'String', 'URLs', "\"${readFileToJson("online").replace("\"","\\\"")}\""
|
||||||
}
|
}
|
||||||
demo {
|
demo {
|
||||||
dimension "env"
|
dimension "env"
|
||||||
buildConfigField 'int', 'NET_ENV', '4'
|
buildConfigField 'int', 'NET_ENV', '4'
|
||||||
|
buildConfigField 'String', 'URLs', "\"${readFileToJson("demo").replace("\"","\\\"")}\""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,6 +251,51 @@ android {
|
|||||||
apply from: "./productFlavors/fMultiDisplayOchBus.gradle"
|
apply from: "./productFlavors/fMultiDisplayOchBus.gradle"
|
||||||
apply from: "./productFlavors/fMultiDisplayOchTaxi.gradle"
|
apply from: "./productFlavors/fMultiDisplayOchTaxi.gradle"
|
||||||
|
|
||||||
|
variantFilter { variant ->
|
||||||
|
def names = variant.flavors*.name
|
||||||
|
//要检查特定的构建类型,请使用variant.buildType.name ==“ <buildType>”
|
||||||
|
// region 过滤sweper 的flavors
|
||||||
|
if (names.contains("sweeper")&&!names.contains("fPadLenovoOchSweeper")) {
|
||||||
|
//Gradle会忽略满足上述条件的所有变体
|
||||||
|
setIgnore(true)
|
||||||
|
}
|
||||||
|
// endregion
|
||||||
|
|
||||||
|
// region 过滤shuttle 的flavors
|
||||||
|
if (names.contains("shuttle")) {
|
||||||
|
//Gradle会忽略满足上述条件的所有变体
|
||||||
|
if(names.contains("fPadLenovoOchBus")){
|
||||||
|
}else if(names.contains("fPadLenovoOchBusPassenger")){
|
||||||
|
}else {
|
||||||
|
setIgnore(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// endregion
|
||||||
|
// region 过滤taxibase 的flavors
|
||||||
|
if (names.contains("taxibase")) {
|
||||||
|
//Gradle会忽略满足上述条件的所有变体
|
||||||
|
if(names.contains("fPadLenovoOchTaxi")){
|
||||||
|
}else if(names.contains("fPadLenovoOchTaxiPassenger")){
|
||||||
|
}else if(names.contains("fPadLenovo")){
|
||||||
|
}else if(names.contains("fMultiDisplayOchTaxi")){
|
||||||
|
}else {
|
||||||
|
setIgnore(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// endregion
|
||||||
|
// region 过滤taxibase 的flavors
|
||||||
|
if (names.contains("busbase")) {
|
||||||
|
//Gradle会忽略满足上述条件的所有变体
|
||||||
|
if(names.contains("fPadLenovoOchBus")){
|
||||||
|
}else if(names.contains("fPadLenovoOchBusPassenger")){
|
||||||
|
}else if(names.contains("fMultiDisplayOchBus")){
|
||||||
|
}else {
|
||||||
|
setIgnore(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// endregion
|
||||||
|
}
|
||||||
|
|
||||||
packagingOptions {
|
packagingOptions {
|
||||||
exclude 'META-INF/io.netty.versions.properties'
|
exclude 'META-INF/io.netty.versions.properties'
|
||||||
}
|
}
|
||||||
@@ -395,3 +458,44 @@ boolean isReleaseBuild() {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Object readFileToJson(env){
|
||||||
|
try {
|
||||||
|
def businessType = project.hasProperty('business')
|
||||||
|
if(businessType){
|
||||||
|
println("businessType:${businessType}----${business}")
|
||||||
|
}
|
||||||
|
// 加载config.json 文件
|
||||||
|
File file = new File("${rootDir}/app/config.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("busbase").get(env))
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
def variantName() {
|
||||||
|
def taskName = getGradle().getStartParameter().getTaskRequests().toString()
|
||||||
|
def split = taskName.split(":")
|
||||||
|
if (split.length > 2){
|
||||||
|
return split[2].toString().split("]")[0].replace("assemble","")
|
||||||
|
}else {
|
||||||
|
if(taskName.contains("bus")) {
|
||||||
|
return "busbase"
|
||||||
|
}else {
|
||||||
|
return "taxibase"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
46
app/config.json
Normal file
46
app/config.json
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"busbase": {
|
||||||
|
"qa": {
|
||||||
|
"och_url":"https://tech-qa.zhidaohulian.com"
|
||||||
|
},
|
||||||
|
"online": {
|
||||||
|
"och_url":"https://tech.zhidaohulian.com"
|
||||||
|
},
|
||||||
|
"demo": {
|
||||||
|
"och_url":"http://tech-dev.zhidaohulian.com"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"taxibase": {
|
||||||
|
"qa": {
|
||||||
|
"och_url":"https://tech-qa.zhidaohulian.com"
|
||||||
|
},
|
||||||
|
"online": {
|
||||||
|
"och_url":"https://tech.zhidaohulian.com"
|
||||||
|
},
|
||||||
|
"demo": {
|
||||||
|
"och_url":"http://tech-dev.zhidaohulian.com"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"shuttle": {
|
||||||
|
"qa": {
|
||||||
|
"och_url":"https://och-driver-qa.zhidaozhixing.com"
|
||||||
|
},
|
||||||
|
"online": {
|
||||||
|
"och_url":"https://och-driver.zhidaozhixing.com"
|
||||||
|
},
|
||||||
|
"demo": {
|
||||||
|
"och_url":"http://och-driver-dev.zhidaozhixing.com"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sweeper": {
|
||||||
|
"qa": {
|
||||||
|
"och_url":"https://och-driver-qa.zhidaozhixing.com"
|
||||||
|
},
|
||||||
|
"online": {
|
||||||
|
"och_url":"https://och-driver.zhidaozhixing.com"
|
||||||
|
},
|
||||||
|
"demo": {
|
||||||
|
"och_url":"http://och-driver-dev.zhidaozhixing.com"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,7 +9,9 @@ import com.mogo.eagle.core.data.app.AppConfigInfo.workingBranchName
|
|||||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||||
import com.mogo.eagle.core.data.config.HdMapBuildConfig
|
import com.mogo.eagle.core.data.config.HdMapBuildConfig
|
||||||
import com.mogo.eagle.core.data.config.HmiBuildConfig
|
import com.mogo.eagle.core.data.config.HmiBuildConfig
|
||||||
|
import com.mogo.eagle.core.data.deva.net.UrlConfig
|
||||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||||
|
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||||
import com.mogo.eagle.core.utilcode.util.ProcessUtils
|
import com.mogo.eagle.core.utilcode.util.ProcessUtils
|
||||||
import com.mogo.launcher.BuildConfig
|
import com.mogo.launcher.BuildConfig
|
||||||
import com.mogo.launcher.R
|
import com.mogo.launcher.R
|
||||||
@@ -45,6 +47,8 @@ class ConfigStartUp : AndroidStartup<Boolean>() {
|
|||||||
FunctionBuildConfig.isDemoMode = BuildConfig.IS_DEMO_MODE
|
FunctionBuildConfig.isDemoMode = BuildConfig.IS_DEMO_MODE
|
||||||
// // app安装的身份信息
|
// // app安装的身份信息
|
||||||
FunctionBuildConfig.appIdentityMode = BuildConfig.APP_IDENTITY_MODE
|
FunctionBuildConfig.appIdentityMode = BuildConfig.APP_IDENTITY_MODE
|
||||||
|
// 各个module需要的url
|
||||||
|
FunctionBuildConfig.urlJson = GsonUtils.fromJson(BuildConfig.URLs, UrlConfig::class.java)
|
||||||
|
|
||||||
Log.d("ConfigStartUp", "ProcessUtils.getCurrentProcessName():" + ProcessUtils.getCurrentProcessName())
|
Log.d("ConfigStartUp", "ProcessUtils.getCurrentProcessName():" + ProcessUtils.getCurrentProcessName())
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package com.mogo.eagle.core.data.config
|
package com.mogo.eagle.core.data.config
|
||||||
|
|
||||||
|
import com.mogo.eagle.core.data.deva.net.UrlConfig
|
||||||
|
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xiaoyuzhou
|
* @author xiaoyuzhou
|
||||||
* @date 2021/8/24 8:59 下午
|
* @date 2021/8/24 8:59 下午
|
||||||
@@ -173,4 +176,11 @@ object FunctionBuildConfig {
|
|||||||
@JvmField
|
@JvmField
|
||||||
var isPNCWarning = true
|
var isPNCWarning = true
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最外层设置的Url
|
||||||
|
*/
|
||||||
|
@Volatile
|
||||||
|
@JvmField
|
||||||
|
var urlJson: UrlConfig = GsonUtils.fromJson("{\"och_url\":\"https://tech.zhidaohulian.com\"}", UrlConfig::class.java)
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.mogo.eagle.core.data.deva.net
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
|
data class UrlConfig(
|
||||||
|
@SerializedName("och_url")
|
||||||
|
val ochUrl: String
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user