forked from MarcusWolschon/osmeditor4android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
505 lines (447 loc) · 21 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
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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
// Top-level build file where you can add
// configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
maven { url 'https://dl.bintray.com/content/simonpoole/gradle' }
maven { url 'https://dl.bintray.com/content/simonpoole/osm' }
google()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } // For Spoon snapshot, until 2.0.0 is released
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.0'
classpath 'ch.poole.gradle:markdown-gradle-plugin:0.2.1'
classpath 'org.jacoco:org.jacoco.core:0.8.5'
classpath "ch.poole:preset-utils:0.19.0"
classpath 'com.github.ksoichiro:gradle-eclipse-aar-plugin:0.3.1'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:1.0.0'
classpath 'com.jaredsburrows:gradle-spoon-plugin:1.5.0'
}
}
plugins {
id "de.undercouch.download" version "4.0.4"
id "org.sonarqube" version "2.8"
id "net.ltgt.apt" version "0.21"
id "com.github.ben-manes.versions" version "0.28.0"
}
import de.undercouch.gradle.tasks.download.Download
allprojects {
repositories {
mavenCentral()
maven { url 'https://dl.bintray.com/content/simonpoole/div' }
maven { url 'https://dl.bintray.com/content/simonpoole/android' }
maven { url "https://maven.google.com" }
maven { url "https://jitpack.io" }
jcenter()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } // For Spoon snapshot, until 2.0.0 is released
mavenLocal()
google()
// flatDir {
// dirs 'lib'
// }
}
}
// Project level build file starts here
apply plugin: 'eclipse'
apply plugin: 'com.android.application'
apply plugin: "net.ltgt.apt"
apply plugin: 'ch.poole.gradle.markdown'
apply plugin: 'jacoco'
apply plugin: 'com.getkeepsafe.dexcount'
apply plugin: 'com.jaredsburrows.spoon'
markdownToHtml {
sourceDir = new File(projectDir.getPath() + '/documentation/docs/help')
inputEncoding ="utf8"
outputDir = new File(projectDir.getPath() + '/src/main/assets/help')
outputEncoding = "utf8"
configuration.template = projectDir.getPath() + "/documentation/html_template.tpl"
}
task markdownToHtmlRtl(type: ch.poole.gradle.markdown.MarkdownToHtmlTask) {
sourceDir = new File(projectDir.getPath() + '/documentation/docs/help-rtl')
inputEncoding ="utf8"
outputDir = new File(projectDir.getPath() + '/src/main/assets/help')
outputEncoding = "utf8"
configuration.template = projectDir.getPath() + "/documentation/html_template_rtl.tpl"
}
markdownToHtml.dependsOn markdownToHtmlRtl
task downloadPresetIconsZipFile(type: Download) {
doFirst {
delete projectDir.getPath() + '/src/main/assets/images/icons/png'
}
acceptAnyCertificate true
src 'https://github.com/simonpoole/beautified-JOSM-preset/releases/latest/download/vespucci_icons.zip'
dest new File(projectDir.getPath() + '/src/main/assets/images/icons/png', 'vespucci_icons.zip')
}
task downloadPresetFile(type: Download) {
acceptAnyCertificate true
src 'https://github.com/simonpoole/beautified-JOSM-preset/releases/latest/download/vespucci_preset_build.xml'
dest new File(projectDir.getPath() + '/src/main/assets/preset.xml')
}
task updatePreset(dependsOn: ["downloadPresetFile", "downloadPresetIconsZipFile"], type: Copy) {
from zipTree(downloadPresetIconsZipFile.dest)
into projectDir.getPath() + '/src/main/assets/images/icons/png'
doLast { delete downloadPresetIconsZipFile.dest }
}
updatePreset.group = 'vespucci'
updatePreset.description = 'Update the default preset from http://simonpoole.github.io/beautified-JOSM-preset/'
task updateImageryFromJosm(type: Download) {
acceptAnyCertificate true
src 'https://josm.openstreetmap.de/maps?format=geojson'
dest new File(projectDir.getPath() + '/src/main/assets/imagery.geojson')
}
updateImageryFromJosm.group = 'vespucci'
updateImageryFromJosm.description = 'Update the background layer configuration from https://josm.openstreetmap.de/wiki/Maps'
task updateImageryFromELI(type: Download) {
acceptAnyCertificate true
src 'https://osmlab.github.io/editor-layer-index/imagery.geojson'
dest new File(projectDir.getPath() + '/src/main/assets/imagery.geojson')
}
updateImageryFromELI.group = 'vespucci'
updateImageryFromELI.description = 'Update the background layer configuration from https://osmlab.github.io/editor-layer-index/imagery.geojson'
task updateGeocontext(type: Download) {
acceptAnyCertificate true
src 'https://raw.githubusercontent.com/simonpoole/geocontext/master/geocontext.json'
dest new File(projectDir.getPath() + '/src/main/assets/geocontext.json')
}
updateGeocontext.group = 'vespucci'
updateGeocontext.description = 'Update the geocontext configuration'
task update3rdPartyDocs() {
}
update3rdPartyDocs.group = 'vespucci'
update3rdPartyDocs.description = 'Update markdown help files for 3rd party libraries'
['de', 'en', 'es', 'fi', 'fr', 'gl', 'hu', 'it', 'pl', 'pt', 'zh-rTW'].each { lang ->
def name="updateOpeningHoursDoc${lang.capitalize()}"
task (name,type: Download) {
acceptAnyCertificate true
src "https://raw.githubusercontent.com/simonpoole/OpeningHoursFragment/master/lib/documentation/docs/help/${lang}/Opening%20hours.md"
dest new File(projectDir.getPath() + "/documentation/docs/help/${lang}/Opening hours.md")
}
update3rdPartyDocs.dependsOn name
}
['fa','iw'].each { lang ->
def name="updateOpeningHoursDoc${lang.capitalize()}"
task (name,type: Download) {
acceptAnyCertificate true
src "https://raw.githubusercontent.com/simonpoole/OpeningHoursFragment/master/lib/documentation/docs/help/${lang}/Opening%20hours.md"
dest new File(projectDir.getPath() + "/documentation/docs/help-rtl/${lang}/Opening hours.md")
}
update3rdPartyDocs.dependsOn name
}
task updateTranslations(type: Exec) {
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
commandLine 'cmd', '/c', 'tx.exe', 'pull', '-a'
} else {
commandLine 'tx', 'pull', '-a'
}
doLast {
ant.move(file: projectDir.getPath() + "/documentation/docs/help/fa", tofile: projectDir.getPath() + "/documentation/docs/help-rtl/fa")
ant.move(file: projectDir.getPath() + "/documentation/docs/help/iw", tofile: projectDir.getPath() + "/documentation/docs/help-rtl/iw")
}
}
updateTranslations.group = 'vespucci'
updateTranslations.description = 'Update translations by executing the transifex tx utility'
task updateSynonyms() {
doLast {
def dir = 'https://api.github.com/repos/openstreetmap/iD/contents/dist/locales?ref=release'
// download directory listing via GitHub API
def contentsFile = new File(buildDir, "directory_contents.json")
download {
src dir
dest contentsFile
}
// parse directory listing
def contents = new groovy.json.JsonSlurper().parseFile(contentsFile, "utf-8")
def langs = contents.collect { it.name.replace('.json', '') }
langs.each { lang ->
def name="updateSynonyms${lang.capitalize()}"
def output = "src/main/assets/synonyms/synonyms.$lang"
javaexec {
main = "ch.poole.osm.presetutils.Synonyms"
classpath = buildscript.configurations.classpath
args('-u', 'https://raw.githubusercontent.com/openstreetmap/iD/release/dist/locales/',
'-l', "$lang",
'-x', "military",
'-o', output,
'-r')
}
}
// delete downloaded directory listing
contentsFile.delete()
}
}
updateSynonyms.group = 'vespucci'
updateSynonyms.description = 'Update synonym files from iD editor repo'
apply from: 'https://raw.githubusercontent.com/simonpoole/gradle-tasks/master/eclipse-android-3.6-flavors'
// apply from: '../gradle-tasks/eclipse-android-3.6-flavors'
sonarqube {
properties {
property "sonar.java.source","1.8"
property "sonar.sourceEncoding","UTF-8"
property "sonar.java.binaries", "build/intermediates/app_classes/currentDebug/classes.jar"
property "sonar.coverage.jacoco.xmlReportPaths","build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml"
}
}
ext {
private_assets = "$projectDir/../private_assets"
}
android {
defaultConfig {
versionCode project.getVersionCode()
versionName "${project.getVersionName()}"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
def reporter = System.getenv('VESPUCCI_REPORTER')
if (reporter == null) {
reporter = "";
}
resValue("string", "reporter", reporter)
}
buildTypes {
debug {
testCoverageEnabled true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-shrink-only.txt','proguard-rules.pro'
testProguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-shrink-only.txt','proguard-test.txt','proguard-rules.pro'
// proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),'proguard-rules.pro'
}
release {
minifyEnabled true
// proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),'proguard-rules.pro'
}
}
// this, unluckily, cannot be set per flavour
compileSdkVersion 29
// Specifies one flavor dimension.
flavorDimensions "api"
productFlavors {
current {
dimension "api"
minSdkVersion 14
targetSdkVersion 29
applicationIdSuffix ""
versionNameSuffix ""
resValue "string", "content_provider", "de.blau.android.provider"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
testOptions {
unitTests.all {
jacoco { includeNoLocationClasses = true }
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
outputs.upToDateWhen {false}
showStandardStreams = true
}
}
}
dexOptions {
jumboMode = true
javaMaxHeapSize "4g"
}
sourceSets {
main.assets.srcDirs += files("$private_assets".toString())
}
lintOptions {
abortOnError true
baseline file("lint-baseline.xml")
}
}
ext {
adb = android.getAdbExe().toString()
}
task enableFreeform(type: Exec) {
commandLine adb, 'shell', 'settings', 'put', 'global', 'enable_freeform_support', '1'
}
enableFreeform.group = 'emulators'
enableFreeform.description = 'turn on free form window support'
task dumpTaginfoJson(dependsOn: ["installCurrentDebug", "installCurrentDebugAndroidTest"],type: Exec) {
commandLine adb, 'shell', 'am', 'instrument', '-w', '-e', 'class', "de.blau.android.TaginfoDump", 'de.blau.android.test/androidx.test.runner.AndroidJUnitRunner'
}
task updateTaginfoJson(dependsOn: "dumpTaginfoJson", type: Exec) {
commandLine adb, 'pull', 'sdcard/Vespucci/taginfo.json', projectDir.getPath()
}
updateTaginfoJson.group = 'vespucci'
updateTaginfoJson.description = 'Update the taginfo.json file from test device'
afterEvaluate{
android.applicationVariants.all { variant ->
task("generate${variant.name.capitalize()}Javadoc", type: Javadoc) {
description "Generates Javadoc for $variant.name."
group "Documentation"
source = variant.javaCompile.source
classpath = files(variant.javaCompile.classpath.files) + files(android.bootClasspath) + files(variant.javaCompile.destinationDir)
options.links("http://docs.oracle.com/javase/7/docs/api/");
options.links("http://d.android.com/reference/");
exclude '**/BuildConfig.java'
exclude '**/R.java'
}
}
// these tasks needs to be created after the uninstall tasks
// hardwired single test, this is only needed during initial developement, once the whole test suite has been run
// any new test will be included automatically
// it would probably be better to somehow get the test name interactively from the user
android.productFlavors.all { flavor ->
task ("runSingleConnected${flavor.name.capitalize()}Test",
dependsOn: ["install${flavor.name.capitalize()}Debug", "install${flavor.name.capitalize()}DebugAndroidTest"],
type: Exec) {
group = 'vespucci'
description = "Run a single test method on device (configuration needs to be edited) for the ${flavor.name} flavor"
def toRun = "de.blau.android.services.MapTileProviderServiceTest"
// commandLine adb, 'shell', 'pm', 'list', 'instrumentation'
commandLine adb, 'shell', 'am', 'instrument', '-w', '-e', 'class', toRun, "de.blau.android${flavor.applicationIdSuffix}.test/androidx.test.runner.AndroidJUnitRunner"
finalizedBy "uninstall${flavor.name.capitalize()}DebugAndroidTest","uninstall${flavor.name.capitalize()}Debug"
}
}
// this task will generate tasks for each test that was run in the last on device test
// it doesn't depend on it directly as that would require waiting for all the tests to execute first
// so the best strategy seems to simply refresh the build after the on device tests have been ran
// tests are split up over two categories depending if they failed or not
task generateTestTasks {
android.productFlavors.all { flavor ->
def flavorName = flavor.name.toUpperCase()
def fileRegex = "TEST.*-${flavorName}\\.xml"
def fileList = new File(projectDir.getPath() +"/build/outputs/androidTest-results/connected/flavors/${flavorName}/").listFiles().findAll { it.name ==~ /${fileRegex}/ }
if (!fileList.empty) {
def tests = (new XmlParser()).parse(fileList.get(0)) // assume all tests outputs are equivalent
tests.'testcase'.each { testcase ->
def toRun = testcase.@classname + "#" + testcase.@name
task ("run${flavor.name.capitalize()}${toRun.capitalize()}",
dependsOn: ["install${flavor.name.capitalize()}Debug", "install${flavor.name.capitalize()}DebugAndroidTest"],
type: Exec) {
if (testcase.failure.size() == 0) {
group = 'sucessful tests'
} else {
group = "failed tests"
}
description = "Run test " + toRun
// commandLine adb, 'shell', 'pm', 'list', 'instrumentation'
commandLine adb, 'shell', 'am', 'instrument', '-w', '-e', 'class', toRun, "de.blau.android${flavor.applicationIdSuffix}.test/androidx.test.runner.AndroidJUnitRunner"
finalizedBy "uninstall${flavor.name.capitalize()}DebugAndroidTest","uninstall${flavor.name.capitalize()}Debug"
}
}
}
}
}
}
ext {
okHttpVersion = "3.12.12" // don't change to higher than 3.12 as later versions break android 5 and earlier builds
signpostVersion = "2.1.1"
acraVersion = "5.4.0"
mapboxVersion = "4.5.0"
}
dependencies {
implementation ("ch.acra:acra-http:$acraVersion") { exclude group: 'com.android.support' }
implementation ("ch.acra:acra-dialog:$acraVersion") { exclude group: 'com.android.support' }
// android support and other libraries
implementation "androidx.appcompat:appcompat:1.1.0"
implementation "androidx.recyclerview:recyclerview:1.1.0"
implementation "androidx.preference:preference:1.1.0"
implementation "com.google.android.material:material:1.0.0"
implementation "androidx.annotation:annotation:1.1.0"
implementation "androidx.core:core:1.2.0"
implementation "androidx.exifinterface:exifinterface:1.1.0"
implementation "androidx.legacy:legacy-preference-v14:1.0.0"
//
implementation 'com.heinrichreimersoftware:android-issue-reporter:1.4'
implementation "com.nononsenseapps:filepicker:4.2.1"
implementation "oauth.signpost:signpost-core:$signpostVersion"
implementation 'se.akerfeldt:okhttp-signpost:1.1.0'
implementation "com.squareup.okhttp3:okhttp:$okHttpVersion"
implementation "com.squareup.okhttp3:logging-interceptor:$okHttpVersion"
implementation "com.adobe.xmp:xmpcore:6.1.10"
implementation "com.drewnoakes:metadata-extractor:2.13.0"
implementation "com.google.code.gson:gson:2.8.5"
implementation 'com.google.protobuf:protobuf-java:2.6.1'
implementation 'com.google.openlocationcode:openlocationcode:1.0.4'
implementation ('com.faendir.rhino:rhino-android:1.5.1') { exclude group: 'org.mozilla' }
implementation "org.mozilla:rhino:1.7.11"
implementation "com.mapbox.mapboxsdk:mapbox-sdk-geojson:$mapboxVersion"
implementation "com.mapbox.mapboxsdk:mapbox-sdk-turf:$mapboxVersion"
implementation 'com.github.Kunzisoft:AndroidClearChroma:2.3'
implementation "ch.poole:PoParser:0.7.2"
implementation "ch.poole:OpeningHoursParser:0.22.1"
implementation "ch.poole:ConditionalRestrictionParser:0.3.0"
implementation "ch.poole:OpeningHoursFragment:0.8.3"
implementation 'ch.poole.android:numberpicker:1.0.9'
implementation 'ch.poole.android:numberpickerpreference:2.0.0'
implementation "ch.poole.osm:JosmFilterParser:0.2.0"
implementation 'de.westnordost:countryboundaries:1.5'
implementation 'com.github.sevar83:indeterminate-checkbox:1.0.5@aar'
implementation 'de.ruedigermoeller:fst:2.57'
implementation 'org.openstreetmap.osmosis:osmosis-osm-binary:0.47'
implementation 'com.zaxxer:SparseBitSet:1.2'
implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.10.0'
implementation 'io.michaelrocks:libphonenumber-android:8.11.5'
implementation 'io.noties.markwon:core:4.5.1'
// for temp stuff during dev
// implementation(name:'alibrary', ext:'jar')
// Unit tests
testImplementation "junit:junit:4.13"
testImplementation 'xmlpull:xmlpull:1.1.3.1'
testImplementation 'net.sf.kxml:kxml2:2.3.0'
// Instrumentation tests
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test:rules:1.1.1'
androidTestImplementation "org.hamcrest:hamcrest-library:1.3"
androidTestImplementation "com.squareup.okhttp3:mockwebserver:$okHttpVersion"
androidTestImplementation "pl.droidsonroids.yaml:snakeyaml:1.18-android"
androidTestImplementation ("com.orhanobut:mockwebserverplus:1.0.0") {
exclude group: 'org.yaml', module: 'snakeyaml'
}
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
androidTestImplementation "com.squareup.spoon:spoon-client:2.0.0-SNAPSHOT"
}
int getVersionCode() {
def xml = getXmlFromFile("${android.sourceSets.main.manifest.srcFile}")
return xml.@'android:versionCode'.toInteger()
}
String getVersionName() {
def xml = getXmlFromFile("${android.sourceSets.main.res.srcDirs[0]}/values/appname.xml")
def versionName = xml.string.find { it.@name == 'app_version' }.toString()
if (versionName == null || versionName.length() == 0) {
throw new NullPointerException("Failure extracting version name.")
}
return versionName
}
def getXmlFromFile(String xmlFilePath) {
def xml = new XmlSlurper().parse(new File(xmlFilePath))
if (xml == null) {
throw new NullPointerException("Failure reading from " + xmlFilePath)
}
return xml;
}
def coverageSourceDirs = ['src/main/java']
task jacocoTestReport(type:JacocoReport, dependsOn: "testCurrentDebugUnitTest") {
group = "Verification"
description = "Generate Jacoco coverage reports"
classDirectories = fileTree(
dir: 'build/intermediates/javac/currentDebug/classes/',
excludes: ['**/R.class', '**/R$*.class', '**/*$ViewInjector*.*', '**/BuildConfig.*', '**/Manifest*.*'])
additionalSourceDirs = files(coverageSourceDirs)
sourceDirectories = files(coverageSourceDirs)
executionData = fileTree(
dir : "$buildDir",
include : ['jacoco/testCurrentDebugUnitTest.exec', 'outputs/code-coverage/connected/flavors/CURRENT/*coverage.ec', 'spoon-output/currentDebug/coverage/merged-coverage.ec'])
reports {
xml.enabled = true
html.enabled = true
}
sourceDirectories = files(coverageSourceDirs)
}
spoon {
// https://github.com/jaredsburrows/gradle-spoon-plugin for configuration
debug = true
noAnimations = false
adbTimeout = 5
codeCoverage = true
shard = false
singleInstrumentationCall = true
ignoreFailures = true
clearAppDataBeforeEachTest = true
// set these for individual text execution
// className = "de.blau.android.layer.LayerDialogTest"
// methodName = "dataLayerPrune"
}