Bug 1906365 - Configure the Glean Gradle Plugin to use our vendored glean_parser. r=nalexander,geckoview-reviewers,android-reviewers,owlish

The Glean Gradle plugin now exposes ext.gleanPythonEnvDir for users to
point to an existing Python virtualenv where glean_parser is available.

As documented in https://mozilla.github.io/glean/book/language-bindings/android/android-build-configuration-options.html,
the Glean Gradle plugin options such as ext.gleanPythonEnvDir must be
set before applying the plugin.

This enables us to use gradle offline for Android builds (except the
android-gradle-dependencies task of course).

Differential Revision: https://phabricator.services.mozilla.com/D215795
This commit is contained in:
Nicolas Guichard 2024-09-09 17:33:49 +00:00
parent 2e3b4e7e8c
commit 72ea57475d
10 changed files with 41 additions and 18 deletions

View File

@ -101,7 +101,10 @@ dependencies {
androidTestImplementation project(':tooling-fetch-tests')
}
ext.gleanNamespace = "mozilla.telemetry.glean"
ext {
gleanNamespace = "mozilla.telemetry.glean"
gleanPythonEnvDir = gradle.mozconfig.substs.GRADLE_GLEAN_PARSER_VENV
}
apply plugin: "org.mozilla.telemetry.glean-gradle-plugin"
apply from: '../../../android-lint.gradle'
apply from: '../../../publish.gradle'

View File

@ -94,7 +94,10 @@ dependencies {
testImplementation ComponentsDependencies.mozilla_glean_forUnitTests
}
ext.gleanNamespace = "mozilla.telemetry.glean"
ext {
gleanNamespace = "mozilla.telemetry.glean"
gleanPythonEnvDir = gradle.mozconfig.substs.GRADLE_GLEAN_PARSER_VENV
}
apply plugin: "org.mozilla.telemetry.glean-gradle-plugin"
apply from: '../../../android-lint.gradle'
apply from: '../../../publish.gradle'

View File

@ -119,5 +119,8 @@ nimbus {
? gradle.getProperty('localProperties.autoPublish.application-services.dir') : null
}
ext.gleanNamespace = "mozilla.telemetry.glean"
ext {
gleanNamespace = "mozilla.telemetry.glean"
gleanPythonEnvDir = gradle.mozconfig.substs.GRADLE_GLEAN_PARSER_VENV
}
apply plugin: "org.mozilla.telemetry.glean-gradle-plugin"

View File

@ -88,5 +88,8 @@ dependencies {
androidTestImplementation ComponentsDependencies.testing_mockwebserver
}
ext.gleanNamespace = "mozilla.telemetry.glean"
ext {
gleanNamespace = "mozilla.telemetry.glean"
gleanPythonEnvDir = gradle.mozconfig.substs.GRADLE_GLEAN_PARSER_VENV
}
apply plugin: "org.mozilla.telemetry.glean-gradle-plugin"

View File

@ -51,6 +51,9 @@ dependencies {
implementation ComponentsDependencies.mozilla_glean
}
ext.gleanNamespace = "mozilla.telemetry.glean"
ext {
gleanNamespace = "mozilla.telemetry.glean"
gleanPythonEnvDir = gradle.mozconfig.substs.GRADLE_GLEAN_PARSER_VENV
}
apply plugin: "org.mozilla.telemetry.glean-gradle-plugin"

View File

@ -516,7 +516,12 @@ android.applicationVariants.configureEach { variant ->
}
// Generate Kotlin code for the Fenix Glean metrics.
ext.gleanNamespace = "mozilla.telemetry.glean"
ext {
// Enable expiration by major version.
gleanExpireByVersion = Config.majorVersion(project)
gleanNamespace = "mozilla.telemetry.glean"
gleanPythonEnvDir = gradle.mozconfig.substs.GRADLE_GLEAN_PARSER_VENV
}
apply plugin: "org.mozilla.telemetry.glean-gradle-plugin"
apply plugin: "org.mozilla.appservices.nimbus-gradle-plugin"
@ -923,6 +928,3 @@ def getSupportedLocales() {
def foundLocalesString = foundLocales.toString().replaceAll(',}', '}')
return foundLocalesString
}
// Enable expiration by major version.
ext.gleanExpireByVersion = Config.majorVersion(project)

View File

@ -204,7 +204,12 @@ tasks.withType(KotlinCompile).configureEach {
// -------------------------------------------------------------------------------------------------
// Generate Kotlin code for the Focus Glean metrics.
// -------------------------------------------------------------------------------------------------
ext.gleanNamespace = "mozilla.telemetry.glean"
ext {
// Enable expiration by major version.
gleanExpireByVersion = 1
gleanNamespace = "mozilla.telemetry.glean"
gleanPythonEnvDir = gradle.mozconfig.substs.GRADLE_GLEAN_PARSER_VENV
}
apply plugin: "org.mozilla.telemetry.glean-gradle-plugin"
apply plugin: "org.mozilla.appservices.nimbus-gradle-plugin"
@ -695,9 +700,6 @@ tasks.register('printVariants') {
}
}
// Enable expiration by major version.
ext.gleanExpireByVersion = 1
afterEvaluate {
// Format test output. Copied from Fenix, which was ported from AC #2401

View File

@ -658,3 +658,11 @@ def gradle_maven_repositories(values):
set_config("GRADLE_MAVEN_REPOSITORIES", gradle_maven_repositories)
@imports(_from="sys", _import="prefix")
def gradle_glean_parser_venv():
return prefix
set_config("GRADLE_GLEAN_PARSER_VENV", gradle_glean_parser_venv())

View File

@ -82,7 +82,7 @@ def configure_gradlew(config, job, taskdesc):
{
"ANDROID_SDK_ROOT": path.join(fetches_dir, "android-sdk-linux"),
"GRADLE_USER_HOME": path.join(
topsrc_dir, "mobile/android/gradle/dotgradle-online"
topsrc_dir, "mobile/android/gradle/dotgradle-offline"
),
"MOZ_BUILD_DATE": config.params["moz_build_date"],
}

View File

@ -24,10 +24,6 @@ pushd mobile/android/focus-android
./gradlew lint
popd
pushd mobile/android/android-components
# Before building anything we explicitly build one component that contains Glean and initializes
# the Miniconda Python environment and doesn't have (almost) any other transitive dependencies.
# If that happens concurrently with other tasks then this seems to fail quite often.
./gradlew service-nimbus:build
./gradlew -Pcoverage detekt lint service-nimbus:assembleAndroidTest samples-browser:testGeckoDebugUnitTest tooling-lint:test
popd