summaryrefslogtreecommitdiffstats
path: root/mobile/android/geckoview/build.gradle
blob: 8507714a769f4d6bb09115e77f3c12b58e3ad85b (plain)
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
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
buildDir "${topobjdir}/gradle/build/mobile/android/geckoview"

import groovy.json.JsonOutput

apply plugin: 'com.android.library'
apply plugin: 'checkstyle'
apply plugin: 'kotlin-android'

apply from: "${topsrcdir}/mobile/android/gradle/product_flavors.gradle"

// The SDK binding generation tasks depend on the JAR creation task of the
// :annotations project.
evaluationDependsOn(':annotations')

android {
    buildToolsVersion project.ext.buildToolsVersion
    compileSdkVersion project.ext.compileSdkVersion

    useLibrary 'android.test.runner'
    useLibrary 'android.test.base'
    useLibrary 'android.test.mock'

    defaultConfig {
        targetSdkVersion project.ext.targetSdkVersion
        minSdkVersion project.ext.minSdkVersion
        manifestPlaceholders = project.ext.manifestPlaceholders
        multiDexEnabled true

        versionCode project.ext.versionCode
        versionName project.ext.versionName
        consumerProguardFiles 'proguard-rules.txt'

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        buildConfigField 'String', "GRE_MILESTONE", "\"${mozconfig.substs.GRE_MILESTONE}\""
        buildConfigField 'String', "MOZ_APP_BASENAME", "\"${mozconfig.substs.MOZ_APP_BASENAME}\"";

        // For the benefit of future archaeologists:
        // GRE_BUILDID is exactly the same as MOZ_APP_BUILDID unless you're running
        // on XULRunner, which is never the case on Android.
        buildConfigField 'String', "MOZ_APP_BUILDID", "\"${project.ext.buildId}\"";
        buildConfigField 'String', "MOZ_APP_ID", "\"${mozconfig.substs.MOZ_APP_ID}\"";
        buildConfigField 'String', "MOZ_APP_NAME", "\"${mozconfig.substs.MOZ_APP_NAME}\"";
        buildConfigField 'String', "MOZ_APP_VENDOR", "\"${mozconfig.substs.MOZ_APP_VENDOR}\"";
        buildConfigField 'String', "MOZ_APP_VERSION", "\"${mozconfig.substs.MOZ_APP_VERSION}\"";
        buildConfigField 'String', "MOZ_APP_DISPLAYNAME", "\"${mozconfig.substs.MOZ_APP_DISPLAYNAME}\"";
        buildConfigField 'String', "MOZ_APP_UA_NAME", "\"${mozconfig.substs.MOZ_APP_UA_NAME}\"";
        buildConfigField 'String', "MOZ_UPDATE_CHANNEL", "\"${mozconfig.substs.MOZ_UPDATE_CHANNEL}\"";

        // MOZILLA_VERSION is oddly quoted from autoconf, but we don't have to handle it specially in Gradle.
        buildConfigField 'String', "MOZILLA_VERSION", "\"${mozconfig.substs.MOZILLA_VERSION}\"";
        buildConfigField 'String', "OMNIJAR_NAME", "\"${mozconfig.substs.OMNIJAR_NAME}\"";

        // Keep in sync with actual user agent in nsHttpHandler::BuildUserAgent
        buildConfigField 'String', "USER_AGENT_GECKOVIEW_MOBILE", "\"Mozilla/5.0 (Android \" + android.os.Build.VERSION.RELEASE + \"; Mobile; rv:109.0) Gecko/\" + ${mozconfig.defines.MOZILLA_UAVERSION} + \" Firefox/\" + ${mozconfig.defines.MOZILLA_UAVERSION}";
        buildConfigField 'String', "USER_AGENT_GECKOVIEW_TABLET", "\"Mozilla/5.0 (Android \" + android.os.Build.VERSION.RELEASE + \"; Tablet; rv:109.0) Gecko/\" + ${mozconfig.defines.MOZILLA_UAVERSION} + \" Firefox/\" + ${mozconfig.defines.MOZILLA_UAVERSION}";

        buildConfigField 'int', 'MIN_SDK_VERSION', mozconfig.substs.MOZ_ANDROID_MIN_SDK_VERSION;

        // Is the underlying compiled C/C++ code compiled with --enable-debug?
        buildConfigField 'boolean', 'DEBUG_BUILD', mozconfig.substs.MOZ_DEBUG ? 'true' : 'false';

        // See this wiki page for more details about channel specific build defines:
        // https://wiki.mozilla.org/Platform/Channel-specific_build_defines
        // This makes no sense for GeckoView and should be removed as soon as possible.
        buildConfigField 'boolean', 'RELEASE_OR_BETA', mozconfig.substs.RELEASE_OR_BETA ? 'true' : 'false';
        // This makes no sense for GeckoView and should be removed as soon as possible.
        buildConfigField 'boolean', 'NIGHTLY_BUILD', mozconfig.substs.NIGHTLY_BUILD ? 'true' : 'false';
        // This makes no sense for GeckoView and should be removed as soon as possible.
        buildConfigField 'boolean', 'MOZ_CRASHREPORTER', mozconfig.substs.MOZ_CRASHREPORTER ? 'true' : 'false';

        buildConfigField 'int', 'MOZ_ANDROID_CONTENT_SERVICE_COUNT', mozconfig.substs.MOZ_ANDROID_CONTENT_SERVICE_COUNT;

        // Official corresponds, roughly, to whether this build is performed on
        // Mozilla's continuous integration infrastructure. You should disable
        // developer-only functionality when this flag is set.
        // This makes no sense for GeckoView and should be removed as soon as possible.
        buildConfigField 'boolean', 'MOZILLA_OFFICIAL', mozconfig.substs.MOZILLA_OFFICIAL ? 'true' : 'false';

        // This env variable signifies whether we are running an isolated process build.
        buildConfigField 'boolean', 'MOZ_ANDROID_CONTENT_SERVICE_ISOLATED_PROCESS', mozconfig.substs.MOZ_ANDROID_CONTENT_SERVICE_ISOLATED_PROCESS ? 'true' : 'false';
    }

    project.configureProductFlavors.delegate = it
    project.configureProductFlavors()

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }

    lintOptions {
        abortOnError false
    }

    sourceSets {
        main {
            java {
                if (!mozconfig.substs.MOZ_ANDROID_HLS_SUPPORT) {
                    exclude 'org/mozilla/gecko/media/GeckoHlsAudioRenderer.java'
                    exclude 'org/mozilla/gecko/media/GeckoHlsPlayer.java'
                    exclude 'org/mozilla/gecko/media/GeckoHlsRendererBase.java'
                    exclude 'org/mozilla/gecko/media/GeckoHlsVideoRenderer.java'
                    exclude 'org/mozilla/gecko/media/Utils.java'
                }

                if (mozconfig.substs.MOZ_WEBRTC) {
                    srcDir "${topsrcdir}/dom/media/systemservices/android_video_capture/java/src"
                    srcDir "${topsrcdir}/third_party/libwebrtc/sdk/android/api"
                    srcDir "${topsrcdir}/third_party/libwebrtc/sdk/android/src"
                    srcDir "${topsrcdir}/third_party/libwebrtc/rtc_base/java"
                    srcDir "${topsrcdir}/third_party/libwebrtc/modules/audio_device/android/java"
                }

                srcDir "${topobjdir}/mobile/android/geckoview/src/main/java"
            }

            resources {
                if (mozconfig.substs.MOZ_ASAN) {
                    // If this is an ASAN build, include a `wrap.sh` for Android 8.1+ devices.  See
                    // https://developer.android.com/ndk/guides/wrap-script.
                    srcDir "${topsrcdir}/mobile/android/geckoview/src/asan/resources"
                }
            }

            assets {
            }

            debug {
                manifest.srcFile "${topobjdir}/mobile/android/geckoview/src/main/AndroidManifest_overlay.xml"
            }

            release {
                manifest.srcFile "${topobjdir}/mobile/android/geckoview/src/main/AndroidManifest_overlay.xml"
            }
        }

        withGeckoBinaries {
            assets {
                // This should contain only `omni.ja`.
                srcDir "${topobjdir}/dist/geckoview/assets"
            }

            jniLibs {
                if (!mozconfig.substs.MOZ_ANDROID_FAT_AAR_ARCHITECTURES) {
                    srcDir "${topobjdir}/dist/geckoview/lib"
                } else {
                    srcDir "${topobjdir}/dist/fat-aar/output/jni"
                }
            }
        }
    }
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
    // Translate Kotlin messages like "w: ..." and "e: ..." into
    // "...: warning: ..." and "...: error: ...", to make Treeherder understand.
    def listener = {
        if (it.startsWith("e: warnings found")) {
            return
        }

        if (it.startsWith('w: ') || it.startsWith('e: ')) {
            def matches = (it =~ /([ew]): (.+): \((\d+), (\d+)\): (.*)/)
            if (!matches) {
                logger.quiet "kotlinc message format has changed!"
                if (it.startsWith('w: ')) {
                    // For warnings, don't continue because we don't want to throw an
                    // exception. For errors, we want the exception so that the new error
                    // message format gets translated properly.
                    return
                }
            }
            def (_, type, file, line, column, message) = matches[0]
            type = (type == 'w') ? 'warning' : 'error'
            // Use logger.lifecycle, which does not go through stderr again.
            logger.lifecycle "$file:$line:$column: $type: $message"
        }
    } as StandardOutputListener

    kotlinOptions {
        allWarningsAsErrors = true
        jvmTarget = JavaVersion.VERSION_11
    }

    doFirst {
        logging.addStandardErrorListener(listener)
    }
    doLast {
        logging.removeStandardErrorListener(listener)
    }
}

