-
Notifications
You must be signed in to change notification settings - Fork 307
/
Copy pathbuild.gradle
247 lines (216 loc) · 8.28 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
apply plugin: 'com.android.application'
apply plugin: 'io.sentry.android.gradle'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'dagger.hilt.android.plugin'
def versionProperties = loadPropertiesFromFile(file("${rootDir}/version.properties"))
android {
namespace 'com.automattic.simplenote'
compileSdk 34
buildTypes {
debug {
applicationIdSuffix '.debug'
}
release {
minifyEnabled true
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
// Dedicated build type for screenshots so that we can add the special
// permissions only to it, keeping debug and release closer together to
// make bug hunting easier.
screenshots {
initWith debug
}
}
defaultConfig {
applicationId "com.automattic.simplenote"
// Allow versionName to be overridden with property. e.g. -PversionName=1234
if (project.hasProperty("versionName")) {
versionName project.property("versionName")
} else {
versionName versionProperties.getProperty("versionName")
}
versionCode versionProperties.getProperty("versionCode").toInteger()
minSdkVersion 23
targetSdkVersion 34
testInstrumentationRunner 'com.automattic.simplenote.SimplenoteAppRunner'
}
lintOptions {
checkReleaseBuilds false
}
testOptions {
unitTests.returnDefaultValues = true
// Disable animations in order to enter text in the text inputs in the
// Espresso tests
animationsDisabled = true
}
// Target Java8 to avoid use certain Kotlin's features
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
viewBinding {
enabled = true
}
}
buildscript {
dependencies {
classpath 'io.sentry:sentry-android-gradle-plugin:3.5.0'
}
repositories {
google()
jcenter()
}
}
dependencies {
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:4.0.0'
testImplementation 'org.mockito:mockito-inline:4.0.0'
androidTestImplementation 'androidx.test:core:1.3.0'
androidTestImplementation 'androidx.annotation:annotation:1.0.0'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test:rules:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.0'
androidTestImplementation('androidx.test.espresso:espresso-contrib:3.1.0') {
// Necessary to avoid version conflicts
exclude group: 'androidx', module: 'appcompat'
exclude group: 'androidx', module: 'support-v4'
exclude group: 'androidx', module: 'support-annotations'
exclude module: 'recyclerview-v7'
}
// Infrastructure to test fragments
testImplementation "androidx.arch.core:core-testing:2.1.0"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.4.3"
testImplementation "org.mockito.kotlin:mockito-kotlin:3.2.0"
// Support for JsonObjects in unit tests since they are used by BucketObjects
testImplementation 'org.json:json:20210307'
// Fastlane screengrab for screenshots automation
androidTestImplementation 'tools.fastlane:screengrab:2.0.0'
// Automattic and WordPress dependencies
implementation 'com.automattic:simperium:v1.3.1'
implementation('com.github.Automattic:Automattic-Tracks-Android:2.1.0') {
// Tracks lib is referring to an unavailable build of okhttp
exclude group: 'com.squareup.okhttp3'
}
// Kotlin's coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'
// Google Support
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0-beta01'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
implementation 'androidx.preference:preference:1.1.0'
implementation 'androidx.legacy:legacy-preference-v14:1.0.0'
implementation 'androidx.work:work-runtime:2.7.1'
implementation 'androidx.concurrent:concurrent-futures:1.1.0'
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
implementation "androidx.multidex:multidex:2.0.1"
// Support for ViewModels and LiveData
implementation "androidx.activity:activity-ktx:1.3.1"
implementation "androidx.fragment:fragment-ktx:1.3.6"
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
// Support for androidx Fragments
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.3.1"
// Google Play Services
implementation 'com.google.android.gms:play-services-wearable:17.0.0'
// Third Party
implementation 'com.squareup.okhttp3:okhttp:3.12.0'
implementation 'com.commonsware.cwac:anddown:0.4.0'
implementation 'net.openid:appauth:0.7.0'
// Dagger Hilt dependencies
implementation 'com.google.dagger:hilt-android:2.38.1'
annotationProcessor 'com.google.dagger:hilt-compiler:2.38.1'
kapt 'com.google.dagger:hilt-compiler:2.38.1'
wearApp project(':Wear')
implementation project(':PasscodeLock')
}
repositories {
maven {
url "https://a8c-libs.s3.amazonaws.com/android"
content {
includeGroup "com.automattic"
}
}
maven { url "https://maven.google.com" }
maven { url "https://s3.amazonaws.com/repo.commonsware.com" }
jcenter()
maven {
url 'https://jitpack.io'
content {
includeGroup "com.github.Automattic"
}
}
}
if(["storeFile", "storePassword", "keyAlias", "keyPassword"].count { !project.hasProperty(it) } == 0 ){
android {
signingConfigs {
release {
storeFile = rootProject.file(project.storeFile)
storePassword = project.storePassword
keyAlias = project.keyAlias
keyPassword = project.keyPassword
}
}
}
android.buildTypes.release.signingConfig = android.signingConfigs.release
}
task copyGradlePropertiesIfMissing(group: "generate", description: "Copy Gradle Properties") {
if (!file("${rootDir}/Simplenote/gradle.properties").exists()) {
copy {
from("${rootDir}/Simplenote")
into("${rootDir}/Simplenote")
include('gradle.properties-example')
rename('gradle.properties-example', 'gradle.properties')
}
}
}
static def loadPropertiesFromFile(inputFile) {
def properties = new Properties()
inputFile.withInputStream { stream ->
properties.load(stream)
}
return properties
}
static String toSnakeCase( String text ) {
text.replaceAll( /([A-Z])/, /_$1/ ).replaceAll( /^_/, '' )
}
android.applicationVariants.all { variant ->
variant.generateBuildConfigProvider.configure {
dependsOn(copyGradlePropertiesIfMissing)
}
def inputFile = file("${rootDir}/Simplenote/gradle.properties")
def properties = loadPropertiesFromFile(inputFile)
properties.any { property ->
def key = toSnakeCase(property.key).toUpperCase()
if (key == "SIMPERIUM_APP_ID" ||
key == "SIMPERIUM_APP_KEY" ||
key == "GOOGLE_ANALYTICS_ID" ||
key == "LOGIN_EMAIL" ||
key == "LOGIN_PASSWORD" ||
key == "SENTRY_DSN" ||
key == "WPCOM_CLIENT_ID" ||
key == "SCREENSHOT_EMAIL" ||
key == "SCREENSHOT_PASSWORD") {
buildConfigField "String", key, "\"${property.value}\""
}
}
buildConfigField "String", "BUILD", "\"${gitDescribe()}\""
buildConfigField "String", "BUILD_HASH", "\"${gitHash()}\""
}
if (project.hasProperty("debugStoreFile")) {
def sharedDebugStore = file(project.debugStoreFile.replaceFirst("^~", System.getProperty("user.home")))
if (sharedDebugStore.exists()) {
android {
signingConfigs {
debug {
storeFile sharedDebugStore
}
}
}
}
}