Using locally-published Glean in Fenix
Note: This is a bit tedious, and you might like to try the substitution-based approach documented in Working on unreleased Glean code in android-components. That approach is still fairly new, and the local-publishing approach in this document is necessary if it fails.
Note: This is Fenix-specific only in that some links on the page go to the
mozilla-mobile/fenix
repository, however these steps should work for e.g.reference-browser
, as well. (Same goes for Lockwise, or any other consumer of Glean, but they may use a different structure -- Lockwise has no Dependencies.kt, for example)
Preparation
Clone the Glean SDK, android-components and Fenix repositories:
git clone https://github.com/mozilla/glean
git clone https://github.com/mozilla-mobile/android-components
git clone https://github.com/mozilla-mobile/fenix/
Local publishing
-
Inside the
glean
repository root:-
In
.buildconfig.yml
, changelibraryVersion
to end in-TESTING$N
1, where$N
is some number that you haven't used for this before.Example:
libraryVersion: 22.0.0-TESTING1
-
Check your
local.properties
file, and addrust.targets=x86
if you're testing on the emulator,rust.targets=arm
if you're testing on 32-bit arm (arm64 for 64-bit arm, etc). This will make the build that's done in the next step much faster. -
Run
./gradlew publishToMavenLocal
. This may take a few minutes.
-
-
Inside the
android-components
repository root:-
In
.buildconfig.yml
, changecomponentsVersion
to end in-TESTING$N
1, where$N
is some number that you haven't used for this before.Example:
componentsVersion: 24.0.0-TESTING1
-
Inside
buildSrc/src/main/java/Dependencies.kt
, changemozilla_glean
to reference thelibraryVersion
you published in step 2 part 1.Example:
const val mozilla_glean = "22.0.0-TESTING1"
-
Inside
build.gradle
, addmavenLocal()
insideallprojects { repositories { <here> } }
. -
Add the following block in the
settings.gradle
file, before any other statement in the script, in order to have the Glean Gradle plugin loaded from the local Maven repository.
pluginManagement { repositories { mavenLocal() gradlePluginPortal() } }
-
Inside the android-component's
local.properties
file, ensuresubstitutions.glean.dir
is NOT set. -
Run
./gradlew publishToMavenLocal
.
-
-
Inside the
fenix
repository root:-
Inside
build.gradle
, addmavenLocal()
insideallprojects { repositories { <here> } }
. -
Inside
buildSrc/src/main/java/Dependencies.kt
, changemozilla_android_components
to the version you defined in step 3 part 1.Example:
const val mozilla_android_components = "24.0.0-TESTING1"
In the same file change
mozilla_glean
to the version you defined in step 1 part 1.Example:
const val mozilla_glean = "22.0.0-TESTING1"
-
Change the
Versions.mozilla_android_components.endsWith('-SNAPSHOT')
line inapp/build.gradle
toVersions.mozilla_android_components.endsWith('-TESTING$N')
where$N
is the number to reference the version you published in part 2.
-
You should now be able to build and run Fenix (assuming you could before all this).
Caveats
- This assumes you have followed the Android/Rust build setup
- Make sure you're fully up to date in all repositories, unless you know you need to not be.
- This omits the steps if changes needed because, e.g. Glean made a breaking change to an API used in android-components. These should be understandable to fix, you usually should be able to find a PR with the fixes somewhere in the android-component's list of pending PRs (or, failing that, a description of what to do in the Glean changelog).
- Ask in the #glean channel on chat.mozilla.org.
Notes
This document is based on the equivalent documentation for application-services: Using locally-published components in Fenix
It doesn't have to end with -TESTING$N
, it only needs to have the format -someidentifier
.
-SNAPSHOT$N
is also very common to use, however without the numeric suffix, this has specific meaning to gradle,
so we avoid it.
Additionally, while the $N
we have used in our running example has matched
(e.g. all of the identifiers ended in -TESTING1
, this is not required, so long as you match everything up correctly at the end).