Working on unreleased Glean code in mozilla-central
Note: This guide is for mozilla-central Android builds. If you only need to replace the Glean Rust parts, refer to Developing with a local Glean build in the Firefox Source Docs.
Note: This guide only refers to building Fenix. It should work similarly for Focus Android.
Preparation
This guide assumes you are already setup to build the mozilla-central repository for Android. Refer to Getting Set Up To Work On The Firefox Codebase for more.
Clone the Glean SDK repositories:
git clone https://github.com/mozilla/glean
Cargo build targets
By default when building Fenix using gradle, the rust-android plugin will compile Glean for every possible platform,
which might end up in build failures.
You can customize which targets are built in glean/local.properties
(more information):
# For physical devices:
rust.targets=arm
# For unit tests:
# rust.targets=darwin # Or linux-*, windows-* (* = x86/x64)
# For emulator only:
rust.targets=x86
Substituting projects
Fenix has custom build logic for dealing with composite builds,
so you should be able to configure it by simply adding the path to the Glean repository in the correct local.properties
file:
In mozilla-central/mobile/android/fenix/local.properties
:
autoPublish.glean.dir=../../../../glean
Make sure to use the correct path pointing to your Glean checkout.
Note: This substitution-based approach will not work for testing updates to the Glean Gradle plugin or
glean_parser
as shipped in the Glean Gradle Plugin.See Replacing the Glean Gradle plugin in mozilla-central.
For replacingglean_parser
in a local build, see Substitutingglean_parser
.
Manual mavenLocal()
If the Substituting projects does not work you can manually switch to using mavenLocal()
.
In the Glean repository:
- Bump the version:
bin/prepare-release.sh 65.1.0
- Only increase the minor version to ensure it works transitively
- Publish the Gradle project locally:
./gradlew publishToMavenLocal
- Check that the packages are available in
~/.m2/repository
In mozilla-central
:
- In
gradle.properties
remove the lineorg.gradle.configuration-cache=true
- Alternatively use
--no-build-cache --no-configuration-cache
on all Gradle invocations when building Fenix/Focus
- Alternatively use
- In
gradle/libs.versions.toml
change the version ofmozilla-glean
- In the top-level
build.gradle
addmavenLocal()
to therepositories
block underallprojects
, e.g.allprojects { repositories { mavenLocal() } }
- Further down in the top-level
build.gradle
disable the check inverifyGleanVersion
, e.g.@TaskAction void verifyGleanVersion() { }
Now you can build Fenix or Focus, for example with ./mach gradle fenix:assembleFenixDebug
.
After changes in the Glean repository publish a new package using ./gradlew publishToMavenLocal
and rebuild Fenix.
Try runs with development versions of Glean
Publish Glean to the local maven repository as above.
In mozilla-central
:
- Create a directory:
mkdir -p third_party/kotlin
- Add the local packages:
cp -a ~/.m2/repository/* third_party/kotlin
- Commit the new files:
git add third_party/kotlin && git commit -m "dev glean from local repo"
- Change the version number in
gradle/libs.versions.toml
- Add the following under
repositories
to the top-levelbuild.gradle
and nestedbuild.gradle
files:maven { url uri("${gradle.mozconfig.topsrcdir}/third_party/kotlin") }
The nested build.gradle
files are:
mobile/android/fenix/build.gradle
mobile/android/focus-android/build.gradle
mobile/android/android-components/build.gradle
You can now launch try tasks with the modified Glean.
After changes in the Glean repository publish a new package using ./gradlew publishToMavenLocal
,
then copy the files again with cp -a ~/.m2/repository/* third_party/kotlin
.
Commit the changes and push to try again.