configurations {
    withGeckoBinariesApi {
        outgoing {
            if (!mozconfig.substs.MOZ_ANDROID_GECKOVIEW_LITE) {
                // The omni build provides glean-native
                capability("org.mozilla.telemetry:glean-native:${project.ext.gleanVersion}")
            }
            afterEvaluate {
                // Implicit capability
                capability("org.mozilla.geckoview:${getArtifactId()}:${project.ext.versionNumber}")
            }
        }
    }
    // TODO: This is a workaround for a bug that was fixed in Gradle 7.
    // The variant resolver _should_ pick the RuntimeOnly configuration when building
    // the tests as those define the implicit :geckoview capability but it doesn't,
    // so we manually define it here.
    withGeckoBinariesRuntimeOnly {
        outgoing {
            afterEvaluate {
                // Implicit capability
                capability("org.mozilla.geckoview:geckoview:${project.ext.versionNumber}")
            }
        }
    }
}

dependencies {
    implementation "androidx.annotation:annotation:1.6.0"
    implementation "androidx.legacy:legacy-support-v4:1.0.0"

    implementation "com.google.android.gms:play-services-fido:20.0.1"
    implementation "org.yaml:snakeyaml:2.0"

    implementation "androidx.lifecycle:lifecycle-common:2.6.1"
    implementation "androidx.lifecycle:lifecycle-process:2.6.1"

    if (mozconfig.substs.MOZ_ANDROID_HLS_SUPPORT) {
        implementation project(":exoplayer2")
    }

    testImplementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    testImplementation 'junit:junit:4.13.2'
    testImplementation 'org.robolectric:robolectric:4.10.1'
    testImplementation 'org.mockito:mockito-core:5.3.1'

    androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
    androidTestImplementation 'androidx.test:runner:1.5.2'
    androidTestImplementation 'androidx.test:rules:1.5.0'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'

    androidTestImplementation 'com.koushikdutta.async:androidasync:3.1.0'

    androidTestImplementation 'androidx.multidex:multidex:2.0.1'
}

