-
-
Notifications
You must be signed in to change notification settings - Fork 362
/
Copy pathbuild.gradle.kts
317 lines (267 loc) · 11.3 KB
/
build.gradle.kts
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
import java.io.FileInputStream
import java.io.FileWriter
import java.util.Properties
plugins {
id("com.android.application")
kotlin("android")
kotlin("plugin.serialization") version "2.0.0"
kotlin("plugin.compose") version "2.0.0"
}
android {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
isCoreLibraryDesugaringEnabled = true
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
}
signingConfigs {
create("release") {
}
}
compileSdk = 34
testOptions {
unitTests {
isReturnDefaultValues = true
}
}
defaultConfig {
applicationId = "de.westnordost.streetcomplete"
minSdk = 21
targetSdk = 34
versionCode = 5901
versionName = "59.0-alpha2"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
all {
isMinifyEnabled = true
isShrinkResources = false
// don't use proguard-android-optimize.txt, it is too aggressive, it is more trouble than it is worth
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
testProguardFile("test-proguard-rules.pro")
}
getByName("release") {
signingConfig = signingConfigs.getByName("release")
buildConfigField("boolean", "IS_GOOGLE_PLAY", "false")
}
getByName("debug") {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
applicationIdSuffix = ".debug"
buildConfigField("boolean", "IS_GOOGLE_PLAY", "false")
}
create("releaseGooglePlay") {
signingConfig = signingConfigs.getByName("release")
buildConfigField("boolean", "IS_GOOGLE_PLAY", "true")
}
}
buildFeatures {
viewBinding = true
buildConfig = true
compose = true
}
bundle {
language {
enableSplit = false // because language is selectable in-app
}
}
lint {
disable += listOf(
"MissingTranslation", // crowd-contributed translations are incomplete all the time
"UseCompatLoadingForDrawables" // doesn't make sense for minSdk >= 21
)
abortOnError = false
}
namespace = "de.westnordost.streetcomplete"
}
val keystorePropertiesFile = rootProject.file("keystore.properties")
if (keystorePropertiesFile.exists()) {
val props = Properties()
props.load(FileInputStream(keystorePropertiesFile))
val releaseSigningConfig = android.signingConfigs.getByName("release")
releaseSigningConfig.storeFile = file(props.getProperty("storeFile"))
releaseSigningConfig.storePassword = props.getProperty("storePassword")
releaseSigningConfig.keyAlias = props.getProperty("keyAlias")
releaseSigningConfig.keyPassword = props.getProperty("keyPassword")
}
repositories {
google()
mavenCentral()
}
dependencies {
val mockitoVersion = "3.12.4"
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4")
// tests
testImplementation("org.mockito:mockito-core:$mockitoVersion")
testImplementation("org.mockito:mockito-inline:$mockitoVersion")
testImplementation(kotlin("test"))
androidTestImplementation("androidx.test:runner:1.6.1")
androidTestImplementation("androidx.test:rules:1.6.1")
androidTestImplementation("org.mockito:mockito-android:$mockitoVersion")
androidTestImplementation(kotlin("test"))
// dependency injection
implementation(platform("io.insert-koin:koin-bom:3.5.6"))
implementation("io.insert-koin:koin-core")
implementation("io.insert-koin:koin-android")
implementation("io.insert-koin:koin-androidx-workmanager")
implementation("io.insert-koin:koin-androidx-compose")
// Android stuff
implementation("com.google.android.material:material:1.12.0")
implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.annotation:annotation:1.8.2")
implementation("androidx.fragment:fragment-ktx:1.8.2")
implementation("androidx.recyclerview:recyclerview:1.3.2")
implementation("androidx.viewpager:viewpager:1.0.0")
implementation("androidx.localbroadcastmanager:localbroadcastmanager:1.1.0")
// Jetpack Compose
val composeBom = platform("androidx.compose:compose-bom:2024.06.00")
implementation(composeBom)
androidTestImplementation(composeBom)
implementation("androidx.compose.material:material")
implementation("androidx.activity:activity-compose")
// Jetpack Compose Previews
implementation("androidx.compose.ui:ui-tooling-preview")
debugImplementation("androidx.compose.ui:ui-tooling")
implementation("androidx.navigation:navigation-compose:2.7.7")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.4")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.8.4")
// multiplatform webview (for login via OAuth)
implementation("io.github.kevinnzou:compose-webview-multiplatform-android:1.9.20")
// photos
implementation("androidx.exifinterface:exifinterface:1.3.7")
// settings
implementation("com.russhwolf:multiplatform-settings:1.1.1")
// Kotlin
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1")
implementation("org.jetbrains.kotlinx:kotlinx-io-core:0.5.1")
// Date/time
api("org.jetbrains.kotlinx:kotlinx-datetime:0.6.0")
// scheduling background jobs
implementation("androidx.work:work-runtime-ktx:2.9.1")
// HTTP Client
implementation("io.ktor:ktor-client-core:2.3.12")
implementation("io.ktor:ktor-client-android:2.3.12")
testImplementation("io.ktor:ktor-client-mock:2.3.12")
// TODO: as soon as both ktor-client and kotlinx-serialization have been refactored to be based
// on kotlinx-io, revisit sending and receiving xml/json payloads via APIs, currently it
// is all String-based, i.e. no KMP equivalent of InputStream/OutputStream involved
// finding in which country we are for country-specific logic
implementation("de.westnordost:countryboundaries:2.1")
// finding a name for a feature without a name tag
implementation("de.westnordost:osmfeatures:6.1")
// widgets
implementation("androidx.viewpager2:viewpager2:1.1.0")
implementation("me.grantland:autofittextview:0.2.1")
implementation("com.google.android.flexbox:flexbox:3.0.0")
// box2d view
implementation("org.jbox2d:jbox2d-library:2.2.1.1")
// sharing presets/settings via QR Code
implementation("io.github.alexzhirkevich:qrose:1.0.1")
// for encoding information for the URL configuration (QR code)
implementation("com.ionspin.kotlin:bignum:0.3.10")
// serialization
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1")
implementation("com.charleskorn.kaml:kaml:0.61.0")
implementation("io.github.pdvrieze.xmlutil:core:0.90.1")
// map and location
implementation("org.maplibre.gl:android-sdk:11.2.0")
// opening hours parser
implementation("de.westnordost:osm-opening-hours:0.1.0")
// image view that allows zoom and pan
implementation("com.github.chrisbanes:PhotoView:2.3.0")
}
/** Localizations that should be pulled from POEditor */
val bcp47ExportLanguages = setOf(
"ar", "ast", "be", "bg", "bs", "ca", "cs", "da", "de", "el",
"en", "en-AU", "en-GB", "eo", "es", "eu", "fa", "fi", "fr", "gl", "he", "hr", "hu", "hy",
"id", "it", "ja", "ko", "lt", "lv", "nb", "no", "nl", "nn", "pl", "pt", "pt-BR",
"ro", "ru", "sk", "sl", "sr-cyrl", "sr-latn", "sv", "sw", "th", "tr", "uk",
"zh", "zh-CN", "zh-HK", "zh-TW"
)
// see https://github.com/osmlab/name-suggestion-index/tags for latest version
val nsiVersion = "v6.0.20240826"
// see https://github.com/openstreetmap/id-tagging-schema/releases for latest version
val presetsVersion = "v6.8.1"
val poEditorProjectId = "97843"
tasks.register("updateAvailableLanguages") {
group = "streetcomplete"
doLast {
val fileWriter = FileWriter("$projectDir/src/main/res/raw/languages.yml", false)
fileWriter.write(bcp47ExportLanguages.joinToString("\n") { "- $it" })
fileWriter.write("\n")
fileWriter.close()
}
}
tasks.register<GetTranslatorCreditsTask>("updateTranslatorCredits") {
group = "streetcomplete"
targetFile = "$projectDir/src/main/res/raw/credits_translators.yml"
languageCodes = bcp47ExportLanguages
cookie = properties["POEditorCookie"] as String
phpsessid = properties["POEditorPHPSESSID"] as String
}
tasks.register<UpdatePresetsTask>("updatePresets") {
group = "streetcomplete"
version = presetsVersion
languageCodes = bcp47ExportLanguages
targetDir = "$projectDir/src/main/assets/osmfeatures/default"
}
tasks.register<UpdateNsiPresetsTask>("updateNsiPresets") {
group = "streetcomplete"
version = nsiVersion
targetDir = "$projectDir/src/main/assets/osmfeatures/brands"
}
// tasks.register<DownloadBrandLogosTask>("downloadBrandLogos") {
// group = "streetcomplete"
// version = nsiVersion
// targetDir = "$projectDir/src/main/assets/osmfeatures/brands"
// }
tasks.register<DownloadAndConvertPresetIconsTask>("downloadAndConvertPresetIcons") {
group = "streetcomplete"
version = presetsVersion
targetDir = "$projectDir/src/main/res/drawable/"
iconSize = 34
transformName = { "ic_preset_" + it.replace('-', '_') }
indexFile = "$projectDir/src/main/java/de/westnordost/streetcomplete/view/PresetIconIndex.kt"
}
tasks.register<UpdateAppTranslationsTask>("updateTranslations") {
group = "streetcomplete"
languageCodes = bcp47ExportLanguages
apiToken = properties["POEditorAPIToken"] as String
projectId = poEditorProjectId
targetFiles = { "$projectDir/src/main/res/values-$it/strings.xml" }
}
tasks.register<UpdateAppTranslationCompletenessTask>("updateTranslationCompleteness") {
group = "streetcomplete"
languageCodes = bcp47ExportLanguages
mustIncludeLanguagePercentage = 90
apiToken = properties["POEditorAPIToken"] as String
projectId = poEditorProjectId
targetFiles = { "$projectDir/src/main/res/values-$it/translation_info.xml" }
}
tasks.register<UpdateChangelogTask>("updateChangelog") {
group = "streetcomplete"
sourceFile = "$rootDir/CHANGELOG.md"
targetFile = "$projectDir/src/main/res/raw/changelog.html"
}
tasks.register<UpdateMapStyleTask>("updateMapStyle") {
group = "streetcomplete"
targetDir = "$projectDir/src/main/assets/map_theme"
apiKey = "mL9X4SwxfsAGfojvGiion9hPKuGLKxPbogLyMbtakA2gJ3X88gcVlTSQ7OD6OfbZ"
mapStyleBranch = "master"
}
tasks.register<GenerateMetadataByCountryTask>("generateMetadataByCountry") {
group = "streetcomplete"
sourceDir = "$rootDir/res/country_metadata"
targetDir = "$projectDir/src/main/assets/country_metadata"
}
tasks.register("copyDefaultStringsToEnStrings") {
doLast {
File("$projectDir/src/main/res/values/strings.xml")
.copyTo(File("$projectDir/src/main/res/values-en/strings.xml"), true)
}
}