-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
190 lines (169 loc) · 6.22 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
apply plugin: 'com.android.application'
apply from: '../gradle/quality.gradle'
ext {
// ATTENTION do not forget to run "gradlew clean" when changing the package name!
PACKAGE_NAME = "com.publiss.whitelabel" // Take Bundle Id from Publiss Online
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
configurations.all {
resolutionStrategy {
// don't cache changing modules at all
cacheChangingModulesFor 0, 'seconds'
}
}
productFlavors {
submodule {
}
nexussnapshot {
}
nexus {
}
}
lintOptions {
lintConfig file("lint.xml")
}
defaultConfig {
applicationId PACKAGE_NAME
minSdkVersion 15
targetSdkVersion 22
multiDexEnabled true
versionCode retrieveVersionCode()
println "VersionCode: " + versionCode
versionName generateVersionName(versionCode)
println "VersionName: " + versionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// testInstrumentationRunner "com.android.test.runner.MultiDexTestRunner"
}
buildTypes {
debug {
debuggable true
minifyEnabled false
}
release {
debuggable false
zipAlignEnabled true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
// def manifestParser = new com.android.builder.core.DefaultManifestParser()
// def versionName = manifestParser.getVersionName(android.sourceSets.main.manifest.srcFile);
def apkType = System.getenv("ANDROID_APK_TYPE")
if (apkType.equals("null")) {
apkType = "local"
}
def fileName = outputFile.name.replace("app-", "app-" + PACKAGE_NAME.replace(".", "-") + "-" + apkType + "-")
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
}
}
sourceSets {
androidTest {
java.srcDirs = ['src/androidTest/java']
res.srcDirs = ['src/androidTest/res']
}
test {
java.srcDirs = ['src/test/java']
res.srcDirs = ['src/test/res']
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'LICENSE.txt'
}
}
android.applicationVariants.all{ variant ->
variant.mergeResources.doLast{
ext.env = System.getenv()
File valuesFile = file("${buildDir}/intermediates/res/merged/${variant.dirName}/values/values.xml")
println("Replacing package name placeholder in " + valuesFile + " with " + PACKAGE_NAME)
String content = valuesFile.getText('UTF-8')
content = content.replaceAll(/PACKAGE_NAME_INSERTED_BY_GRADLE/, PACKAGE_NAME)
valuesFile.write(content, 'UTF-8')
}
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
nexusCompile('com.publiss.core:publiss-android-core:1.7.4@aar') {
transitive = true
}
nexussnapshotCompile('com.publiss.core:publiss-android-core:dev-SNAPSHOT@aar') {
transitive = true
}
submoduleCompile project(':publiss-android-core')
compile 'com.bytepoets.bporssreader:bporssreader:1.1.2@aar'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.9.5'
androidTestCompile 'org.mockito:mockito-core:1.10.19'
androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
androidTestCompile 'com.android.support.test:runner:0.3'
androidTestCompile 'com.android.support.test:rules:0.3'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'
androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2'
androidTestCompile('com.android.support:multidex-instrumentation:1.0.1') {
exclude group: 'com.android.support', module: 'multidex'
}
androidTestCompile 'com.android.support:support-annotations:23.2.0'
compile 'com.android.support:support-annotations:23.2.0'
// androidTestCompile project(':publiss-android-core')
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
def retrieveVersionCode() {
def calculatedVersionCode = System.getenv("BUILD_NUMBER");
if (null == calculatedVersionCode) {
calculatedVersionCode = "-1";
}
return Integer.parseInt(calculatedVersionCode)
}
def getGitDescribe() {
try {
return 'git describe --tags'.execute().text.trim()
} catch (IOException exception) {
throw new UnsupportedOperationException("Could not find git! Maybe it is not in \$PATH variable?", exception)
}
}
def getCurrentGitBranch() {
try {
return 'git rev-parse --abbrev-ref HEAD'.execute().text.trim()
} catch (IOException exception) {
throw new UnsupportedOperationException("Could not find git! Maybe it is not in \$PATH variable?", exception)
}
}
def generateVersionName(buildNumber) {
def versionName
if (buildNumber == -1) {
// local build
versionName = getGitDescribe() + " " + getCurrentGitBranch()
} else {
// jenkins build
versionName = getGitDescribe()
}
return versionName.concat(" (" + getDate() + ")")
}
def getDate() {
def date = new Date()
def formattedDate = date.format('yyyy-MM-dd')
return formattedDate
}
def signing_config_path = System.getenv("SIGNING_CONFIGURATION_FILE")
logger.quiet("Signing config path: " + signing_config_path)
if (null != signing_config_path && !signing_config_path.isEmpty()) {
def signing_config_file = file(signing_config_path)
if (signing_config_file.exists()) {
apply from: signing_config_file.absolutePath
} else {
apply from: file("../gradle/signing_config.gradle")
}
}