Skip to content

Commit 662baa2

Browse files
committed
Fixup localpublish workflows.
1 parent 280db3a commit 662baa2

File tree

2 files changed

+47
-18
lines changed

2 files changed

+47
-18
lines changed

automation/publish_to_maven_local_if_modified.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import os
1313
import sys
1414
import time
15+
import shutil
1516

1617
from shared import fatal_err, find_app_services_root, run_cmd_checked
1718

@@ -113,6 +114,9 @@
113114
print("Contents have not changed, no need to publish")
114115
else:
115116
print("Contents have changed, publishing")
117+
# Ensure rust changes get picked up. No idea why, but stale .so files under `intermediates` end up published.
118+
# Repro: 1) publish, 2) change rust, re-publish, 3) rust from first step is still in the artifacts; not all "dupe" .so files are identical.
119+
shutil.rmtree("./megazords/full/android/build/intermediates", ignore_errors=True)
116120
run_cmd_checked(["./gradlew", "publishToMavenLocal", f"-Plocal={time.time_ns()}"])
117121
with open(LAST_CONTENTS_HASH_FILE, "w") as f:
118122
f.write(contents_hash)

docs/howtos/locally-published-components-in-fenix.md

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,69 @@ from there.
88
With support from the upstream project, it's possible to do this in a single step using
99
our auto-publishing workflow.
1010

11-
## rust.targets
11+
# Using the auto-publishing workflow
12+
13+
mozilla-central has support for automatically publishing and including a local development version of application-services in the build.
14+
This is supported for most of the Android targets available in mozilla-central including Fenix - this
15+
doc will focus on Fenix, but the same general process is used for all. The workflow is:
16+
17+
## Pre-requisites:
18+
1. Ensure you have a regular [build of application-services working](../building.md).
19+
1. Disable the gradle cache in mozilla-central - edit `./gradle.properties`, comment out `org.gradle.configuration-cache=true`
20+
1. Ensure you have a regular build of Fenix from mozilla-central testable in Android Studio or an emulator.
21+
22+
## Setup 2 x `local.properties`
23+
24+
Edit (or create) the file `local.properties` in each of the repos:
25+
26+
### app-services
27+
28+
In the root of the app-services repo:
29+
30+
Please be sure you have read [our guide to building Fenix](../building.md#building-for-fenix) and successfully built
31+
using the instructions there. In particular, this may lead you to adding `sdk.dir` and `ndk.dir` properties, and/or
32+
set environment variables `ANDROID_SDK_ROOT` and `ANDROID_HOME`.
33+
34+
In addition to those instructions, you will need:
35+
36+
#### rust.targets
1237

1338
Both the auto-publishing and manual workflows can be sped up significantly by
1439
using the `rust.targets` property which limits which architectures the Rust
15-
code gets build against. You can set this property by creating/editing the
16-
`local.properties` file in the repository root and adding a line like
40+
code gets build against. Adding a line like
1741
`rust.targets=x86,linux-x86-64`. The trick is knowing which targets to put in
1842
that comma separated list:
1943

20-
- Use `x86` for running the app on most emulators (in rare cases, when you have a 64-bit emulator, you'll want `x86_64`)
44+
- Use `x86` for running the app on most emulators on Intel hardware (in rare cases, when you have a 64-bit emulator, you'll want `x86_64`).
45+
- Use `arm64` for emulators running on Apple Silicon Macs.
2146
- If you're running the `android-components` or `fenix` unit tests, then you'll need the architecture of your machine:
2247
- OSX running Intel chips: `darwin-x86-64`
2348
- OSX running M1 chips: `darwin-aarch64`
2449
- Linux: `linux-x86-64`
2550

26-
## Using the auto-publishing workflow
51+
eg, on a Mac your `local.properties` file will have a single line, `rust.targets=darwin-aarch64,arm64`
2752

28-
mozilla-central has support for automatically publishing and including a local development version of application-services in the build.
29-
This is supported for most of the Android targets available in mozilla-central including Fenix - this
30-
doc will focus on Fenix, but the same general process is used for all. The workflow is:
53+
### mozilla-central
3154

32-
1. Ensure you have a regular build of Fenix working from mozilla-central and that you've done a `./mach build`
33-
1. Ensure you have a regular [build of application-services working](../building.md).
34-
1. Edit (or create) the file `local.properties` - this can be in the root of the mozilla-central checkout,
35-
or in the project specific directory (eg, `mobile/android/fenix`) and tell it where to
36-
find your local checkout of application-services, by adding a line like:
55+
`local.properties` can be in the root of the mozilla-central checkout,
56+
or in the project specific directory (eg, `mobile/android/fenix`) and you tell it where to
57+
find your local checkout of application-services by adding a line like:
58+
59+
`autoPublish.application-services.dir=path/to/your/checkout/of/application-services`
60+
61+
Note that the path can be absolute or relative from `local.properties`. For example, if `application-services`
62+
and `mozilla-central` are at the same level, and you are using a `local.properties` in the root of mozilla-central,
63+
the relative path would be `../application-services`
3764

38-
`autoPublish.application-services.dir=path/to/your/checkout/of/application-services`
65+
## Build and test your Fenix again.
3966

40-
Note that the path can be absolute or relative from `local.properties`. For example, if `application-services`
41-
and `mozilla-central` are at the same level, and you are using a `local.properties` in the root of mozilla-central,
42-
the relative path would be `../application-services`
43-
1. Build your target normally - eg, in Android Studio. or using `gradle`
67+
After configuring as described above, build and test your Fenix again.
4468

4569
If all goes well, this should automatically build your checkout of `application-services`, publish it
4670
to a local maven repository, and configure the consuming project to install it from there instead of
4771
from our published releases.
4872

73+
# Other notes
4974
### Using Windows/WSL
5075

5176
Good luck! This implies you are also building mozilla-central in a Windows/WSL environment;

0 commit comments

Comments
 (0)