Bug 1820467 - Removed dependency to google_material from support-ktx gradle. (https...
[gecko.git] / mobile / android / fenix / docs / substituting-local-ac-and-gv.md
blobaab7c16c8d902c0ec49dbf816d6aab6d29e1eb29
1 # Substituting local ac and GV
2 To build fenix with a local android-components or local GeckoView, we recommend the following methods:
4 |type|fenix -> local ac|fenix -> local GV|fenix -> local ac -> local GV|
5 |-|-|-|-|
6 |**method**|local.properties|local.properties|manual publish + local.properties|
8 For instructions with `local.properties`, see [the root README](https://github.com/mozilla-mobile/fenix/blob/main/README.md). For instructions on manual publish + local.properties, keep reading. See [ac#8386](https://github.com/mozilla-mobile/android-components/issues/8386) for why we can't use local properties for fenix -> local ac -> local GV publishing.
10 ## fenix -> local ac -> local GV
11 We're going to manually publish our GeckoView to our local maven repository, modify ac locally to consume it, and use local.properties to build fenix -> local ac.
13 ### 1. Synchronize checkouts
14 To avoid breaking changes causing our builds to fail, we should make sure each of the repositories is on a commit from around the same time frame. You can use the [`android-components/tools/list_compatible_dependency_versions.py` script](https://github.com/mozilla-mobile/android-components/blob/main/tools/list_compatible_dependency_versions.py) to trivially identify ac and GV builds from a given fenix commit. If you want to synchronize builds from a GV or ac commit, you'll likely need to try to align around the commit merge dates (use `git log --pretty=fuller`).
16 ### 2. Manually publish GeckoView
17 With our builds synchronized, we can publish our local changes to GeckoView. To publish GeckoView, run:
18 ```sh
19 ./mach build && ./mach gradle \
20     geckoview:publishWithGeckoBinariesDebugPublicationToMavenLocal \
21     exoplayer2:publishDebugPublicationToMavenLocal
22 ```
24 This **needs to be run every time you make changes.**
26 We also need to know what version of GeckoView we published. You can make this local change:
27 ```diff
28 diff --git a/mobile/android/geckoview/build.gradle b/mobile/android/geckoview/build.gradle
29 --- a/mobile/android/geckoview/build.gradle
30 +++ b/mobile/android/geckoview/build.gradle
31 @@ -382,16 +382,17 @@ android.libraryVariants.all { variant ->
32      // and we can simply extend its inputs.  See
33      // https://android.googlesource.com/platform/tools/base/+/0cbe8846f7d02c0bb6f07156b9f4fde16d96d329/build-system/gradle-core/src/main/java/com/android/build/gradle/tasks/BundleAar.kt#94.
34      variant.packageLibraryProvider.get().from("${topsrcdir}/toolkit/components/telemetry/geckoview/streaming/metrics.yaml")
35  }
37  apply plugin: 'maven-publish'
39  version = getVersionNumber()
40 +println("version = " + version)
41  group = 'org.mozilla.geckoview'
43  def getArtifactId() {
44      def id = "geckoview" + project.ext.artifactSuffix
46      if (!mozconfig.substs.MOZ_ANDROID_GECKOVIEW_LITE) {
47          id += "-omni"
48      }
49 ```
51 And execute `./mach build | grep version` to find a version number like `98.0.20211208151112-SNAPSHOT`.
53 ### 3. Modify ac to consume local GV
54 Update the build.gradle and Gecko.kt file in Fenix (see the diff below). Remember to update the GV version with the version you found in step 2!
55 ```diff
56 diff --git a/build.gradle b/build.gradle
57 index fa8149781f..863df65a57 100644
58 --- a/build.gradle
59 +++ b/build.gradle
60 @@ -6,6 +6,7 @@ import static org.gradle.api.tasks.testing.TestResult.ResultType
62  buildscript {
63      repositories {
64 +        mavenLocal()
65          if (project.hasProperty("googleRepo")) {
66              maven {
67                  name "Google"
68 @@ -40,6 +41,7 @@ plugins {
70  allprojects {
71      repositories {
72 +        mavenLocal()
73          if (project.hasProperty("googleRepo")) {
74              maven {
75                  name "Google"
76 diff --git a/buildSrc/src/main/java/Gecko.kt b/buildSrc/src/main/java/Gecko.kt
77 index 331158bf50..f37a05791a 100644
78 --- a/buildSrc/src/main/java/Gecko.kt
79 +++ b/buildSrc/src/main/java/Gecko.kt
80 @@ -9,7 +9,10 @@ object Gecko {
81      /**
82       * GeckoView Version.
83       */
84 -    const val version = "98.0.20220125100058"
85 +    const val version = "98.0.20211208151112-SNAPSHOT"
87      /**
88       * GeckoView channel
89 @@ -23,7 +26,7 @@ object Gecko {
90  enum class GeckoChannel(
91      val artifactName: String
92  ) {
93 -    NIGHTLY("geckoview-nightly-omni"),
94 +    NIGHTLY("geckoview-default-omni"),
95      BETA("geckoview-beta-omni"),
96      RELEASE("geckoview-omni")
97  }
98 ```
100 ### 4. Build fenix with local.properties change
101 Now build fenix as usual with [the `local.properties` change](https://github.com/mozilla-mobile/fenix#auto-publication-workflow-for-android-components-and-application-services) to build with your local ac. This build will automatically build ac each time it is run. You should have a fenix -> local ac -> local GV build now!