apply from: "${topsrcdir}/mobile/android/gradle/with_gecko_binaries.gradle"

android.libraryVariants.all { variant ->
    // See the notes in mobile/android/app/build.gradle for details on including
    // Gecko binaries and the Omnijar.
    if ((variant.productFlavors*.name).contains('withGeckoBinaries')) {
        configureVariantWithGeckoBinaries(variant)
    }

    // Javadoc and Sources JAR configuration cribbed from
    // https://github.com/mapbox/mapbox-gl-native/blob/d169ea55c1cfa85cd8bf19f94c5f023569f71810/platform/android/MapboxGLAndroidSDK/build.gradle#L85
    // informed by
    // https://code.tutsplus.com/tutorials/creating-and-publishing-an-android-library--cms-24582,
    // and amended from numerous Stackoverflow posts.
    def name = variant.name
    def javadoc = task "javadoc${name.capitalize()}"(type: Javadoc) {
        failOnError = false
        description = "Generate Javadoc for build variant $name"
        destinationDir = new File(destinationDir, variant.baseName)

        // The javadoc task will not re-run if the previous run is still up-to-date,
        // this is a problem for the javadoc lint, which needs to read the output of the task
        // to determine if there are warnings or errors. To force that we pass a -Pandroid-lint
        // parameter to all lints that can be used here to force running the task every time.
        outputs.upToDateWhen {
            !project.hasProperty('android-lint')
        }

        doFirst {
            classpath = files(variant.javaCompileProvider.get().classpath.files)
        }

        def results = []
        def listener = {
            if (!it.toLowerCase().contains("warning:") && !it.toLowerCase().contains("error:")) {
              // Likely not an error or a warning
              return
            }
            // Like '/abs/path/to/topsrcdir/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/ContentBlocking.java:480: warning: no @return'
            def matches = (it =~ /(.+):(\d+):.*(warning|error)(.*)/)
            if (!matches) {
                // could not parse, let's add it anyway since it's a warning or error
                results << [path: "parsing-failed", lineno: 0, level: "error", message: it]
                return
            }
            def (_, file, line, level, message) = matches[0]
            results << [path: file, lineno: line, level: level, message: message]
        } as StandardOutputListener

        doFirst {
            logging.addStandardErrorListener(listener)
        }

        doLast {
            logging.removeStandardErrorListener(listener)

            // We used to treat Javadoc warnings as errors here; now we rely on the
            // `android-javadoc` linter to fail in the face of Javadoc warnings.
            def resultsJson = JsonOutput.toJson(results)

            file("$buildDir/reports").mkdirs()
            file("$buildDir/reports/javadoc-results-${name}.json").write(resultsJson)
        }

        source = variant.sourceSets.collect({ it.java.srcDirs })
        exclude '**/R.java', '**/BuildConfig.java'
        include 'org/mozilla/geckoview/**.java'
        options.addPathOption('sourcepath', ':').setValue(
             variant.sourceSets.collect({ it.java.srcDirs }).flatten() +
             variant.generateBuildConfigProvider.get().sourceOutputDir.asFile.get() +
             variant.aidlCompileProvider.get().sourceOutputDir.asFile.get()
        )
        options.addStringOption("Xmaxwarns", "1000")

        classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
        classpath += variant.javaCompileProvider.get().classpath

        options.memberLevel = JavadocMemberLevel.PROTECTED
        options.source = 11
        options.links("https://developer.android.com/reference")

        options.docTitle = "GeckoView ${mozconfig.substs.MOZ_APP_VERSION} API"
        options.header = "GeckoView ${mozconfig.substs.MOZ_APP_VERSION} API"
        options.noTimestamp = true
        options.noQualifiers = ['java.lang']
        options.tags = ['hide:a:']
    }

    def javadocJar = task("javadocJar${name.capitalize()}", type: Jar, dependsOn: javadoc) {
        archiveClassifier = 'javadoc'
        from javadoc.destinationDir
    }

    // This task is used by `mach android geckoview-docs`.
    task("javadocCopyJar${name.capitalize()}", type: Copy) {
        from(javadocJar.destinationDirectory) {
            include 'geckoview-*-javadoc.jar'
            rename { _ -> 'geckoview-javadoc.jar' }
        }
        into javadocJar.destinationDirectory
        dependsOn javadocJar
    }

    def sourcesJar = task("sourcesJar${name.capitalize()}", type: Jar) {
        classifier 'sources'
        description = "Generate Javadoc for build variant $name"
        destinationDirectory =
            file("${topobjdir}/mobile/android/geckoview/sources/${variant.baseName}")
        from files(variant.sourceSets.collect({ it.java.srcDirs }).flatten())
    }

    task("checkstyle${name.capitalize()}", type: Checkstyle) {
        classpath = variant.javaCompileProvider.get().classpath
        // TODO: cleanup and include all sources
        source = ['src/main/java/']
        include '**/*.java'

    }
}

