Source code
Revision control
Copy as Markdown
Other Tools
/* 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 static org.mozilla.conventions.BuildConfigKt.getBuildId
buildscript {
repositories {
gradle.configureMavenRepositories(delegate)
}
dependencies {
classpath libs.mozilla.glean.gradle.plugin
}
}
plugins {
alias(libs.plugins.dependency.analysis)
alias(libs.plugins.python.envs.plugin)
id 'org.mozilla.nimbus-gradle-plugin'
}
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
packaging {
resources {
excludes += ['META-INF/LICENSE.md', 'META-INF/LICENSE-notice.md']
}
}
buildFeatures {
buildConfig = true
}
namespace = 'mozilla.components.browser.engine.gecko'
}
// Set configuration for the Glean parser to extract metrics.yaml
// file from AAR dependencies of this project rather than look
// for it into the project directory.
ext.allowMetricsFromAAR = true
dependencies {
if (findProject(":geckoview") != null) {
api project(':geckoview')
} else {
api getGeckoViewDependency()
}
// We only compile against Glean. It's up to the app to add those dependencies
// if it wants to collect GeckoView telemetry through the Glean SDK.
compileOnly libs.mozilla.glean
implementation project(':components:concept-engine')
implementation project(':components:concept-fetch')
implementation(project(':components:service-nimbus')) {
exclude group: 'org.mozilla.telemetry', module: 'glean-native'
}
implementation project(':components:support-ktx')
implementation project(':components:support-utils')
implementation libs.androidx.core.ktx
implementation libs.androidx.datastore.preferences
implementation libs.androidx.lifecycle.livedata
implementation libs.androidx.paging
implementation libs.kotlinx.coroutines
testImplementation project(':components:support-test')
testImplementation project(':components:tooling-fetch-tests')
testImplementation testFixtures(project(':components:support-utils'))
testImplementation libs.androidx.test.core
testImplementation libs.androidx.test.junit
testImplementation libs.androidx.work.testing
testImplementation libs.kotlinx.coroutines.test
testImplementation libs.mockwebserver
testImplementation libs.mozilla.glean
testImplementation libs.okhttp
testImplementation libs.okio
testImplementation libs.robolectric
androidTestImplementation project(':components:tooling-fetch-tests')
androidTestImplementation libs.androidx.test.core
androidTestImplementation libs.androidx.test.rules
androidTestImplementation libs.androidx.test.runner
}
ext {
gleanNamespace = "mozilla.telemetry.glean"
gleanPythonEnvDir = gradle.mozconfig.substs.GRADLE_GLEAN_PARSER_VENV
}
apply plugin: "org.mozilla.telemetry.glean-gradle-plugin"
apply from: '../../../common-config.gradle'
apply from: '../../../publish.gradle'
nimbus {
// The path to the Nimbus feature manifest file
manifestFile = "geckoview.fml.yaml"
channels = [
debug: "debug",
release: "release",
]
// This is an optional value, and updates the plugin to use a copy of application
// services. The path should be relative to the root project directory.
// *NOTE*: This example will not work for all projects, but should work for Fenix, Focus, and Android Components
applicationServicesDir = gradle.hasProperty('localProperties.autoPublish.application-services.dir')
? gradle.getProperty('localProperties.autoPublish.application-services.dir') : null
}
ext.configurePublish(config.componentsGroupId, project.name, project.ext.description)
// Non-official versions are like "61.0a1", where "a1" is the milestone.
// This simply strips that off, leaving "61.0" in this example.
def getAppVersionWithoutMilestone() {
return gradle.mozconfig.substs.MOZ_APP_VERSION.replaceFirst(/a[0-9]/, "")
}
def getVersionNumber() {
def appVersion = getAppVersionWithoutMilestone()
def parts = appVersion.split('\\.')
def version = parts[0] + "." + parts[1] + "." + getBuildId(gradle.mozconfig.topobjdir)
if (!gradle.mozconfig.substs.MOZILLA_OFFICIAL && !gradle.mozconfig.substs.MOZ_ANDROID_FAT_AAR_ARCHITECTURES) {
// Use -SNAPSHOT versions locally to enable the local GeckoView substitution flow.
version += "-SNAPSHOT"
}
return version
}
def getArtifactSuffix() {
def suffix = ""
// Release artifacts don't specify the channel, for the sake of simplicity.
if (gradle.mozconfig.substs.MOZ_UPDATE_CHANNEL != 'release') {
suffix += "-${gradle.mozconfig.substs.MOZ_UPDATE_CHANNEL}"
}
return suffix
}
def computeArtifactId() {
def id = "geckoview" + getArtifactSuffix()
if (!gradle.mozconfig.substs.MOZ_ANDROID_GECKOVIEW_LITE) {
id += "-omni"
}
if (gradle.mozconfig.substs.MOZILLA_OFFICIAL && !gradle.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 += "-${gradle.mozconfig.substs.ANDROID_CPU_ARCH}"
}
return id
}
def getGeckoViewDependency() {
// on try, relax geckoview version pin to allow for --use-existing-task
if ('https://hg.mozilla.org/try' == System.env.GECKO_HEAD_REPOSITORY) {
rootProject.logger.lifecycle("Getting geckoview on try: ${computeArtifactId()}:+")
return "org.mozilla.geckoview:${computeArtifactId()}:+"
}
rootProject.logger.lifecycle("Getting geckoview: ${computeArtifactId()}:${getVersionNumber()}")
return "org.mozilla.geckoview:${computeArtifactId()}:${getVersionNumber()}"
}