/
build.gradle
267 lines (214 loc) · 8.38 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
/*
* Copyright (c) 2015 Markus Poeschl
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
buildscript {
dependencies {
classpath 'com.github.jcandksolutions.gradle:android-unit-test:2.0.2'
classpath 'io.fabric.tools:gradle:1.14.4'
classpath 'de.undercouch:gradle-download-task:1.2'
}
}
// Manifest version information!
def versionMajor = 1
def versionMinor = 0
def versionPatch = 0
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'de.undercouch.download'
def gitSha = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
def buildTime = new Date().format("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC"))
project.ext.set("gitSha", gitSha)
android {
compileSdkVersion 21
buildToolsVersion "22"
signingConfigs {
googlePlay {
//Placeholder which gets automatically filled during project sync. Needs the right setting file.
//This settings is not in the source control, because it contains sensitive information.
}
}
defaultConfig {
applicationId "de.poeschl.apps.tryandremove"
minSdkVersion 15
targetSdkVersion 22
versionCode versionMajor * 10000 + versionMinor * 1000 + versionPatch
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
buildConfigField "String", "GIT_SHA", "\"${gitSha}\""
buildConfigField "String", "BUILD_TIME", "\"${buildTime}\""
//Setup the fabric keys
def properties = getExternalProperties()
resValue "string", "fabric_key", properties["crashlytics_apiKey"]
resValue "string", "fabric_appSecret", properties["crashlytics_appSecret"]
println "Setup fabric api keys"
}
lintOptions {
lintConfig file("lint.xml")
checkReleaseBuilds true
abortOnError true
}
buildTypes {
release {
minifyEnabled false
proguardFiles 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android.txt')
signingConfig signingConfigs.googlePlay
applicationVariants.all { variant ->
renameReleasePackage(variant, defaultConfig)
}
}
debug {
applicationIdSuffix '.dev'
ext.enableCrashlytics = false
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'LICENSE.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
apply plugin: 'android-unit-test'
androidUnitTest {
testReleaseBuildType true
//Run tests for all the build types including non-debuggable (like the Release build type). Only works for Application projects, not Library projects.
downloadDependenciesSources false
//Download the sources.jar for the production dependencies. `true` by default.
downloadDependenciesJavadoc true
//Download the javadoc.jar for the production dependencies. `false` by default.
downloadTestDependenciesSources false
//Download the sources.jar for the test dependencies. `true` by default.
downloadTestDependenciesJavadoc true
//Download the javadoc.jar for the test dependencies. `false` by default.
}
apply plugin: 'checkstyle'
checkstyle {
configFile new File("${project.buildDir}/checkstyle.xml")
reportsDir new File("${project.buildDir}/outputs")
toolVersion "6.2"
}
//Add checkstyle execution
preBuild.dependsOn('checkstyle')
task checkstyle(type: Checkstyle) {
source 'src'
include '**/*.java'
exclude '**/gen/**'
exclude '**/R.java'
exclude '**/BuildConfig.java'
def configProps = ['proj.module.dir': buildDir]
configProperties configProps
//If you are offline and the checkstyle stuff was downloaded once you can comment the next line out
it.dependsOn 'downloadCheckstyleConfig'
classpath = files()
}
import de.undercouch.gradle.tasks.download.Download
task downloadCheckstyleConfig(type: Download) {
src([
'https://raw.githubusercontent.com/Poeschl/Android-Checkstyle/master/checkstyle.xml',
'https://raw.githubusercontent.com/Poeschl/Android-Checkstyle/master/suppressions.xml'
])
dest buildDir
overwrite true
onlyIfNewer true
}
def getExternalProperties() {
//Get environment variable of keystore settings folder location.
def keyStorePath = System.getenv('Android_Keystore_Path')
//Name of the properties file
def propertiesFileName = 'TryAndRemove.keyproperties'
def propsFile = file(keyStorePath + '/' + propertiesFileName)
def properties;
if (propsFile.exists()) {
properties = new Properties()
properties.load(new FileInputStream(propsFile))
properties.put('path', keyStorePath)
} else {
System.err.println("File " + propsFile.name + " for setup not available");
}
return properties
}
def setupSigning(properties) {
if (properties == null) {
System.err.println("Could not set signing config. No properties");
return;
}
def configName = 'googlePlay'
if (android.signingConfigs.hasProperty(configName)) {
//Android signing information
android.signingConfigs[configName].storeFile = file(properties['path'] + '/' + properties['storeFile'])
android.signingConfigs[configName].storePassword = properties['storePassword']
android.signingConfigs[configName].keyAlias = properties['keyAlias']
android.signingConfigs[configName].keyPassword = properties['keyPassword']
println("Setup keystore settings.")
}
}
def setupFabricApiFile(properties) {
File crashlyticsProps = new File(getBuildFile().getPath().replace(getBuildFile().getName(), "crashlytics.properties"));
FileWriter writer = new FileWriter(crashlyticsProps, false);
try {
writer.write("apiSecret=" + properties["crashlytics_appSecret"]);
writer.write("\n")
writer.write("apiKey=" + properties["crashlytics_apiKey"]);
} finally {
writer.close();
}
println("Setup crashlytics key file.")
}
/*
* Adds dynamically keys and secret stuff to the project
*/
afterEvaluate { project ->
def props = getExternalProperties();
setupSigning(props)
setupFabricApiFile(props)
}
/*
* Gives the output apks the right names. Automatic file name convention.
*/
def renameReleasePackage(variant, defaultConfig) {
variant.outputs.each { output ->
def fileName = "Try And Remove - " + defaultConfig.versionName + " - " + project.gitSha + ".apk";
def file = output.packageApplication.outputFile
output.packageApplication.outputFile = new File(file.parent, fileName)
}
}
dependencies {
compile 'com.android.support:recyclerview-v7:21.0.3'
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:palette-v7:22.0.0'
compile 'com.google.android.gms:play-services-ads:7.0.0'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.jakewharton.timber:timber:2.7.1'
compile 'com.squareup.dagger:dagger:1.2.2'
provided 'com.squareup.dagger:dagger-compiler:1.2.2'
compile 'com.makeramen:roundedimageview:2.0.0'
compile "com.daimajia.swipelayout:library:1.1.8@aar"
// Is replaced with local aar until changes gets merged
// compile 'com.getbase:floatingactionbutton:1.4.0'
compile project(':android-floating-action-button')
compile('com.crashlytics.sdk.android:crashlytics:2.2.3@aar') {
transitive = true;
}
testCompile 'junit:junit:4.10'
testCompile 'org.robolectric:robolectric:2.4'
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.3.1'
androidTestCompile 'org.hamcrest:hamcrest-core:1.3'
androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
debugCompile 'com.android.support:support-v4:22.0.0'
debugCompile 'com.jakewharton.scalpel:scalpel:1.1.2'
}