apply plugin: 'com.android.application' apply plugin: 'com.alibaba.arouter' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' import java.text.SimpleDateFormat 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", "armeabi-v7a" } } } signingConfigs { release { keyAlias = 'CarLauncher' storeFile file('../keystore/car_launcher.jks') storePassword 'ZDauto123456' keyPassword 'ZDauto123456' } } buildTypes { debug { debuggable = true minifyEnabled false signingConfig signingConfigs.release } release { minifyEnabled true zipAlignEnabled true shrinkResources true signingConfig signingConfigs.release proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility 1.8 targetCompatibility 1.8 } sourceSets { main { manifest.srcFile 'src/main/AndroidManifest.xml' } launcher { manifest.srcFile 'src/launcher/AndroidManifest.xml' } independent { manifest.srcFile 'src/independent/AndroidManifest.xml' } e8xx{ manifest.srcFile 'src/e8xx/AndroidManifest.xml' } em4 { manifest.srcFile 'src/em4/AndroidManifest.xml' } } flavorDimensions "product", "basic", "env" productFlavors { //独立app independent{ dimension "basic" applicationId rootProject.ext.android.independentApplicationId // 是否启动位置服务 buildConfigField 'boolean', 'LAUNCH_LOCATION_SERVICE', 'false' // 是否使用高德sdk自定义导航 buildConfigField 'boolean', 'USE_CUSTOM_NAVI', 'true' // 是否作为 launcher 运行 buildConfigField 'boolean', 'IS_LAUNCHER', 'false' } // launcher app launcher{ dimension "basic" applicationId rootProject.ext.android.launcherApplicationId // 是否启动位置服务 buildConfigField 'boolean', 'LAUNCH_LOCATION_SERVICE', 'true' // 是否使用高德sdk自定义导航 buildConfigField 'boolean', 'USE_CUSTOM_NAVI', 'true' // 是否作为 launcher 运行 buildConfigField 'boolean', 'IS_LAUNCHER', 'true' } // f系列-分体机全系列,未细分 f8xx{ dimension "product" // 使用思必驰语音 buildConfigField 'int', 'AIType','2' buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'false' // 车机类型,主要用于区分自研车机还是别人家的车机,自研车机类型为0 buildConfigField 'int', 'CAR_MACHINE_TYPE', '0' } // e系列,采用Launcher方案 e8xx { dimension "product" // 使用思必驰语音 buildConfigField 'int', 'AIType','2' buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'true' // 车机类型,主要用于区分自研车机还是别人家的车机,自研车机类型为0 buildConfigField 'int', 'CAR_MACHINE_TYPE', '0' } // 同上 em4 { dimension "product" // 使用思必驰语音 buildConfigField 'int', 'AIType','2' buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'true' // 车机类型,主要用于区分自研车机还是别人家的车机,自研车机类型为0 buildConfigField 'int', 'CAR_MACHINE_TYPE', '0' } // e系列-2+32,对标D系列2+32,采用独立app的形式 em3 { dimension "product" // 使用思必驰语音 buildConfigField 'int', 'AIType', '2' buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'true' // 车机类型,主要用于区分自研车机还是别人家的车机,自研车机类型为0 buildConfigField 'int', 'CAR_MACHINE_TYPE', '0' } // e系列-1+16,对标D系列1+16,采用独立app形式 em1 { dimension "product" // 使用思必驰语音 buildConfigField 'int', 'AIType', '2' buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'true' // 车机类型,主要用于区分自研车机还是别人家的车机,自研车机类型为0 buildConfigField 'int', 'CAR_MACHINE_TYPE', '0' } // d系列 d8xx { dimension "product" // 使用同行者语音 buildConfigField 'int', 'AIType','1' buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'true' // 车机类型,主要用于区分自研车机还是别人家的车机,自研车机类型为0 buildConfigField 'int', 'CAR_MACHINE_TYPE', '0' } // d系列 1+16 版本 d82x{ dimension "product" // 使用同行者语音 buildConfigField 'int', 'AIType','1' buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'true' // 车机类型,主要用于区分自研车机还是别人家的车机,自研车机类型为0 buildConfigField 'int', 'CAR_MACHINE_TYPE', '0' } // 比亚迪 bydauto{ dimension "product" // 不使用语音 buildConfigField 'int', 'AIType','0' buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'false' // 车机类型,主要用于区分自研车机还是别人家的车机,其他车机,比亚迪定为1 buildConfigField 'int', 'CAR_MACHINE_TYPE', '1' } qa { dimension "env" buildConfigField 'int', 'NET_ENV', '2' } online { dimension "env" buildConfigField 'int', 'NET_ENV', '3' } demo { dimension "env" buildConfigField 'int', 'NET_ENV', '4' } } packagingOptions { exclude 'META-INF/io.netty.versions.properties' } } 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.z,x[1,99], y[0, 99], z[0, 99])") } if (num2 < 0 || num2 > 99){ throw new GradleException("版本号必须定义为 x.y.z,x[1,99], y[0, 99], z[0, 99])") } if (num3 < 0 || num3 > 99){ throw new GradleException("版本号必须定义为 x.y.z,x[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.z,x[1,99], y[0, 99], z[0, 99])") } } repositories { flatDir { dirs 'libs' } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) //Crash日志收集 implementation rootProject.ext.dependencies.crashSdk implementation rootProject.ext.dependencies.androidxappcompat implementation rootProject.ext.dependencies.arouter implementation rootProject.ext.dependencies.boostmultidex debugImplementation rootProject.ext.dependencies.leakcanary testImplementation rootProject.ext.dependencies.leakcanary releaseImplementation rootProject.ext.dependencies.leakcanarynoop implementation rootProject.ext.dependencies.carcallprovider implementation rootProject.ext.dependencies.carcall implementation rootProject.ext.dependencies.moduletanlu, { exclude group: 'com.mogo.module', module: 'module-share' } if (Boolean.valueOf(RELEASE)) { launcherImplementation rootProject.ext.dependencies.modulemainlauncher independentImplementation rootProject.ext.dependencies.modulemainindependent implementation rootProject.ext.dependencies.mogocommons implementation rootProject.ext.dependencies.modulecommon implementation rootProject.ext.dependencies.modulesearch implementation rootProject.ext.dependencies.mogomoduleguide implementation rootProject.ext.dependencies.mogomoduleauth implementation rootProject.ext.dependencies.modulemedia implementation rootProject.ext.dependencies.moduleservice implementation rootProject.ext.dependencies.modulesplash implementation rootProject.ext.dependencies.moduleV2x } 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-guide') implementation project(':modules:mogo-module-authorize') implementation project(':modules:mogo-module-media') implementation project(':modules:mogo-module-service') implementation project(':modules:mogo-module-splash') implementation project(':modules:mogo-module-v2x') } apply from: "./functions/baseservices.gradle" apply from: "./functions/socketpush.gradle" apply from: "./functions/gpssimulator.gradle" apply from: "./functions/eventpanel.gradle" apply from: "./functions/leftpanel.gradle" } //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 } afterEvaluate { it.getTasks().iterator().forEachRemaining { def nameLowCase = it.name if (nameLowCase.startsWith("assemble") && nameLowCase.contains("Independent") && (nameLowCase.endsWith("Debug") || nameLowCase.endsWith("Release"))) { it.group = "assembleIndependent" } else if (nameLowCase.startsWith("assemble") && nameLowCase.contains("Launcher") && (nameLowCase.endsWith("Debug") || nameLowCase.endsWith("Release"))) { it.group = "assembleLauncher" } else if (nameLowCase.startsWith("install") && nameLowCase.contains("Independent") && (nameLowCase.endsWith("Debug") || nameLowCase.endsWith("Release"))) { it.group = "installIndependent" } else if (nameLowCase.startsWith("install") && nameLowCase.contains("Launcher") && (nameLowCase.endsWith("Debug") || nameLowCase.endsWith("Release"))) { it.group = "installLauncher" } } }