Files
MoGoEagleEye/app/build.gradle

361 lines
12 KiB
Groovy
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
import java.text.SimpleDateFormat
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'bugly'
apply from: rootProject.file('gradle/bytex/bytex.gradle')
bugly {
appId = 'ac71228f85' // 注册时分配的App ID
appKey = '3c736249-d6be-4066-b577-b7a6dc975cf7' // 注册时分配的App Key
}
Properties properties = new Properties();
properties.load(project.rootProject.file("gradle.properties").newDataInputStream())
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
defaultConfig {
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode rootProject.versionCode as int
versionName rootProject.versionName
applicationId rootProject.ext.android.applicationId
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
javaCompileOptions {
annotationProcessorOptions {
arguments = [AROUTER_MODULE_NAME: project.getName()]
}
}
multiDexEnabled true
}
packagingOptions {
exclude 'META-INF/proguard/coroutines.pro'
exclude 'META-INF/*'
exclude "/lib/armeabi-v7a/*.so"
}
signingConfigs {
release {
keyAlias = 'CarLauncher'
storeFile file('../keystore/car_launcher.jks')
storePassword 'ZDauto123456'
keyPassword 'ZDauto123456'
}
releaseEB5 {
keyAlias = 'android_platform'
storeFile file('../keystore/EB5/car_launcher.jks')
storePassword 'ZDauto123456'
keyPassword 'ZDauto123456'
}
}
buildTypes {
debug {
debuggable true
minifyEnabled false
zipAlignEnabled false
shrinkResources false
signingConfig signingConfigs.release
manifestPlaceholders = [
MAP_SDK_VERSION: properties.getProperty("MAP_SDK_VERSION")
]
}
release {
debuggable false
minifyEnabled false
zipAlignEnabled false
shrinkResources false
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
manifestPlaceholders = [
MAP_SDK_VERSION: properties.getProperty("MAP_SDK_VERSION")
]
}
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
}
}
flavorDimensions "business", "product", "basic", "env"
productFlavors {
// launcher app
launcher {
dimension "basic"
// 是否作为 launcher 运行
buildConfigField 'boolean', 'IS_LAUNCHER', 'true'
buildConfigField 'String', 'SOCKET_APP_ID', '\"com.mogo.launcher\"'
buildConfigField 'String', 'WORKING_BRANCH_NAME', getWorkingBranchName()
buildConfigField 'String', 'WORKING_BRANCH_HASH', getWorkingBranchHash()
buildConfigField 'String', 'APP_BUILD_TIME', getBuildTime()
buildConfigField 'String', 'MAP_SDK_VERSION', "\"${MAP_SDK_VERSION}\""
buildConfigField 'String', 'MAP_SDK_OPT_VERSION', "\"${MAP_SDK_OPERATION_VERSION}\""
}
noop {
dimension "business"
}
busbase {
dimension "business"
}
taxibase {
dimension "business"
}
sweeper {
dimension "business"
}
shuttle {
dimension "business"
}
// 配置网络环境QA、线上、演示
qa {
dimension "env"
buildConfigField 'int', 'NET_ENV', '2'
buildConfigField 'String', 'URLs', "\"${readFileToJson("qa").replace("\"", "\\\"")}\""
}
online {
dimension "env"
buildConfigField 'int', 'NET_ENV', '3'
buildConfigField 'String', 'URLs', "\"${readFileToJson("online").replace("\"", "\\\"")}\""
}
demo {
dimension "env"
buildConfigField 'int', 'NET_ENV', '4'
buildConfigField 'String', 'URLs', "\"${readFileToJson("demo").replace("\"", "\\\"")}\""
}
}
// 配置不同渠道参数,直接影响功能完整度
apply from: "./productFlavors/fPadLenovo.gradle"
apply from: "./productFlavors/fPadLenovoOchBus.gradle"
apply from: "./productFlavors/fPadLenovoOchTaxi.gradle"
apply from: "./productFlavors/fPadLenovoOchBusPassenger.gradle"
apply from: "./productFlavors/fPadLenovoOchTaxiPassenger.gradle"
apply from: "./productFlavors/fPadLenovoOchSweeper.gradle"
apply from: "./productFlavors/fMultiDisplayOchBus.gradle"
apply from: "./productFlavors/fMultiDisplayOchTaxi.gradle"
apply from: "./productFlavors/fMultiDisplaySweeper.gradle"
variantFilter { variant ->
def names = variant.flavors*.name
//要检查特定的构建类型请使用variant.buildType.name ==“ <buildType>”
// region 过滤noop 的flavors 不带och业务的
if (names.contains("noop") && !names.contains("fPadLenovo")) {
//Gradle会忽略满足上述条件的所有变体
setIgnore(true)
}
// endregion
// region 过滤sweper 的flavors
if (names.contains("sweeper") && !names.contains("fPadLenovoOchSweeper")&& !names.contains("fMultiDisplaySweeper")) {
//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 {
exclude 'META-INF/io.netty.versions.properties'
}
useLibrary 'android.test.runner'
useLibrary 'android.test.base'
useLibrary 'android.test.mock'
}
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
implementation rootProject.ext.dependencies.androidxappcompat
implementation rootProject.ext.dependencies.arouter
implementation rootProject.ext.dependencies.boostmultidex
// debugImplementation rootProject.ext.dependencies.debugleakcanary
// releaseImplementation rootProject.ext.dependencies.releaseleakcanary
implementation rootProject.ext.dependencies.android_start_up
implementation rootProject.ext.dependencies.lancetx_runtime
implementation rootProject.ext.dependencies.mogocustommap
implementation project(':libraries:map-usbcamera')
implementation project(':tts:tts-pad')
implementation project(':core:function-impl:mogo-core-function-startup')
implementation project(':core:function-impl:mogo-core-function-devatools')
implementation project(':core:function-impl:mogo-core-function-datacenter')
implementation project(':core:function-impl:mogo-core-function-biz')
implementation project(':core:function-impl:mogo-core-function-hmi')
implementation project(':core:function-impl:mogo-core-function-map')
implementation project(':core:function-impl:mogo-core-function-chat')
implementation project(':core:function-impl:mogo-core-function-patch')
implementation project(':foudations:mogo-commons')
implementation project(':core:mogo-core-function-call')
implementation project(':core:mogo-core-utils')
implementation project(':core:mogo-core-res')
androidTestImplementation project(':core:mogo-core-function-call')
androidTestImplementation project(':core:mogo-core-res')
apply from: "./functions/och.gradle"
androidTestImplementation rootProject.ext.dependencies.androidx_test_core
androidTestImplementation rootProject.ext.dependencies.androidx_test_core_ktx
androidTestImplementation rootProject.ext.dependencies.androidx_unit_ext
androidTestImplementation rootProject.ext.dependencies.androidx_unit_ext_ktx
androidTestImplementation rootProject.ext.dependencies.androidx_runner
androidTestImplementation rootProject.ext.dependencies.androidx_espresso_core
androidTestImplementation rootProject.ext.dependencies.localbroadcastmanager
}
android.applicationVariants.all { variant ->
def buildTime = new Date().format("yyyyMMdd", TimeZone.getTimeZone("GMT+08:00"))
def flavor = variant.productFlavors.collect { it.name }.join('-')
variant.outputs.all { output ->
outputFileName = [
rootProject.applicationName,
"v${variant.versionName}",
buildTime,
flavor.length() > 0 ? "[${flavor}]" : "",
variant.buildType.name
].findAll { it.length() > 0 }.join('_') << ".apk"
}
}
apply from: "./regroup.gradle"
/**
* @return 获取当前分支名称
*/
def getWorkingBranchName() {
def workingBranchName = ""
def proc = "git rev-parse --abbrev-ref HEAD".execute()
proc.in.eachLine { line -> workingBranchName = line }
proc.err.eachLine { line -> println line }
proc.waitFor()
workingBranchName = "\"${workingBranchName}\""
println "Working branch name: " + workingBranchName
return workingBranchName
}
/**
* @return 获取当前分支hash
*/
def getWorkingBranchHash() {
def workingBranchHash = ""
def proc = "git log -n1 --format=format:%h".execute()
proc.in.eachLine { line -> workingBranchHash = line }
proc.err.eachLine { line -> println line }
proc.waitFor()
println "Working branch hash: " + workingBranchHash
return "\"${workingBranchHash}\""
}
static def getBuildTime() {
def buildTimeFormat = "yyyy-MM-dd HH:mm:ss"
//设置时间格式
SimpleDateFormat formatter = new SimpleDateFormat(buildTimeFormat, Locale.getDefault())
//获取当前时间
Date curDate = new Date(System.currentTimeMillis())
def buildTime = formatter.format(curDate)
return "\"${buildTime}\""
}
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"
}
}
}