com um clique
android-new-module
// Guide for creating new Android gradle modules in the android-components project.
// Guide for creating new Android gradle modules in the android-components project.
Steps to reliably split a commit/change using the jj (jujutsu) VCS
Analyze a range of local commits, and reorganize them to minimize latency and friction in the review and landing process. To achieve this, commits can be split, reordered, squashed / grouped, or even rewritten. In the final commit series / "patch stack", the codebase should build, lint, and test cleanly after every commit, and each individual commit should stand on its own.
Structured performance opportunity investigation for SpiderMonkey (the Firefox JavaScript engine). Use this skill when the user wants to investigate JS engine performance, profile SpiderMonkey, find optimization opportunities, write performance patches, or evaluate benchmark regressions. Trigger on mentions of: profiling JS, SpiderMonkey performance, JIT optimization, benchmark regression analysis, shell benchmarking, or any request to make JS workloads faster. The methodolgy is described mostly for the JS shell but can be adapted to browser investigation.
Analyze Firefox performance profiles using the profiler-cli CLI tool. Trigger when given a profiler.firefox.com or share.firefox.dev link, a local profile path, or when the user wants to investigate an issue in a Firefox profile. Always use this skill instead of WebFetch for Firefox profiler URLs; WebFetch only retrieves the profiler UI's HTML shell and cannot access profile data, whereas profiler-cli downloads and parses the actual profile into a local daemon that supports structured queries over stacks, markers, threads, and samples.
Use webspec-index to query WHATWG, W3C, IETF and TC39 web specifications from the command line
Map relationships between a web spec section, its Firefox implementation code, and Web Platform Tests. Use when starting work on a spec feature, checking implementation coverage, or finding which WPTs to enable.
| name | android-new-module |
| description | Guide for creating new Android gradle modules in the android-components project. |
This skill helps you create new Android gradle modules following Mozilla's conventions and structure. Components are organized into categories: browser, concept, feature, lib, service, support, ui, and compose.
Create a plan to execute the steps. The plan should include all nine steps below.
Ask the user:
my-component)publish: true, examples are publish: false)mkdir -p mobile/android/android-components/components/{category}/{name}/src/main/java/mozilla/components/{category}/{name}
mkdir -p mobile/android/android-components/components/{category}/{name}/src/test/java/mozilla/components/{category}/{name}
mkdir -p mobile/android/android-components/components/{category}/{name}/src/test/resources
Reference the example at mobile/android/android-components/components/feature/example/build.gradle for the standard structure.
Key elements:
com.android.library and kotlin-androidmozilla.components.{category}.{name}androidx.core.ktx, kotlinx.coroutinesjunit.bom, junit4, robolectric, kotlinx.coroutines.testAdd dependencies as needed:
implementation project(':components:support-base')libs.androidx.lifecycle.runtimeplatform(libs.androidx.compose.bom) and compose dependenciesimplementation project(':components:lib-state')implementation project(':components:browser-state')implementation project(':components:{category}:{component-name}')File: src/main/AndroidManifest.xml
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<manifest />
File: src/main/java/mozilla/components/{category}/{name}/{ComponentName}.kt
Reference the example at mobile/android/android-components/components/feature/example/src/main/java/mozilla/components/feature/example/ExampleFeature.kt.
Key elements for a feature component:
mozilla.components.{category}.{name}LifecycleAwareFeature for lifecycle-aware featuresCoroutineDispatcher)start(), stop())For simpler library components, a basic class with the necessary methods is sufficient.
File: src/test/java/mozilla/components/{category}/{name}/{ComponentName}Test.kt
Reference the example at mobile/android/android-components/components/feature/example/src/test/java/mozilla/components/feature/example/ExampleFeatureTest.kt.
Key elements:
StandardTestDispatcher from kotlinx.coroutines.test for testing coroutinesrunTest(testDispatcher) to run tests with coroutine supporttestDispatcher.scheduler.advanceUntilIdle() to advance virtual time`start triggers onUpdate callback`)File: src/test/resources/robolectric.properties
sdk=35
This configures Robolectric to use Android SDK 35 for unit tests.
File: README.md
Reference the example at mobile/android/android-components/components/feature/example/README.md.
Key elements:
# [android-components](../../../README.md) > {Category} > {Name}Add the component to .buildconfig.yml in alphabetical order within its category:
components:{category}-{name}:
description: {Brief description}
path: components/{category}/{name}
publish: true
Find the correct insertion point by searching for the category (e.g., components:feature- for feature modules) and inserting in alphabetical order.
Then update the upstream_dependencies for the new buildconfig with this mach command:
./mach android update-buildconfig android-components
Also update taskcluster/config.yml to add the new module's display name to treeherder.group-names. Without this step, CI will fail with a buildconfig mismatch error.
mozilla.components.{category}.{name}mozilla.components.feature.examplemy-component → MyComponentapi - For interfaces and contracts (concept modules)implementation - For internal dependenciestestImplementation - For testing dependenciesandroidTestImplementation - For instrumented tests@VisibleForTesting for test-only visibilityAfter creating the component, verify it builds with the debug variant:
./mach gradle :components:{category}-{name}:buildDebug
Run tests:
./mach gradle :components:{category}-{name}:testDebug
Format and lint:
./mach lint --fix mobile/android/android-components/components/{category}/{name}
./mach gradle instead of gradlew to ensure the build system is executed in its entirety.publish: false for example/sample components because we do not want them to be distributed through the maven mirrors..buildconfig.yml.