checkstyle {
    configDirectory = file(".")
    configFile = file("checkstyle.xml")
    toolVersion = "8.36.2"
}

android.libraryVariants.all { variant ->
    if (variant.name == mozconfig.substs.GRADLE_ANDROID_GECKOVIEW_VARIANT_NAME) {
        configureLibraryVariantWithJNIWrappers(variant, "Generated")
    }
}

android.libraryVariants.all { variant ->
    // At this point, the Android-Gradle plugin has created all the Android
    // tasks and configurations.  This is the time for us to declare additional
    // Glean files to package into AAR files.  This packs `metrics.yaml` in the
    // root of the AAR, sibling to `AndroidManifest.xml` and `classes.jar`.  By
    // default, consumers of the AAR will ignore this file, but consumers that
    // look for it can find it (provided GeckoView is a `module()` dependency
    // and not a `project()` dependency.)  Under the hood this uses that the
    // task provided by `packageLibraryProvider` task is a Maven `Zip` task,
    // and we can simply extend its inputs.  See
    // https://android.googlesource.com/platform/tools/base/+/0cbe8846f7d02c0bb6f07156b9f4fde16d96d329/build-system/gradle-core/src/main/java/com/android/build/gradle/tasks/BundleAar.kt#94.
    variant.packageLibraryProvider.get().from("${topsrcdir}/toolkit/components/telemetry/geckoview/streaming/metrics.yaml")
}

