Skip to content

feat: build logic#4829

Merged
jamesarich merged 8 commits intomainfrom
feat/build-logic
Mar 17, 2026
Merged

feat: build logic#4829
jamesarich merged 8 commits intomainfrom
feat/build-logic

Conversation

@jamesarich
Copy link
Copy Markdown
Collaborator

This pull request introduces a new convention plugin for Kotlin Multiplatform (KMP) feature modules and updates documentation and build configuration to standardize its usage. It also removes unnecessary dependencies and improves Gradle configuration practices for better maintainability and build performance.

Build logic and plugin improvements:

  • Added a new meshtastic.kmp.feature convention plugin (KmpFeatureConventionPlugin) that composes existing library, Compose, and Koin plugins, and wires up shared dependencies for KMP feature modules. Feature modules now only need to declare their own specific dependencies. (build-logic/convention/src/main/kotlin/KmpFeatureConventionPlugin.kt, build-logic/convention/build.gradle.kts, [1] [2]
  • Updated plugin graph and graph generation logic to recognize the new meshtastic.kmp.feature plugin, improving project structure visualization and internal tooling. (build-logic/convention/src/main/kotlin/org/meshtastic/buildlogic/Graph.kt, [1] [2]

Gradle configuration enhancements:

  • Replaced afterEvaluate with lazy configuration (configureEach) in convention plugins and flavor resolution logic, following best practices for Gradle performance and reliability. (build-logic/convention/src/main/kotlin/org/meshtastic/buildlogic/FlavorResolution.kt, [1] [2]
  • Removed unnecessary and unused dependencies (javax.inject, devtools.ksp, truth, and some Compose runtime dependencies) from several modules to reduce build size and complexity. [1] [2] [3] [4] [5] [6] [7] [8]

Documentation updates:

  • Updated documentation (AGENTS.md, GEMINI.md, .github/copilot-instructions.md) to describe the new meshtastic.kmp.feature plugin, its purpose, and the expectation that all feature modules use it. Also added guidance on using lazy Gradle configuration in convention plugins. [1] [2] [3] [4] [5] [6] [7] [8] [9]

These changes collectively standardize feature module setup, improve build performance, and clarify project structure for contributors.

@github-actions github-actions bot added the enhancement New feature or request label Mar 17, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 13.38%. Comparing base (4ef2e5d) to head (91cb778).
⚠️ Report is 6 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4829   +/-   ##
=======================================
  Coverage   13.38%   13.38%           
=======================================
  Files         539      539           
  Lines       17753    17753           
  Branches     2651     2651           
=======================================
  Hits         2376     2376           
  Misses      15058    15058           
  Partials      319      319           
Flag Coverage Δ
host-unit 13.38% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

This commit introduces a new convention plugin, `KmpFeatureConventionPlugin`, to consolidate and standardize dependency management across Kotlin Multiplatform (KMP) feature modules. This change eliminates approximately 100 lines of redundant dependency declarations by centralizing common Compose, Lifecycle, and Koin configurations.

Key changes include:

- **New Convention Plugin:** Created `KmpFeatureConventionPlugin` which composes `kmp.library`, `kmp.library.compose`, and `koin` plugins.
- **Dependency Consolidation:**
    - Moved common `commonMain` dependencies (Compose M3, Lifecycle ViewModels, Koin Compose, Kermit) into the feature plugin.
    - Moved common `androidMain` dependencies (Compose BOM, Accompanist permissions, Activity Compose, Material3) into the feature plugin.
    - Automatically includes `core:testing` in `commonTest` for all features.
- **Module Migration:** Updated all feature modules (`intro`, `messaging`, `settings`, `firmware`, `node`, `map`, `connections`) to use the new `meshtastic.kmp.feature` plugin, significantly thinning their `build.gradle.kts` files.
- **Cleanup:**
    - Removed unused `javax.inject` and `ksp` dependencies from various core and feature modules.
    - Updated `Graph.kt` and project documentation (`AGENTS.md`, `GEMINI.md`, `ROADMAP.md`) to reflect the new plugin and architecture.
    - Refined `KmpLibraryComposeConventionPlugin` and related build logic to better support the new structure.

Signed-off-by: James Rich <[email protected]>
…endency injection

This commit removes the `javax.inject.Qualifier` annotations from the `core:prefs` module as part of the transition to Koin for dependency injection.

Specific changes include:
- Deleted `core/prefs/src/commonMain/kotlin/org/meshtastic/core/prefs/di/Qualifiers.kt` which contained numerous DataStore qualifiers (e.g., `AnalyticsDataStore`, `AppDataStore`, `MapDataStore`).
- Removed the `javax.inject` dependency from `core/prefs/build.gradle.kts`.

Signed-off-by: James Rich <[email protected]>
This commit refactors `libs.versions.toml` to centralize hardcoded versions into the `[versions]` block and removes unused dependencies. It also corrects documentation regarding automatically provided dependencies in build logic conventions.

Specific changes include:
- Centralized versions for `datadog-gradle`, `firebase-crashlytics-gradle`, and `google-services-gradle` by moving them to the `[versions]` block and referencing them in `[libraries]` and `[plugins]`.
- Removed unused `koin-annotations` version and `javax-inject` library definition.
- Updated `docs/BUILD_LOGIC_CONVENTIONS_GUIDE.md` to remove `jetbrains-lifecycle-runtime-compose` from the list of automatically provided `commonMain` dependencies.

Signed-off-by: James Rich <[email protected]>
…ation

This commit updates the build logic conventions to prefer lazy Gradle configuration and reorganizes historical optimization documents into an archive. It also removes unused test dependencies from the version catalog.

Specific changes include:
- **Build Logic Refactoring**: Updated `FlavorResolution.kt` to use `configurations.configureEach` instead of `afterEvaluate` for better configuration performance.
- **Documentation Reorganization**:
    - Moved historical optimization analysis and summary files to a new `docs/archive/` directory.
    - Simplified `docs/BUILD_LOGIC_INDEX.md` to serve as a concise entry point for current conventions.
    - Updated `BUILD_LOGIC_CONVENTIONS_GUIDE.md` with examples of lazy vs. eager task configuration.
- **Guidelines Update**: Added explicit instructions to `AGENTS.md`, `GEMINI.md`, and `.github/copilot-instructions.md` regarding the preference for lazy Gradle APIs (`configureEach`, `withPlugin`) over `afterEvaluate`.
- **Dependency Cleanup**: Removed the unused `truth` library dependency from `gradle/libs.versions.toml` and the `build-logic` configuration.

Signed-off-by: James Rich <[email protected]>
This commit significantly restructures the CI pipeline in `.github/workflows/reusable-check.yml` to separate host-based tasks (linting, unit tests, KMP smoke tests) from Android matrix-based tasks (instrumented tests and assembly). This optimization reduces redundant test execution and improves coverage reporting.

Specific changes include:

- **CI Workflow Refactoring**:
    - Split `reusable-check.yml` into `host-check` (runs once) and `android-check` (runs per API level).
    - Updated `merge-queue.yml` to explicitly enable lint, unit tests, and instrumented tests.
    - Switched from shorthand Gradle tasks (e.g., `lintDebug`) to explicit module paths (e.g., `app:lintFdroidDebug`) for better precision in CI.
    - Consolidated Codecov uploads for unit tests and instrumented tests into their respective jobs.
    - Updated `pull-request.yml` path filtering to ensure infrastructure and configuration changes (e.g., `.github/workflows/**`, `gradle/`, `settings.gradle.kts`) trigger CI.

- **Build Logic**:
    - Updated `FlavorResolution.kt` to use `ProductFlavorAttr` for marketplace attribute matching, improving compatibility with Android Gradle Plugin flavor resolution.
    - Added a legacy marketplace attribute fallback to maintain compatibility during transitions.

- **Documentation**:
    - Updated `AGENTS.md`, `.github/copilot-instructions.md`, `GEMINI.md`, and `testing-and-ci-playbook.md` to reflect the new CI architecture and task naming conventions.
    - Documented Robolectric/Java 17 compatibility constraints (pinning to SDK 34).

- **Dependency & Module Management**:
    - Expanded JVM smoke compilation to include newly added modules like `:core:testing` and `:feature:connections`.
    - Added explicit lint and Kover tasks for `core:barcode`, `core:api`, and `mesh_service_example`.

Signed-off-by: James Rich <[email protected]>
This commit refactors the CI pipeline to optimize caching strategies and introduces a safety check to ensure pull request path filtering remains synchronized with the project structure.

Specific changes include:
- **Cache Optimization**: Configured `gradle/actions/setup-gradle` to use read-only mode for non-trusted branches. Cache writes are now restricted to `main`, `merge_group`, and `gh-readonly-queue/*` refs.
- **Workflow Validation**: Added a `verify-check-changes-filter` job to `pull-request.yml`. This Python-based check ensures that all module roots defined in `settings.gradle.kts` are explicitly covered by the GitHub Actions path filters.
- **PR Targeting**: Updated `pull-request.yml` to target only the `main` branch, removing `develop`.
- **Dependency Graph**: Removed `dependency-graph: generate-and-submit` from the reusable check workflow in favor of optimized cache settings.
- **Documentation**: Updated `AGENTS.md`, `GEMINI.md`, `.github/copilot-instructions.md`, and the testing playbook to reflect the new caching policy and PR targeting rules.
- **Status Reporting**: Updated the `check-workflow-status` job to account for the new filter verification step.

Signed-off-by: James Rich <[email protected]>
…tplace attributes

This commit improves the build logic for marketplace flavor resolution to prevent configuration errors and removes redundant attribute definitions from the network module.

Specific changes include:
- **FlavorResolution.kt**: Added checks to `configurations.configureEach` to ensure logic only applies to resolvable (not consumable) configurations, preventing potential attribute conflicts.
- **core/network**: Removed the manual "marketplace" attribute configuration from `build.gradle.kts`, centralizing flavor handling within the established build-logic conventions.

Signed-off-by: James Rich <[email protected]>
…ore flavor resolution

This reverts the lazy configuration migration for marketplace fallback logic to use `afterEvaluate`. This is required because Android Gradle Plugin (AGP) does not immediately initialize the `isCanBeResolved` and `isCanBeConsumed` flags on newly created configurations. Checking them before they are populated breaks dependency resolution for downstream flavor consumers.
@jamesarich jamesarich marked this pull request as ready for review March 17, 2026 20:35
@jamesarich jamesarich added this pull request to the merge queue Mar 17, 2026
Merged via the queue into main with commit 7d63f8b Mar 17, 2026
7 checks passed
@jamesarich jamesarich deleted the feat/build-logic branch March 17, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant