优化 app 模块 build.gradle 文件内容,及重新整理分组方式。
This commit is contained in:
133
app/build.gradle
133
app/build.gradle
@@ -2,11 +2,9 @@ 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
|
||||
@@ -66,13 +64,13 @@ android {
|
||||
independent {
|
||||
manifest.srcFile 'src/independent/AndroidManifest.xml'
|
||||
}
|
||||
e8xx{
|
||||
e8xx {
|
||||
manifest.srcFile 'src/e8xx/AndroidManifest.xml'
|
||||
}
|
||||
em4 {
|
||||
manifest.srcFile 'src/em4/AndroidManifest.xml'
|
||||
}
|
||||
f8xxLauncherOnlineRelease{
|
||||
f8xxLauncherOnlineRelease {
|
||||
manifest.srcFile 'src/f8xxLauncherOnlineRelease/AndroidManifest.xml'
|
||||
}
|
||||
}
|
||||
@@ -81,7 +79,7 @@ android {
|
||||
|
||||
productFlavors {
|
||||
//独立app
|
||||
independent{
|
||||
independent {
|
||||
dimension "basic"
|
||||
// 是否启动位置服务
|
||||
buildConfigField 'boolean', 'LAUNCH_LOCATION_SERVICE', 'false'
|
||||
@@ -90,7 +88,7 @@ android {
|
||||
buildConfigField 'String', 'SOCKET_APP_ID', '\"com.mogo.launcher\"'
|
||||
}
|
||||
// launcher app
|
||||
launcher{
|
||||
launcher {
|
||||
dimension "basic"
|
||||
// 是否启动位置服务
|
||||
buildConfigField 'boolean', 'LAUNCH_LOCATION_SERVICE', 'true'
|
||||
@@ -99,11 +97,11 @@ android {
|
||||
buildConfigField 'String', 'SOCKET_APP_ID', '\"com.mogo.launcher\"'
|
||||
}
|
||||
// f系列-分体机全系列,未细分
|
||||
f8xx{
|
||||
f8xx {
|
||||
applicationId rootProject.ext.android.fLauncherApplicationId
|
||||
dimension "product"
|
||||
// 使用思必驰语音
|
||||
buildConfigField 'int', 'AIType','2'
|
||||
buildConfigField 'int', 'AIType', '2'
|
||||
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'false'
|
||||
// 车机类型,主要用于区分自研车机还是别人家的车机,自研车机类型为0
|
||||
buildConfigField 'int', 'CAR_MACHINE_TYPE', '0'
|
||||
@@ -117,7 +115,7 @@ android {
|
||||
applicationId rootProject.ext.android.launcherApplicationId
|
||||
dimension "product"
|
||||
// 使用思必驰语音
|
||||
buildConfigField 'int', 'AIType','2'
|
||||
buildConfigField 'int', 'AIType', '2'
|
||||
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'true'
|
||||
// 车机类型,主要用于区分自研车机还是别人家的车机,自研车机类型为0
|
||||
buildConfigField 'int', 'CAR_MACHINE_TYPE', '0'
|
||||
@@ -131,7 +129,7 @@ android {
|
||||
applicationId rootProject.ext.android.launcherApplicationId
|
||||
dimension "product"
|
||||
// 使用思必驰语音
|
||||
buildConfigField 'int', 'AIType','2'
|
||||
buildConfigField 'int', 'AIType', '2'
|
||||
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'true'
|
||||
// 车机类型,主要用于区分自研车机还是别人家的车机,自研车机类型为0
|
||||
buildConfigField 'int', 'CAR_MACHINE_TYPE', '0'
|
||||
@@ -173,7 +171,7 @@ android {
|
||||
applicationId rootProject.ext.android.independentApplicationId
|
||||
dimension "product"
|
||||
// 使用同行者语音
|
||||
buildConfigField 'int', 'AIType','1'
|
||||
buildConfigField 'int', 'AIType', '1'
|
||||
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'true'
|
||||
// 车机类型,主要用于区分自研车机还是别人家的车机,自研车机类型为0
|
||||
buildConfigField 'int', 'CAR_MACHINE_TYPE', '0'
|
||||
@@ -183,11 +181,11 @@ android {
|
||||
buildConfigField 'boolean', 'USE_CUSTOM_NAVI', 'false'
|
||||
}
|
||||
// d系列 1+16 版本
|
||||
d82x{
|
||||
d82x {
|
||||
applicationId rootProject.ext.android.independentApplicationId
|
||||
dimension "product"
|
||||
// 使用同行者语音
|
||||
buildConfigField 'int', 'AIType','1'
|
||||
buildConfigField 'int', 'AIType', '1'
|
||||
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'true'
|
||||
// 车机类型,主要用于区分自研车机还是别人家的车机,自研车机类型为0
|
||||
buildConfigField 'int', 'CAR_MACHINE_TYPE', '0'
|
||||
@@ -197,11 +195,11 @@ android {
|
||||
buildConfigField 'boolean', 'USE_CUSTOM_NAVI', 'false'
|
||||
}
|
||||
// 比亚迪
|
||||
bydauto{
|
||||
bydauto {
|
||||
applicationId rootProject.ext.android.bydautoIndependentApplicationId
|
||||
dimension "product"
|
||||
// 不使用语音
|
||||
buildConfigField 'int', 'AIType','0'
|
||||
buildConfigField 'int', 'AIType', '0'
|
||||
buildConfigField 'boolean', 'AI_ASSIST_ACTIVE_STAUTS', 'false'
|
||||
// 车机类型,主要用于区分自研车机还是别人家的车机,其他车机,比亚迪定为1
|
||||
buildConfigField 'int', 'CAR_MACHINE_TYPE', '1'
|
||||
@@ -229,42 +227,6 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
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'
|
||||
@@ -332,13 +294,6 @@ dependencies {
|
||||
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('-')
|
||||
@@ -354,64 +309,4 @@ android.applicationVariants.all { variant ->
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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"
|
||||
}
|
||||
}
|
||||
}
|
||||
apply from: "./regroup.gradle"
|
||||
|
||||
45
app/regroup.gradle
Normal file
45
app/regroup.gradle
Normal file
@@ -0,0 +1,45 @@
|
||||
// 将 install 和 assemble 任务按功能分组
|
||||
|
||||
afterEvaluate {
|
||||
|
||||
def independent = ["em3", "em1", "d8xx", "d82x", "bydauto"]
|
||||
def launcher = ["f8xx", "em4"]
|
||||
|
||||
it.getTasks().iterator().forEachRemaining {
|
||||
def task = it
|
||||
def taskName = task.name
|
||||
if (taskName.startsWith("assemble")
|
||||
&& taskName.contains("Independent")
|
||||
&& (taskName.endsWith("Debug") || taskName.endsWith("Release"))) {
|
||||
independent.forEach {
|
||||
if( taskName.toLowerCase().contains(it) ){
|
||||
task.group = "assembleIndependent"
|
||||
}
|
||||
}
|
||||
} else if (taskName.startsWith("assemble")
|
||||
&& taskName.contains("Launcher")
|
||||
&& (taskName.endsWith("Debug") || taskName.endsWith("Release"))) {
|
||||
launcher.forEach {
|
||||
if( taskName.toLowerCase().contains(it) ){
|
||||
task.group = "assembleLauncher"
|
||||
}
|
||||
}
|
||||
} else if (taskName.startsWith("install")
|
||||
&& taskName.contains("Independent")
|
||||
&& (taskName.endsWith("Debug") || taskName.endsWith("Release"))) {
|
||||
independent.forEach {
|
||||
if( taskName.toLowerCase().contains(it) ){
|
||||
task.group = "installIndependent"
|
||||
}
|
||||
}
|
||||
} else if (taskName.startsWith("install")
|
||||
&& taskName.contains("Launcher")
|
||||
&& (taskName.endsWith("Debug") || taskName.endsWith("Release"))) {
|
||||
launcher.forEach {
|
||||
if( taskName.toLowerCase().contains(it) ){
|
||||
task.group = "installLauncher"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user