-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild.gradle
101 lines (84 loc) · 2.71 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
apply plugin: 'com.android.application'
def releaseTime() {
return new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC"))
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId PACKAGE_NAME
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
// 默认是umeng的渠道
manifestPlaceholders = [UMENG_CHANNEL_VALUE: "umeng"]
}
//渠道信息,其中myserver,pgyer分别为自己服务器上传使用以及上传蒲公英平台使用
productFlavors {
xiaomi {}
_360 {}
baidu {}
wandoujia {}
umeng {}
myserver {}
pgyer {}
}
signingConfigs {
//debug版本不签名
debug {
}
//release版本签名信息
release {
storeFile file("gradle.jks")
storePassword KEYSTORE_PASSWORD
keyAlias "gradle"
keyPassword KEY_PASSWORD
}
}
buildTypes {
//debug版本编译是配置
debug {
// 显示Log
buildConfigField "boolean", "LOG_DEBUG", "true"
versionNameSuffix "-debug"
minifyEnabled false
zipAlignEnabled false
shrinkResources false
signingConfig signingConfigs.debug
}
//release版本编译时配置
release {
// 不显示Log
buildConfigField "boolean", "LOG_DEBUG", "false"
minifyEnabled true
zipAlignEnabled true
// 移除无用的resource文件
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
// 输出apk名称为test_v1.0_2015-01-15_wandoujia.apk
def fileName = "${APP_NAME}_v${defaultConfig.versionName}_${releaseTime()}_${variant.productFlavors[0].name}.apk"
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
}
}
productFlavors.all {
flavor -> flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name]
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
}
//文件上传至蒲公英平台
task upload(type: Exec) {
executable 'sh'
args '-c','../upload.sh'
}