Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite docs on how to use local glean plugin in m-c #3033

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .dictionary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
personal_ws-1.1 en 294 utf-8
personal_ws-1.1 en 295 utf-8
AAR
AARs
ABI
Expand All @@ -18,6 +18,7 @@ CODEOWNERS
Cartfile
CircleCI
Ciufo
Codebase
DNS
DOM
Datetime
Expand Down
4 changes: 2 additions & 2 deletions docs/dev/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
- [Setup Build Environment](android/setup-android-build-environment.md)
- [Android SDK/NDK versions](android/sdk-ndk-versions.md)
- [Logging](android/logging.md)
- [Development with android-components](android/development-with-android-components.md)
- [Locally-published components in Fenix](android/locally-published-components-in-fenix.md)
- [Development with mozilla-central](android/development-with-mozilla-central.md)
- [Replacing the Glean Gradle plugin in mozilla-central](android/gradle-plugin-in-mc.md)
- [Substituting glean_parser](android/glean-parser-substitution.md)
- [iOS bindings](ios/index.md)
- [Setup Build Environment](ios/setup-ios-build-environment.md)
Expand Down
86 changes: 0 additions & 86 deletions docs/dev/android/development-with-android-components.md

This file was deleted.

52 changes: 52 additions & 0 deletions docs/dev/android/development-with-mozilla-central.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# 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](https://firefox-source-docs.mozilla.org/toolkit/components/glean/dev/local_glean.html) 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](https://firefox-source-docs.mozilla.org/setup/index.html) for more.

Clone the Glean SDK repositories:

```sh
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](https://github.com/ncalexan/rust-android-gradle/blob/HEAD/README.md#specifying-local-targets)):

```
# 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`:

```groovy
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](gradle-plugin-in-mc.md).
> For replacing `glean_parser` in a local build, see [Substituting `glean_parser`](glean-parser-substitution.md).
35 changes: 35 additions & 0 deletions docs/dev/android/gradle-plugin-in-mc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Replacing the Glean Gradle plugin in mozilla-central

> **Note**: If you only need to replace the `glean_parser` Python parts used in the build see [Substituting `glean_parser`](glean-parser-substitution.md).
> The approached documented in this chapter is only necessary if you changed `GleanGradlePlugin.groovy`.

If you need to replace the Glean Gradle Plugin used by any component in mozilla-central, follow these steps:

1. In your Glean repository increment the version number in `.buildconfig.yml` to something unused:

```yaml
libraryVersion: 70.0.0
```

1. Build the Glean Gradle plugin and publish the plugin locally:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing requirement of needing to have maven installed locally to serve the package. I think you can get it from homebrew 🤔


```
./gradlew glean-gradle-plugin:publishToMavenLocal
```

1. In your `mozilla-central` checkout, add the following line in `mobile/android/fenix/settings.gradle` file in the `pluginManagement` block:

```gradle
mavenLocal()
```

1. Use the new version number where the plugin is imported in `mobile/android/fenix/build.gradle`:

```
classpath "org.mozilla.telemetry:glean-gradle-plugin:70.0.0"
```

This might need to be applied to the top-level `build.gradle` and other `build.gradle` files under `mobile/android` to apply to all components.


Building Fenix will now use your locally published Glean Gradle Plugin.
36 changes: 0 additions & 36 deletions docs/dev/android/locally-published-components-in-fenix.md

This file was deleted.

Loading