apply plugin: 'maven-publish'

version = getVersionNumber()
group = 'org.mozilla.geckoview'

def getArtifactId() {
    def id = "geckoview" + project.ext.artifactSuffix

    if (!mozconfig.substs.MOZ_ANDROID_GECKOVIEW_LITE) {
        id += "-omni"
    }

    if (mozconfig.substs.MOZILLA_OFFICIAL && !mozconfig.substs.MOZ_ANDROID_FAT_AAR_ARCHITECTURES) {
        // In automation, per-architecture artifacts identify
        // the architecture; multi-architecture artifacts don't.
        // When building locally, we produce a "skinny AAR" with
        // one target architecture masquerading as a "fat AAR"
        // to enable Gradle composite builds to substitute this
        // project into consumers easily.
        id += "-${mozconfig.substs.ANDROID_CPU_ARCH}"
    }

    return id
}

publishing {
    publications {
        android.libraryVariants.all { variant ->
            "${variant.name}"(MavenPublication) {
                from components.findByName(variant.name)

                pom {
                    afterEvaluate {
                        artifactId = getArtifactId()
                    }

                    url = 'https://geckoview.dev'

                    licenses {
                        license {
                            name = 'The Mozilla Public License, v. 2.0'
                            url = 'http://mozilla.org/MPL/2.0/'
                            distribution = 'repo'
                        }
                    }

                    scm {
                        if (mozconfig.substs.MOZ_INCLUDE_SOURCE_INFO) {
                            // URL is like "https://hg.mozilla.org/mozilla-central/rev/1e64b8a0c546a49459d404aaf930d5b1f621246a".
                            connection = "scm::hg::${mozconfig.substs.MOZ_SOURCE_REPO}"
                            url = mozconfig.substs.MOZ_SOURCE_URL
                            tag = mozconfig.substs.MOZ_SOURCE_CHANGESET
                        } else {
                            // Default to mozilla-central.
                            connection = 'scm::hg::https://hg.mozilla.org/mozilla-central/'
                            url = 'https://hg.mozilla.org/mozilla-central/'
                        }
                    }
                }

                // Javadoc and sources for developer ergononomics.
                artifact tasks["javadocJar${variant.name.capitalize()}"]
                artifact tasks["sourcesJar${variant.name.capitalize()}"]
            }
        }
    }
    repositories {
        maven {
            url = "${topobjdir}/gradle/maven"
        }
    }
}

