-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
build.gradle
220 lines (184 loc) · 6.72 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
buildscript {
repositories {
mavenCentral()
maven { url "https://jitpack.io" }
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.3'
classpath 'com.noveogroup.android:check:1.2.5', {
exclude module: 'checkstyle'
exclude module: 'xmlpull'
}
classpath 'com.puppycrawl.tools:checkstyle:7.8.1'
classpath 'com.github.bjoernq:unmockplugin:0.7.9'
}
}
apply plugin: 'com.android.application'
apply plugin: 'com.noveogroup.android.check'
apply plugin: 'de.mobilej.unmock'
// enable verbose lint warnings
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs <<
'-Xlint:deprecation' <<
'-Xlint:unchecked' <<
'-Xdiags:verbose'
}
}
repositories {
maven { url "${System.env.ANDROID_HOME}/extras/android/m2repository/" }
mavenCentral()
maven { url 'https://s3.amazonaws.com/repo.commonsware.com' }
google()
}
def excludeKxml2 = {
// This transitive dependency is excluded from some direct dependencies to prevent
// "Program type already present: org.xmlpull.v1.XmlSerializer" when running
// `gradle clean transformDexArchiveWithExternalLibsDexMergerForGenericDebugAndroidTest`
// This class is also included in the android core libs by default, so this should
// be safe to exclude from androidTestImplementation and implementation configurations.
exclude module: 'kxml2'
}
dependencies {
testImplementation 'androidx.test:core:1.4.0'
testImplementation 'com.google.android:android-test:4.1.1.4'
testImplementation 'org.robolectric:robolectric:4.7'
testImplementation 'com.squareup.okhttp3:mockwebserver:3.2.0'
testImplementation 'org.mockito:mockito-core:4.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'com.google.android:android-test:4.1.1.4'
androidTestImplementation 'com.squareup.okhttp3:mockwebserver:4.9.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
androidTestImplementation 'androidx.test:rules:1.4.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
implementation 'androidx.legacy:legacy-support-core-ui:1.0.0'
implementation 'androidx.fragment:fragment:1.0.0'
implementation 'com.commonsware.cwac:wakeful:1.1.0'
implementation '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'
}
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
}
def getVersionCode = {
int versionCode = 1
if(System.env.CI == 'true' && System.env.GIT_TAG && System.env.GIT_TAG.startsWith('v')) {
def versionParts = System.env.GIT_TAG.split(/[^0-9]+/)
if (versionParts.length != 4 && versionParts.length != 5)
throw new RuntimeException("Unexpected version number - should be of formatted as 'v1.2.3' or 'v1.2.3-alpha.4', but was: $System.env.GIT_TAG")
versionParts = versionParts.drop(1).collect { Integer.parseInt(it) }
int alphaPart = versionParts.size() == 4 ? versionParts[3] : 99;
if (versionParts[1] > 99 || versionParts[2] > 99 || alphaPart > 99)
throw new RuntimeException('Version part greater than 99 not allowed.')
versionCode = (100 * 100 * 100 * versionParts[0]) + (100 * 100 * versionParts[1]) + (100 * versionParts[2]) + alphaPart
if (versionCode > 2100000000 / 10)
throw new RuntimeException('versionCode bigger than max allowed by Google Play.')
}
return versionCode
}
def getVersionName = {
System.env.GIT_TAG ?: 'SNAPSHOT'
}
android {
compileSdkVersion 30
buildToolsVersion '30.0.3'
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
defaultConfig {
minSdkVersion 16
targetSdkVersion 29 // 30+ causes instrumentation tests to fail when uninstalling the app from the device
versionCode getVersionCode()
versionName getVersionName()
archivesBaseName = "${project.name}-${versionName}"
testInstrumentationRunner 'medic.gateway.alert.test.WakingJUnitRunner'
multiDexEnabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
}
applicationVariants.all {
buildConfigField "String", "LOG_TAG", '"CHTGateway"'
buildConfigField "boolean", "DISABLE_APP_URL_VALIDATION", "Boolean.parseBoolean(\"${System.env.DISABLE_APP_URL_VALIDATION}\")"
buildConfigField "boolean", "CI", "Boolean.parseBoolean(\"${System.env.CI}\")"
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 {
lintConfig = new File('config/lint.xml')
disable 'UnusedResources' // linter can't handle static imports, so just skip this test
disable 'GradleDependency'
disable 'JcenterRepositoryObsolete'
disable 'RtlHardcoded'
warningsAsErrors true
// abortOnError false
xmlReport false
if(System.env.CI == 'true') {
abortOnError true
htmlReport false
textReport true
textOutput 'stdout'
}
}
testOptions {
unitTests.includeAndroidResources true
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"
}
}
}
unMock {
keep 'android.net.Uri'
}