build.gradle (2564B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 import org.apache.tools.ant.filters.ReplaceTokens 6 7 apply plugin: 'com.android.library' 8 apply plugin: 'kotlin-android' 9 10 android { 11 sourceSets { 12 main { 13 assets { 14 srcDir layout.buildDirectory.dir("generated/assets/") 15 } 16 } 17 } 18 19 namespace = 'mozilla.components.feature.webcompat' 20 } 21 22 // We copy the webcompat extension from `browser/extensions/webcompat/` to 23 // `assets/extensions/webcompat/` by first copying the extension into the 24 // build directory, which is registered as the assets source directory. 25 // 26 // There is an `extensions/` folder in between, which is needed to access 27 // the extension at: `resource://android/assets/extensions/webcompat/`. 28 tasks.register("syncWebcompatExtension", Sync) { 29 def topsrcdir = gradle.mozconfig.topsrcdir 30 from "$topsrcdir/browser/extensions/webcompat" 31 into layout.buildDirectory.dir("generated/assets/extensions/webcompat/") 32 exclude "**/tests/**", "**/components.conf", "**/moz.build" 33 34 // webcompat adopted #include directives in Bug 1936031, which are only 35 // processed for Desktop builds. The filter below pre-processes the files 36 // that include these directives. 37 38 // configuration-cache doesn't allow calling file() from a groovy closure, 39 // in this case filesMatching callback, so we call file before the closure. 40 def interventionsJson = file("$topsrcdir/browser/extensions/webcompat/data/interventions.json") 41 filesMatching([ 42 '**/run.js', 43 ]) { 44 filter(ReplaceTokens, beginToken: '', endToken: '', tokens: [ 45 '#include data/interventions.json': interventionsJson.text.trim(), 46 ]) 47 } 48 } 49 50 dependencies { 51 implementation project(':components:concept-engine') 52 53 implementation libs.androidx.core.ktx 54 implementation libs.kotlinx.coroutines 55 56 testImplementation project(':components:support-test') 57 testImplementation project(':components:support-webextensions') 58 59 testImplementation libs.androidx.test.core 60 testImplementation libs.androidx.test.junit 61 testImplementation libs.kotlinx.coroutines.test 62 testImplementation libs.robolectric 63 } 64 65 apply from: '../../../common-config.gradle' 66 apply from: '../../../publish.gradle' 67 ext.configurePublish(config.componentsGroupId, project.name, project.ext.description) 68 preBuild.dependsOn syncWebcompatExtension