Files
MoGoEagleEye/app/build.gradle
tongchenfei a24b3e83ba 调整结构
2020-06-02 18:46:00 +08:00

279 lines
9.3 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 java.text.SimpleDateFormat
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
// buildToolsVersion rootProject.ext.android.buildToolsVersion
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
externalNativeBuild {
ndk {
// 设置支持的SO库架构
abiFilters 'armeabi-v7a'
}
}
}
signingConfigs {
release {
keyAlias = 'CarLauncher'
storeFile file('../keystore/car_launcher.jks')
storePassword 'ZDauto123456'
keyPassword 'ZDauto123456'
}
}
buildTypes {
debug {
signingConfig signingConfigs.release
debuggable = true
}
release {
minifyEnabled false
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
flavorDimensions "product","basic" , "env"
productFlavors {
//独立app
independent{
dimension "basic"
sourceSets {
main {
manifest.srcFile 'src/independent/AndroidManifest.xml'
}
}
applicationId rootProject.ext.android.applicationId
}
// launcher app
launcher{
dimension "basic"
sourceSets {
main {
manifest.srcFile 'src/launcher/AndroidManifest.xml'
}
}
applicationId rootProject.ext.android.zhidadoApplicationId
}
// 诺威达
// nwd {
// dimension "product"
// sourceSets {
// main {
// manifest.srcFile 'src/nwd/AndroidManifest.xml'
// }
// }
// applicationId rootProject.ext.android.applicationId
// }
// d80x {
// dimension "product"
// sourceSets {
// main {
// manifest.srcFile 'src/d80x/AndroidManifest.xml'
// }
// }
// applicationId rootProject.ext.android.zhidadoApplicationId
// }
// zhidao {
// dimension "product"
// sourceSets {
// main {
// manifest.srcFile 'src/zhidao/AndroidManifest.xml'
// }
// }
// applicationId rootProject.ext.android.applicationId
// }
// 通用 APP
catholic {
dimension "product"
}
// f系列-分体机全系列,未细分
f8xx{
dimension "product"
}
qa {
dimension "env"
buildConfigField 'int', 'NET_ENV', '2'
}
online {
dimension "env"
buildConfigField 'int', 'NET_ENV', '3'
}
demo {
dimension "env"
buildConfigField 'int', 'NET_ENV', '4'
}
}
}
def generateVersionCode() {
String vn = rootProject.ext.android.versionName
String[] versions = vn.split("\\.")
if (versions.length == 3) {
int num1 = Integer.valueOf(versions[0])
int num2 = Integer.valueOf(versions[1])
int num3 = Integer.valueOf(versions[2])
if (num1 < 1 || num1 > 99){
throw new GradleException("版本号必须定义为 x.y.zx[1,99], y[0, 99], z[0, 99])")
}
if (num2 < 0 || num2 > 99){
throw new GradleException("版本号必须定义为 x.y.zx[1,99], y[0, 99], z[0, 99])")
}
if (num3 < 0 || num3 > 99){
throw new GradleException("版本号必须定义为 x.y.zx[1,99], y[0, 99], z[0, 99])")
}
StringBuilder builder = new StringBuilder()
builder.append(num1)
if( num2 > 9 ){
builder.append(num2)
} else {
builder.append("0").append(num2)
}
if( num3 > 9 ){
builder.append(num3)
} else {
builder.append("0").append(num3)
}
println("last versionCode ${builder}")
return Integer.valueOf(builder.toString())
} else {
throw new GradleException("版本号必须定义为 x.y.zx[1,99], y[0, 99], z[0, 99])")
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//Crash日志收集
implementation rootProject.ext.dependencies.crashSdk
implementation rootProject.ext.dependencies.androidxappcompat
implementation rootProject.ext.dependencies.arouter
implementation rootProject.ext.dependencies.androidxmultidex
debugImplementation rootProject.ext.dependencies.leakcanary
testImplementation rootProject.ext.dependencies.leakcanary
releaseImplementation rootProject.ext.dependencies.leakcanarynoop
// implementation rootProject.ext.dependencies.moduledemo
// implementation rootProject.ext.dependencies.moduledemo2
implementation rootProject.ext.dependencies.carcallprovider
implementation rootProject.ext.dependencies.carcall
implementation rootProject.ext.dependencies.guideshowprovider
implementation rootProject.ext.dependencies.guideshow
implementation rootProject.ext.dependencies.modulemedia
implementation rootProject.ext.dependencies.modulepush, {
exclude group: 'com.mogo.module', module: 'module-common'
}
implementation rootProject.ext.dependencies.moduleadcard
implementation rootProject.ext.dependencies.moduleonlinecar
implementation rootProject.ext.dependencies.moduleV2x
implementation rootProject.ext.dependencies.moduletanlu, {
exclude group: 'com.mogo.module', module: 'module-share'
}
if (Boolean.valueOf(RELEASE)) {
launcherApi rootProject.ext.dependencies.modulemainlauncher
independentApi rootProject.ext.dependencies.modulemainindependent
api rootProject.ext.dependencies.mogocommons
implementation rootProject.ext.dependencies.modulecommon
implementation rootProject.ext.dependencies.modulesearch
implementation rootProject.ext.dependencies.mogomoduleback
implementation rootProject.ext.dependencies.mogomoduleguide
implementation rootProject.ext.dependencies.mogomoduleauth
debugImplementation rootProject.ext.dependencies.gpssimulatordebug
releaseImplementation rootProject.ext.dependencies.gpssimulatornoop
} else {
launcherImplementation project(':main-extensions:mogo-module-main-launcher')
independentImplementation project(':main-extensions:mogo-module-main-independent')
implementation project(':foudations:mogo-commons')
implementation project(':modules:mogo-module-common')
implementation project(':modules:mogo-module-search')
implementation project(':modules:mogo-module-back')
implementation project(':modules:mogo-module-guide')
implementation project(':modules:mogo-module-authorize')
debugImplementation project(':modules:mogo-module-gps-simulator-debug')
releaseImplementation project(':modules:mogo-module-gps-simulator-noop')
}
}
//android.applicationVariants.all { variant ->
// variant.outputs.all { //这里修改apk文件名
// outputFileName = "Launcher2.0_V${android.defaultConfig.versionName}_${getCurrentDate()}_${variant.name}_${getGitCommit()}.apk"
// println outputFileName
// }
//}
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"
}
}
def getMonthAndDay() {
SimpleDateFormat sdf = new SimpleDateFormat("MMddHH")
return sdf.format(new Date())
}
def getCurrentDate() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss")
return sdf.format(new Date())
}
def getGitCommit() {
def gitDir = new File("${new File("${rootDir}")}/.git")
if (!gitDir.isDirectory()) {
return 'non_git_build'
}
def cmd = 'git log --pretty=format:%h -1'
def gitCommit = cmd.execute().text.trim()
print gitCommit
def cmd2 = 'git status -s'
def gitStatus = cmd2.execute().text.trim()
println '---------'
print gitStatus
if (gitStatus != null && !gitStatus.isEmpty()) {
return 'local-build'
}
assert !gitCommit.isEmpty()
gitCommit
}