Skip to content

refactor: Migrate to Android Gradle Plugin 9.0#4072

Merged
jamesarich merged 10 commits into
mainfrom
chore/update_agp9
Dec 28, 2025
Merged

refactor: Migrate to Android Gradle Plugin 9.0#4072
jamesarich merged 10 commits into
mainfrom
chore/update_agp9

Conversation

@jamesarich

Copy link
Copy Markdown
Collaborator

This commit migrates the project to use the new Android Gradle Plugin (AGP) 9.0 API.

Key changes include:

  • Updating from android { ... } block to the configure<LibraryExtension> { ... } syntax in module-level build.gradle.kts files.
  • Refactoring convention plugins to use the new CommonExtension and type casting for ApplicationExtension and LibraryExtension specific configurations.
  • Removing the now-redundant com.android.library and org.jetbrains.kotlin.android plugin applications from convention plugins.
  • Updating the Android Gradle Plugin version to 9.0.0-rc01.
  • Adding a dependency on androidx.lifecycle.runtime.

@codecov

codecov Bot commented Dec 27, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (250caa7) to head (470afd2).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##            main   #4072      +/-   ##
========================================
- Coverage   0.59%   0.00%   -0.60%     
========================================
  Files        407       2     -405     
  Lines      24793      19   -24774     
  Branches    3189       7    -3182     
========================================
- Hits         148       0     -148     
+ Misses     24622      19   -24603     
+ Partials      23       0      -23     

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

@jamesarich jamesarich force-pushed the chore/update_agp9 branch 2 times, most recently from 5300235 to f931218 Compare December 27, 2025 11:26
@jamesarich jamesarich marked this pull request as ready for review December 27, 2025 12:15
This commit migrates the project to use the new Android Gradle Plugin (AGP) 9.0 API.

Key changes include:
*   Updating from `android { ... }` block to the `configure<LibraryExtension> { ... }` syntax in module-level `build.gradle.kts` files.
*   Refactoring convention plugins to use the new `CommonExtension` and type casting for `ApplicationExtension` and `LibraryExtension` specific configurations.
*   Removing the now-redundant `com.android.library` and `org.jetbrains.kotlin.android` plugin applications from convention plugins.
*   Updating the Android Gradle Plugin version to `9.0.0-rc01`.
*   Adding a dependency on `androidx.lifecycle.runtime`.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
Adds the `androidx.core.ktx` library as a dependency to the `core/data` module.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
Removes redundant `extension.apply` blocks and simplifies the `compileOptions` configuration in the `KotlinAndroid` convention plugin.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
Refactor the convention plugins to use type-safe accessors for the `libs` version catalog.

- Add a dependency on the version catalog itself to `build-logic/convention/build.gradle.kts`, enabling type-safe accessors in the plugins' source code.
- Introduce extension functions (`library`, `plugin`, etc.) for `VersionCatalog` to simplify dependency declarations.
- Update `AndroidRoomConventionPlugin`, `AnalyticsConventionPlugin`, and `KotlinXSerializationConventionPlugin` to use these new type-safe accessors instead of `findLibrary()` and string-based plugin IDs.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
Replaces `findLibrary`, `findPlugin`, and `findVersion` calls with the type-safe accessors `library`, `plugin`, and `version` across the build logic convention plugins.

This change also:
*   Sets `targetSdk` from project properties for application modules.
*   Adds `hilt-core` to the version catalog for JVM modules.
*   Removes redundant plugin applications and hardcoded values, relying on the new type-safe accessors and properties.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
Refactors the Detekt and Spotless convention plugins for better Gradle compatibility and conciseness.

- Updates Detekt to use the project-specific `buildDirectory` for reports, preventing conflicts in multi-project builds.
- Simplifies `DetektConventionPlugin` and `SpotlessConventionPlugin` by using `pluginManager.apply` and the `extensions.configure` block, removing redundant `configureKotlinJvm` calls.
- Cleans up Spotless configuration by removing the explicit receiver `extension` and extracting the `ktlintVersion`.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit refactors the Gradle build logic for Kotlin Multiplatform (KMP) modules.

Key changes:
*   A new `configureKotlinMultiplatform` extension function has been created to centralize KMP configuration, including setting the Android `compileSdk` and `minSdk`.
*   The `KmpLibraryConventionPlugin` is simplified to use this new centralized function.
*   Detekt source sets are updated to include KMP source directories (`commonMain`, `androidMain`, `jvmMain`).
*   The `KotlinXSerializationConventionPlugin` is improved to correctly apply the serialization dependency to the appropriate source sets for KMP, Android, and JVM projects.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit introduces a new convention plugin `meshtastic.kmp.library.compose` to streamline the setup for Kotlin Multiplatform modules that use Jetpack Compose.

Key changes include:
*   **New KMP Compose Plugin**: Created `KmpLibraryComposeConventionPlugin.kt` to handle Compose Multiplatform and compiler plugin application, along with common Compose dependencies for KMP modules. This simplifies the build configuration for modules like `core/strings`.
*   **Build Logic Refactoring**:
    *   Hardcoded plugin IDs in `build-logic/convention/build.gradle.kts` have been replaced with direct strings to improve maintainability.
    *   Updated the dependency resolution for the `libs` accessor.
    *   `AndroidRoomConventionPlugin` is now compatible with Kotlin Multiplatform, applying dependencies to the correct source sets (e.g., `commonMain`, `androidMain`).
*   **Linting for KMP**: The `AndroidLintConventionPlugin` is now correctly applied to Kotlin Multiplatform library targets.
*   **Dependency Updates**: Added and organized dependencies for Compose Multiplatform in `gradle/libs.versions.toml`.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
Adds kotlinx.serialization.core to the navigation module and the Room compiler (ksp) to the database module.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
@jamesarich jamesarich added this pull request to the merge queue Dec 28, 2025
Merged via the queue into main with commit 9fd9269 Dec 28, 2025
5 of 6 checks passed
@jamesarich jamesarich deleted the chore/update_agp9 branch December 28, 2025 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant