/
build.gradle
171 lines (148 loc) · 4.96 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
buildscript {
repositories {
mavenCentral()
maven { url "https://jitpack.io" }
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.github.alxndrsn:android-check:1f87548c0686d823e5f1490a2053b70bd9f5022e'
}
}
apply plugin: 'com.android.application'
apply plugin: 'com.noveogroup.android.check'
// enable verbose lint warnings
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs <<
'-Xlint:deprecation' <<
'-Xlint:unchecked' <<
'-Xdiags:verbose'
}
}
repositories {
mavenCentral()
maven { url 'https://s3.amazonaws.com/repo.commonsware.com' }
maven { url "${System.env.ANDROID_HOME}/extras/android/m2repository/" }
google()
}
dependencies {
testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:3.1.4'
testCompile 'com.squareup.okhttp3:mockwebserver:3.2.0'
testCompile 'org.mockito:mockito-core:1.10.19'
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'com.squareup.okhttp3:mockwebserver:3.2.0'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.commonsware.cwac:wakeful:1.1.0'
compile 'com.google.code.findbugs:annotations:3.0.1', {
// Need to exclude these, or build is broken by:
// com.android.dex.DexException: Multiple dex files define Ljavax/annotation/CheckForNull
exclude module: 'jsr305'
exclude module: 'jcip-annotations'
}
}
def getVersionCode = {
if(System.env.JENKINS == 'true') {
def versionParts = System.env.VERSION_TO_BUILD.split(/\./)
if(versionParts.length != 3)
throw new RuntimeException("Unexpected version number - should be of form 'x.y.z', but was: $System.env.VERSION_TO_BUILD")
versionParts = versionParts.collect { Integer.parseInt(it) }
if(versionParts[1] > 999 || versionParts[2] > 999)
throw new RuntimeException('Version part greater than 999 not allowed.')
int versionCode = (1000000 * versionParts[0]) +
(1000 * versionParts[1]) +
versionParts[2]
if(versionCode > 2100000000)
throw new RuntimeException('versionCode biggger than max allowed by Google Play.')
return versionCode
}
return 1
}
def getVersionName = {
System.env.VERSION_TO_BUILD ?: 'SNAPSHOT'
}
android {
compileSdkVersion 23
buildToolsVersion '28.0.2'
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
defaultConfig {
versionCode getVersionCode()
versionName getVersionName()
archivesBaseName = "${project.name}-${versionName}"
testInstrumentationRunner 'medic.gateway.alert.test.WakingJUnitRunner'
}
applicationVariants.all {
buildConfigField "String", "LOG_TAG", '"MedicGateway"'
buildConfigField "boolean", "DISABLE_APP_URL_VALIDATION", "Boolean.parseBoolean(\"${System.env.DISABLE_APP_URL_VALIDATION}\")";
buildConfigField "boolean", "TRAVIS", "Boolean.parseBoolean(\"${System.env.TRAVIS}\")";
buildConfigField "boolean", "FORCE_SEED", "Boolean.parseBoolean(\"${System.env.FORCE_SEED}\")";
buildConfigField "boolean", "LOAD_SEED_DATA", "Boolean.parseBoolean(\"${System.env.LOAD_SEED_DATA}\")";
buildConfigField "boolean", "IS_DUMMY_SEND_AVAILABLE", "Boolean.parseBoolean(\"${System.env.ENABLE_DUMMY_SEND_OPTION}\")";
}
sourceSets {
test { java.srcDirs = [ 'src/test/java', 'src/libTest/java' ] }
androidTest { java.srcDirs = [ 'src/androidTest/java', 'src/libTest/java' ] }
}
signingConfigs {
release {
storeFile file(System.env.ANDROID_KEYSTORE_PATH ?: signingConfigs.debug.storeFile)
storePassword System.env.ANDROID_KEYSTORE_PASSWORD ?: signingConfigs.debug.storePassword
keyAlias System.env.ANDROID_KEY_ALIAS ?: signingConfigs.debug.keyAlias
keyPassword System.env.ANDROID_KEY_PASSWORD ?: signingConfigs.debug.keyPassword
}
}
buildTypes {
debug {
testCoverageEnabled = true
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'config/proguard.pro'
signingConfig signingConfigs.release
}
}
check {
abortOnError true
}
lintOptions {
disable 'UnusedResources' // linter can't handle static imports, so just skip this test
disable 'GradleDependency' // TODO update to latest support-v4 lib and re-enable this rule
warningsAsErrors true
xmlReport false
if(System.env.TRAVIS == 'true') {
abortOnError true
htmlReport false
textReport true
textOutput 'stdout'
}
}
testOptions {
unitTests.all {
testLogging {
events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
outputs.upToDateWhen { false }
showStandardStreams = true
}
}
}
flavorDimensions 'brand'
productFlavors {
generic {
applicationId = 'medic.gateway.alert.generic'
buildConfigField "boolean", "IS_GENERIC_FLAVOUR", "true"
buildConfigField "boolean", "IS_MEDIC_FLAVOUR", "false"
}
medic {
applicationId = 'medic.gateway.alert'
buildConfigField "boolean", "IS_GENERIC_FLAVOUR", "false"
buildConfigField "boolean", "IS_MEDIC_FLAVOUR", "true"
}
}
}