-
Notifications
You must be signed in to change notification settings - Fork 85
/
app.gradle
113 lines (90 loc) · 3.01 KB
/
app.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
102
103
104
105
106
107
108
109
110
111
112
113
apply plugin: 'com.android.application'
apply from: file("${project.rootDir}/common.gradle")
apply from: file("${project.rootDir}/list-dependencies.gradle")
/**
* Gets the full path of the proguard file specified by `name`.
*
* The current options are:
* proguard-clover-apps.txt
*/
ext.getCommonProguardFile = { name ->
def fileName = "${project.rootDir}/$name"
if (!new File(fileName).exists()) {
throw new IllegalArgumentException("'$name' is not a valid proguard config file")
}
return fileName
}
def manifestFile = new File(project.projectDir, '/src/main/AndroidManifest.xml')
def getVersionCode = { ->
def code = project.hasProperty('versionCode') ? versionCode.toInteger() : 32000
return code
}
def getVersionName = { ->
def ns = new groovy.xml.Namespace('http://schemas.android.com/apk/res/android', 'ns')
def parser = new groovy.util.XmlParser(false, true)
def rootNode = parser.parse(manifestFile)
def attributes = rootNode.attributes()
def baseCode = attributes[ns.versionName] ?: '1.0'
def name = baseCode + "-" + getVersionCode()
return name;
}
def releaseBuildTypes = ['release', 'releaseSigned']
android.applicationVariants.all { variant ->
if (releaseBuildTypes.contains(buildType.name)) {
String pkg = variant.applicationId
if (!variant.productFlavors.empty) {
logger.warn('There are product flavors in the project, going to use package names from their override')
if (variant.productFlavors.get(0).applicationId != null) {
pkg = variant.productFlavors.get(0).applicationId
}
}
String versionName = getVersionName()
variant.outputs.all { output ->
outputFileName = new File(output.outputFile.name.replace(project.archivesBaseName, "${pkg}-${versionName}"))
}
}
}
android {
buildTypes {
debug {
zipAlignEnabled true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
getCommonProguardFile('proguard-clover-apps.txt'),
// Force apps to have a proguard file if ProGuard is enabled
'proguard-rules.pro'
testProguardFiles getCommonProguardFile('proguard-test-rules.txt')
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
getCommonProguardFile('proguard-clover-apps.txt'),
// Force apps to have a proguard file if ProGuard is enabled
'proguard-rules.pro'
testProguardFiles getCommonProguardFile('proguard-test-rules.txt')
}
releaseSigned {
initWith release
matchingFallbacks = ['release']
}
}
buildFeatures {
buildConfig = true
}
compileSdkVersion COMPILE_SDK_VERSION
useLibrary HTTP_LIBRARY
defaultConfig {
versionCode getVersionCode()
versionName getVersionName()
minSdkVersion MIN_SDK_VERSION
targetSdkVersion TARGET_SDK_VERSION
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
pickFirst 'META-INF/ASL2.0'
}
lintOptions {
abortOnError false
}
}