// This is all related to the withGeckoBinaries approach; see
// mobile/android/gradle/with_gecko_binaries.gradle.
afterEvaluate {
    // The bundle tasks are only present when the particular configuration is
    // being built, so this task might not exist.  (This is due to the way the
    // Android Gradle plugin defines things during configuration.)
    def bundleWithGeckoBinaries = tasks.findByName('bundleWithGeckoBinariesReleaseAar')
    if (!bundleWithGeckoBinaries) {
        return
    }

    // Remove default configuration, which is the release configuration, when
    // we're actually building withGeckoBinaries.  This makes `gradle install`
    // install the withGeckoBinaries artifacts, not the release artifacts (which
    // are withoutGeckoBinaries and not suitable for distribution.)
    def Configuration archivesConfig = project.getConfigurations().getByName('archives')
    archivesConfig.artifacts.removeAll { it.extension.equals('aar') }

    // For now, ensure Kotlin is only used in tests.
    android.sourceSets.all { sourceSet ->
        if (sourceSet.name.startsWith('test') || sourceSet.name.startsWith('androidTest')) {
            return
        }
        (sourceSet.java.srcDirs + sourceSet.kotlin.srcDirs).each {
            if (!fileTree(it, { include '**/*.kt' }).empty) {
                throw new GradleException("Kotlin used in non-test directory ${it.path}")
            }
        }
    }
}

// Bug 1353055 - Strip 'vars' debugging information to agree with moz.build.
apply from: "${topsrcdir}/mobile/android/gradle/debug_level.gradle"
android.libraryVariants.all configureVariantDebugLevel

// There's nothing specific to the :geckoview project here -- this just needs to
// be somewhere where the Android plugin is available so that we can fish the
// path to "android.jar".
task("generateSDKBindings", type: JavaExec) {
    classpath project(':annotations').jar.archivePath
    classpath project(':annotations').compileJava.classpath
    classpath project(':annotations').sourceSets.main.runtimeClasspath

    // To use the lint APIs: "Lint must be invoked with the System property
    // com.android.tools.lint.bindir pointing to the ANDROID_SDK tools
    // directory"
    systemProperties = [
        'com.android.tools.lint.bindir': "${android.sdkDirectory}/tools",
    ]

    mainClass = 'org.mozilla.gecko.annotationProcessors.SDKProcessor'
    // We only want to generate bindings for the main framework JAR,
    // but not any of the additional android.test libraries.
    args android.bootClasspath.findAll { it.getName().startsWith('android.jar') }
    args 29
    args "${topobjdir}/widget/android/bindings"

    // Configure the arguments at evaluation-time, not at configuration-time.
    doFirst {
        // From -Pgenerate_sdk_bindings_args=... on command line; missing in
        // `android-gradle-dependencies` toolchain task.
        if (project.hasProperty('generate_sdk_bindings_args')) {
            args project.generate_sdk_bindings_args.split(';')
        }
    }

    workingDir "${topsrcdir}/widget/android/bindings"

    dependsOn project(':annotations').jar
}

apply plugin: 'org.mozilla.apilint'

apiLint {
    // TODO: Change this to `org` after hiding org.mozilla.gecko
    packageFilter = 'org.mozilla.geckoview'
    changelogFileName = 'src/main/java/org/mozilla/geckoview/doc-files/CHANGELOG.md'
    skipClassesRegex = [
        '^org.mozilla.geckoview.BuildConfig$',
        '^org.mozilla.geckoview.R$',
    ]
    lintFilters = ['GV']
    deprecationAnnotation = 'org.mozilla.geckoview.DeprecationSchedule'
    libraryVersion = mozconfig.substs.MOZILLA_VERSION.split('\\.')[0] as Integer
    allowedPackages = [
        'java',
        'android',
        'androidx',
        'org.json',
        'org.mozilla.geckoview',
    ]
}