/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import javax.inject.Inject plugins { id 'com.android.library' alias(libs.plugins.dependency.analysis) } android { namespace = 'mozilla.components.feature.webcompat' } // The webcompat extension is copied from `browser/extensions/webcompat/` into a generated assets // directory registered via the variant Sources API. The `extensions/webcompat/` subpath keeps the // extension accessible at `resource://android/assets/extensions/webcompat/`. abstract class SyncWebcompatExtension extends DefaultTask { @InputFiles @PathSensitive(PathSensitivity.RELATIVE) @IgnoreEmptyDirectories abstract ConfigurableFileCollection getSources() @Internal abstract Property getExtensionDir() @Internal abstract Property getGeneratedFilesDir() @OutputDirectory abstract DirectoryProperty getOutputDir() @Inject abstract FileSystemOperations getFs() @TaskAction void sync() { fs.sync { spec -> spec.from(extensionDir.get()) { exclude "run.js" } spec.from(generatedFilesDir.get()) spec.into(outputDir.get().dir("extensions/webcompat")) spec.exclude "**/tests/**", "**/components.conf", "**/moz.build", "**/codegen.py", "**/data/interventions", "**/templates" } } } def syncWebcompatExtension = tasks.register("syncWebcompatExtension", SyncWebcompatExtension) { def extension = "${gradle.mozconfig.topsrcdir}/browser/extensions/webcompat".toString() def generated = "${gradle.mozconfig.topobjdir}/mobile/android/webcompat_addon_generated_files".toString() extensionDir.set(extension) generatedFilesDir.set(generated) sources.from(extension, generated) } androidComponents { onVariants(selector().all()) { variant -> variant.sources.assets.addGeneratedSourceDirectory(syncWebcompatExtension) { it.outputDir } } } // DAGP explodes asset sources directly, so make that happen after the extension is synced. tasks.matching { it.name.startsWith("explodeAssetSource") }.configureEach { t -> t.dependsOn(syncWebcompatExtension) } dependencies { implementation project(':components:concept-engine') implementation libs.androidx.core implementation libs.kotlinx.coroutines testImplementation project(':components:support-test') testImplementation project(':components:support-webextensions') testImplementation libs.androidx.test.core testImplementation libs.androidx.test.junit testImplementation libs.kotlinx.coroutines.test testImplementation libs.robolectric } apply from: '../../../common-config.gradle' apply from: '../../../publish.gradle' ext.configurePublish(config.componentsGroupId, project.name, project.ext.description)