Skip to content

Instantly share code, notes, and snippets.

@aelam
Created September 10, 2013 08:56
Show Gist options
  • Save aelam/6506762 to your computer and use it in GitHub Desktop.
Save aelam/6506762 to your computer and use it in GitHub Desktop.
build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
//设置文件编码
tasks.withType(Compile) {
options.encoding = 'UTF-8'
}
dependencies {
compile "com.android.support:support-v4:18.0.+"
compile fileTree(dir: 'libs', include: '*.jar')
compile project(":Vendor:NineOldAndroids:Library")
compile project(":Vendor:Unionpay:upomp_Res_v1_1")
compile project(":Vendor:ViewPagerIndicator:Library")
compile project(":Vendor:SlidingMenu-library")
}
task copyNativeLibs(type: Copy) {
from fileTree(dir: 'libs/armeabi', include: '**/*.so' ) into 'build/native-libs'
}
tasks.withType(Compile) { compileTask -> compileTask.dependsOn copyNativeLibs }
clean.dependsOn 'cleanCopyNativeLibs'
tasks.withType(com.android.build.gradle.tasks.PackageApplication) {
pkgTask -> pkgTask.jniDir new File(projectDir, 'libs')
}
android {
compileSdkVersion 18
buildToolsVersion "17"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
signingConfigs {
OfficialSigningConfig {
storeFile file("hotelvp.keystore")
storePassword "mango123"
keyAlias "hotelvpandroidkey"
keyPassword "hotelvp"
}
}
buildTypes {
// 基于debug
//chkY.initWith(buildTypes.debug)
//chkY{}
// chkT{
// signingConfig signingConfigs.OfficialSigningConfig
// runProguard true
// proguardFile 'proguard-project.txt'
// }
//
// chk.initWith(buildTypes.debug)
// chk{}
// debug {
// signingConfig signingConfigs.OfficialSigningConfig
// }
// 基于release
release {
signingConfig signingConfigs.OfficialSigningConfig
runProguard true
proguardFile 'proguard-project.txt'
}
// freT.initWith(buildTypes.release)
// freT
//
// fre.initWith(buildTypes.release)
// fre {
// signingConfig signingConfigs.OfficialSigningConfig
// }
}
productFlavors {
def packName = "com.hotelvp.caoniu"
A01_XX { packageName packName }
// A02_XX { packageName packName }
// A03_XX { packageName packName }
// A04_XX { packageName packName }
// A05_XX { packageName packName }
// A06_XX { packageName packName }
// A07_XX { packageName packName }
// A08_XX { packageName packName }
// A09_XX { packageName packName }
// A10_XX { packageName packName }
// A11_XX { packageName packName }
// A12_XX { packageName packName }
// A13_XX { packageName packName }
// A14_XX { packageName packName }
// A15_XX { packageName packName }
// A16_XX { packageName packName }
// A17_XX { packageName packName }
// A18_XX { packageName packName }
// A19_XX { packageName packName }
// A20_XX { packageName packName }
//
// A21_XX { packageName packName }
// A22_XX { packageName packName }
// A23_XX { packageName packName }
// A24_XX { packageName packName }
// A25_XX { packageName packName }
// A26_XX { packageName packName }
// A27_XX { packageName packName }
// A28_XX { packageName packName }
// A29_XX { packageName packName }
// A30_XX { packageName packName }
//
// A31_XX { packageName packName }
// A32_XX { packageName packName }
// A33_XX { packageName packName }
// A34_XX { packageName packName }
// A35_XX { packageName packName }
// A36_XX { packageName packName }
// A37_XX { packageName packName }
// A38_XX { packageName packName }
// A39_XX { packageName packName }
// A40_XX { packageName packName }
}
}
android.applicationVariants.all { variant ->
// variant.processManifest.doLast{
// copy{
// from("${buildDir}/manifests"){
// include "${variant.dirName}/AndroidManifest.xml"
// }
// into("${buildDir}/manifests/$variant.name")
// filter{
// String line -> line.replaceAll("_channel_id_", "${variant.productFlavors.name}".substring(1, "${variant.productFlavors.name}".length() -1))
// }
// variant.processResources.manifestFile = file("${buildDir}/manifests/${variant.name}/${variant.dirName}/AndroidManifest.xml")
//
// }
// }
variant.mergeResources.doLast {
File valuesFile = file("${buildDir}/res/all/${variant.dirName}/values/values.xml")
println("--> Replacing channel_id in " + valuesFile)
String content = valuesFile.getText('UTF-8')
// 替换channel_id
content = content.replaceAll("(?<=channel_id\">).*(?=</string>)", "${variant.productFlavors.name}".substring(1, "${variant.productFlavors.name}".length() -1))
if ("${variant.buildType.name}".contains("chkY")) {
content = content.replaceAll("(?<=isChk\">).*(?=</)", "true")
content = content.replaceAll("(?<=isToday\">).*(?=</)", "false")
content = content.replaceAll("(?<=test\">).*(?=</)", "true")
} else if ("${variant.buildType.name}".contains("chkT")) {
content = content.replaceAll("(?<=isChk\">).*(?=</)","true")
content = content.replaceAll("(?<=isToday\">).*(?=</)","true")
content = content.replaceAll("(?<=test\">).*(?=</)","true")
} else if ("${variant.buildType.name}".contains("chk")) {
content = content.replaceAll("(?<=isChk\">).*(?=</)","true")
content = content.replaceAll("(?<=isToday\">).*(?=</)","true")
content = content.replaceAll("(?<=test\">).*(?=</)","false")
} else if ("${variant.buildType.name}".contains("freY")) {
content = content.replaceAll("(?<=isChk\">).*(?=</)","false")
content = content.replaceAll("(?<=isToday\">).*(?=</)","false")
content = content.replaceAll("(?<=test\">).*(?=</)","true")
} else if ("${variant.buildType.name}".contains("freT")) {
content = content.replaceAll("(?<=isChk\">).*(?=</)","false")
content = content.replaceAll("(?<=isToday\">).*(?=</)","true")
content = content.replaceAll("(?<=test\">).*(?=</)","false")
} else if ("${variant.buildType.name}".contains("fre")) {
content = content.replaceAll("(?<=isChk\">).*(?=</)","false")
content = content.replaceAll("(?<=isToday\">).*(?=</)","true")
content = content.replaceAll("(?<=test\">).*(?=</)","false")
}
valuesFile.write(content, 'UTF-8')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment