Instructions in this GEMINI.md file are project-specific guidelines. They take precedence over general defaults for AI agents working in this repository.
This repository hosts Gradle plugins that improve the developer experience for the Google Play services SDK and Firebase.
- Philosophy: Plugins are optional enhancers, not requirements for using client libraries.
- Source of Truth: GitHub is the primary source of truth.
- Structure: The repository is a monorepo containing independent Gradle projects. Each plugin is its own standalone project with its own
build.gradle.kts,settings.gradle, and Gradle wrapper.
- Purpose: Automates the integration of Firebase and Google Play Services configuration into Android applications.
- Architecture: Hooks into the Android Gradle Plugin (AGP) via the
ApplicationAndroidComponentsExtensionandDynamicFeatureAndroidComponentsExtension. It dynamically registers aGoogleServicesTaskfor every application variant. - Logic: The plugin searches for
google-services.jsonfiles using a hierarchical folder pattern (based on build types and product flavors). It parses the JSON to extract specific API keys, project IDs, and tracking IDs, then generates an Android XML resource file (values.xml) that the SDKs consume at runtime. - Integration: By default, it integrates with the
strict-version-matcher-pluginto perform dependency analysis and ensure version compatibility across Google-owned libraries.
- Purpose: Automates the collection and attribution of open-source licenses for Android applications.
- Architecture: Primarily implemented in Groovy. It hooks into the AGP lifecycle to register a task pipeline consisting of
DependencyTaskandLicensesTask. - Logic:
LicensesTaskresolves the license information for every dependency. It uses Gradle'sArtifactResolutionQueryandArtifactViewto fetch POM files and libraries lazily, ensuring full compatibility with the Gradle Configuration Cache. For Google Play Services and Firebase AARs, it employs a specialized extraction strategy to read embedded license JSON and text files. - Output: It produces two specific raw resources—
third_party_licensesandthird_party_licenses_metadata—which are wired to the Android resources source set for consumption by theplay-services-oss-licensesruntime library.
- Purpose: Enforces version consistency for Google Play Services and Firebase dependencies to prevent runtime crashes caused by incompatible library versions.
- Architecture: A standalone utility that can be applied directly or used as a library by other plugins (like
google-services-plugin). - Logic: It inspects the final resolved dependency graph of a project. It compares the versions Gradle selected against the original version ranges specified in the artifacts' POM files. If Gradle's resolution upgrades a dependency across a major version boundary that violates the original constraints, the plugin fails the build with a descriptive error.
- Languages: Kotlin (preferred for new logic and tests) or Java. The
oss-licenses-pluginis written in Groovy. - Build System: Gradle with Kotlin DSL (
build.gradle.kts) is the preferred standard. JDK 17 is the current build environment standard.
Managed via GitHub Actions with modern best practices:
- Workflows:
main.yml: The primary CI workflow. It includes alint-and-checkjob (Gradle Wrapper validation, Actionlint, and Ratchet) and executes a build matrix that independently runsassemble,check, andtestfor each plugin project.generate_release_rcs.yml: Handles the generation of release candidates.
- Security & Maintenance:
- Version Pinning:
sethvargo/ratchetis used to enforce that all GitHub Actions are pinned to immutable SHA-256 checksums to protect against supply chain attacks. - Dependabot: GitHub Action updates are consolidated into a weekly grouped Pull Request to minimize noise.
- Linting: All workflows are linted using
abcxyz/actions/lint-github-actions(incorporatingactionlintandshellcheck) to ensure syntax correctness.
- Version Pinning:
- Best Practices: We use
gradle/actions/setup-gradlefor high-performance caching and automatic dependency graph submission.
- Standard: Branches should be named using the format
username/description(e.g.,<username>/description).
- Requirement: Every source file (
.kt,.java,.gradle.kts,.groovy,.sh) must include an Apache 2.0 license header. - Format: Use the standard Apache 2.0 block.
- Copyright Text:
Copyright <Year> Google LLC - Year: Use the year the file was created (first published). Do not use a range unless the content has significantly changed. Do not update the year solely for the sake of updating it.
- Entity: Always use "Google LLC" (never "Google Inc.").
- Standard: Follow Semantic Versioning (SemVer).
- Management: Versions are managed independently within each plugin's
build.gradle.ktsfile.
- Testing: All changes must be verified with tests.
oss-licenses-pluginrequires verification against the full AGP/Gradle version matrix inEndToEndTest.kt. - Configuration Cache: New tasks or refactors MUST maintain compatibility with the Gradle Configuration Cache. Use lazy properties and avoid direct project access during task execution.
- Commit Messages: Follow the Conventional Commits specification.
- Format:
<type>[optional scope]: <description> - Common types:
feat,fix,docs,style,refactor,perf,test,build,ci,chore,revert. - Use a
!after the type/scope for breaking changes (e.g.,feat!: rewrite plugin architecture).
- Format:
- Proactiveness: When updating dependencies or AGP, verify the impact across all standalone plugin projects in the monorepo.
- Local Ratchet Usage: Developers are encouraged to run
ratchet pin .github/workflows/*.ymllocally before submitting PRs with new actions.