Skip to content

Add AndroidLibraryPlugin#82

Merged
HeyPouya merged 2 commits intomasterfrom
chore/gradle-plugins
Dec 16, 2025
Merged

Add AndroidLibraryPlugin#82
HeyPouya merged 2 commits intomasterfrom
chore/gradle-plugins

Conversation

@HeyPouya
Copy link
Owner

@HeyPouya HeyPouya commented Dec 14, 2025

This PR adds AndroidLibraryPlugin as a convention plugin to centralize all necessary codes for gradle files of library modules.

Summary by CodeRabbit

  • Chores
    • Switched project to a Kotlin JVM toolchain targeting Java 17.
    • Added a centralized build-convention plugin to standardize Android library setup.
    • Updated platform/tooling versions (AGP, Kotlin, AndroidX, Compose, testing libs).
    • Simplified module build configs by removing redundant per-module settings.
    • Included build-logic as a composite build and ignored /build directories.

✏️ Tip: You can customize this high-level summary in your review settings.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a convention plugin (AndroidLibraryPlugin) to centralize common Android library module build configurations, eliminating duplicated code across library modules. The plugin is implemented in a separate build-logic module and consolidates settings like compileSdk, minSdk, compile options, and Kotlin configuration that were previously repeated in each library module's build.gradle.kts file. The PR also includes dependency version updates across the version catalog.

Key changes:

  • Created AndroidLibraryPlugin convention plugin to centralize Android library configurations
  • Added build-logic module with convention plugin infrastructure
  • Updated all library modules (store, directdownload, compose, appupdater) to use the new convention plugin
  • Updated multiple dependency versions in the version catalog (AGP, Kotlin, AndroidX libraries, Compose, testing libraries)

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
build-logic/convention/src/main/java/com/pouyaheydari/appupdater/convention/plugins/AndroidLibraryPlugin.kt Implements the convention plugin that centralizes Android library configurations including SDK versions, compile options, and Kotlin toolchain setup
build-logic/convention/src/main/java/com/pouyaheydari/appupdater/convention/helpers/ProjectHelper.kt Provides helper functions to extract configuration values (compileSdk, minSdk, javaVersion) from the version catalog
build-logic/convention/build.gradle.kts Configures the convention plugin module with necessary dependencies and plugin registration
build-logic/settings.gradle.kts Sets up dependency resolution and version catalog access for the build-logic module
build-logic/convention/.gitignore Excludes the build directory from version control
settings.gradle.kts Includes the build-logic module in the composite build
gradle/libs.versions.toml Adds new library dependencies for Gradle plugins and declares the custom androidLibrary convention plugin, also updates multiple dependency versions
store/build.gradle.kts Replaces plugin declarations and Android configuration with the new convention plugin
directdownload/build.gradle.kts Replaces plugin declarations and Android configuration with the new convention plugin, fixes formatting in test dependencies
compose/build.gradle.kts Replaces plugin declarations and Android configuration with the new convention plugin
appupdater/build.gradle.kts Replaces plugin declarations and Android configuration with the new convention plugin, fixes formatting in test dependencies
app/build.gradle.kts Updates Kotlin configuration from kotlinOptions to kotlin.jvmToolchain pattern

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coderabbitai
Copy link

coderabbitai bot commented Dec 14, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

A new build-convention Gradle composite is added (build-logic) that provides an Android library plugin and helpers sourcing values from the version catalog. Module build files switch to using the convention plugin (project.androidLibrary) and remove explicit SDK/toolchain settings; libs versions and plugin entries are updated.

Changes

Cohort / File(s) Change Summary
Build convention root & composite
settings.gradle.kts, build-logic/settings.gradle.kts
Added includeBuild("build-logic"); new build-logic settings with repositories and a libs version catalog sourced from ../gradle/libs.versions.toml; rootProject and include(":convention") set.
Build-convention module files
build-logic/convention/build.gradle.kts, build-logic/convention/.gitignore
New Gradle Kotlin DSL project declaring a plugin (id com.pouyaheydari.androidLibraryPlugin), targeting Java 17; .gitignore added to ignore /build.
Convention plugin implementation
build-logic/convention/src/main/java/.../plugins/AndroidLibraryPlugin.kt
New AndroidLibraryPlugin (implements Plugin<Project>) that applies base plugins, configures LibraryExtension (compileSdk, defaultConfig.minSdk/testInstrumentationRunner, compileOptions) and sets the Kotlin JVM toolchain to language version 17.
Convention helpers
build-logic/convention/src/main/java/.../helpers/JavaVersionHelper.kt, build-logic/convention/src/main/java/.../helpers/ProjectHelper.kt
New helpers: javaVersion() returns JavaVersion.VERSION_17; Project.compileSdk() and Project.minSdk() read ints from the libs version catalog; Project.baseLibs extension added.
Module build files switching to convention
app/build.gradle.kts, appupdater/build.gradle.kts, compose/build.gradle.kts, directdownload/build.gradle.kts, store/build.gradle.kts
Replaced multiple plugin aliases with alias(libs.plugins.project.androidLibrary) (project.androidLibrary); removed explicit android DSL settings (compileSdk, defaultConfig minSdk/testInstrumentationRunner, compileOptions, kotlinOptions). In app, replaced kotlinOptions.jvmTarget = "17" with kotlin { jvmToolchain(17) }.
Root build changes
build.gradle.kts
Removed alias(libs.plugins.androidLibrary) apply false from the root plugins block.
Version catalog updates
gradle/libs.versions.toml
Bumped many versions (AGP, Kotlin, AndroidX, Compose BOM, testing libs, mavenPublish); added android-gradlePlugin and kotlin-gradlePlugin libraries and added a plugin entry project-androidLibrary (id com.pouyaheydari.androidLibraryPlugin).
Minor dependency formatting
appupdater/build.gradle.kts, directdownload/build.gradle.kts
Minor formatting adjustments to test dependency callsites (no semantic change).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Review plugin implementation (AndroidLibraryPlugin.kt) for correct extension access and Kotlin toolchain setup.
  • Validate ProjectHelper.kt usages of the version catalog and ensure catalog keys exist.
  • Confirm module build files correctly reference the new plugin alias and that removed settings are provided by the convention.
  • Check gradle/libs.versions.toml version bumps for compatibility.

Poem

🐇 I braided builds into one tidy song,
A tiny plugin to keep configs strong.
From modules scattered, I hop to restore,
Toolchains set, versions bumped — I adore!
✨🐰

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add AndroidLibraryPlugin' accurately reflects the main objective described in the PR, which is to add AndroidLibraryPlugin as a convention plugin to centralize gradle configuration for library modules.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/gradle-plugins

Comment @coderabbitai help to get the list of available commands and usage tips.

@HeyPouya
Copy link
Owner Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Dec 14, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
store/build.gradle.kts (1)

8-11: Remove the java block.

The java block has no effect because the Java Gradle plugin is not applied to this module—only androidLibrary is. The AndroidLibraryPlugin already configures sourceCompatibility and targetCompatibility via compileOptions in the Android extension and sets up the Kotlin JVM toolchain. This java block is redundant and should be deleted.

♻️ Duplicate comments (1)
gradle/libs.versions.toml (1)

23-23: Typo: "roboelectric" should be "robolectric".

The version key and library name reference contain a typo. The correct spelling is "robolectric" (with an 'l').

-roboelectric = "4.16"
+robolectric = "4.16"

Also update line 45:

-roboelectric = { group = "org.robolectric", name = "robolectric", version.ref = "roboelectric" }
+robolectric = { group = "org.robolectric", name = "robolectric", version.ref = "robolectric" }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8c2698f and a119cf0.

📒 Files selected for processing (13)
  • app/build.gradle.kts (1 hunks)
  • appupdater/build.gradle.kts (2 hunks)
  • build-logic/convention/.gitignore (1 hunks)
  • build-logic/convention/build.gradle.kts (1 hunks)
  • build-logic/convention/src/main/java/com/pouyaheydari/appupdater/convention/helpers/JavaVersionHelper.kt (1 hunks)
  • build-logic/convention/src/main/java/com/pouyaheydari/appupdater/convention/helpers/ProjectHelper.kt (1 hunks)
  • build-logic/convention/src/main/java/com/pouyaheydari/appupdater/convention/plugins/AndroidLibraryPlugin.kt (1 hunks)
  • build-logic/settings.gradle.kts (1 hunks)
  • compose/build.gradle.kts (1 hunks)
  • directdownload/build.gradle.kts (2 hunks)
  • gradle/libs.versions.toml (3 hunks)
  • settings.gradle.kts (1 hunks)
  • store/build.gradle.kts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
build-logic/convention/src/main/java/com/pouyaheydari/appupdater/convention/plugins/AndroidLibraryPlugin.kt (2)
build-logic/convention/src/main/java/com/pouyaheydari/appupdater/convention/helpers/ProjectHelper.kt (2)
  • compileSdk (8-8)
  • minSdk (10-10)
build-logic/convention/src/main/java/com/pouyaheydari/appupdater/convention/helpers/JavaVersionHelper.kt (1)
  • javaVersion (5-5)
🔇 Additional comments (18)
build-logic/convention/.gitignore (1)

1-1: Remove this .gitignore file as it is redundant.

The root .gitignore already covers the /build pattern (present as both /build and build/), making this module-level file unnecessary. Since there is only one .gitignore file in the repository (this one) and the root already handles Gradle build output globally, this file should be deleted.

Likely an incorrect or invalid review comment.

build-logic/convention/src/main/java/com/pouyaheydari/appupdater/convention/helpers/JavaVersionHelper.kt (1)

1-5: LGTM!

The helper function provides a centralized Java version constant for convention plugins, aligning with the Java 17 toolchain strategy implemented across the project.

settings.gradle.kts (1)

2-3: LGTM!

The composite build inclusion is correctly placed within the pluginManagement block, enabling the convention plugins to be resolved and applied across the project.

app/build.gradle.kts (1)

27-29: LGTM!

The migration from explicit jvmTarget to the Kotlin JVM toolchain is the correct modern approach, ensuring consistent Java 17 runtime across compilation and execution.

store/build.gradle.kts (1)

1-3: LGTM!

The migration to the centralized project.androidLibrary plugin correctly consolidates the previously explicit plugin declarations.

directdownload/build.gradle.kts (1)

1-7: LGTM!

Clean migration to the project.androidLibrary convention plugin with appropriate removal of explicit Android configuration.

compose/build.gradle.kts (1)

1-24: LGTM!

The migration correctly uses the convention plugin while appropriately retaining Compose-specific configurations (build features, vector drawables, test options, and packaging rules).

build-logic/convention/build.gradle.kts (3)

1-5: LGTM!

Standard Gradle convention plugin setup with appropriate kotlin-dsl plugin and namespaced group coordinates.


7-15: LGTM! Java 17 compatibility and compileOnly dependencies on Android/Kotlin Gradle plugins are correctly configured for convention plugin development. Both android-gradlePlugin and kotlin-gradlePlugin are properly defined in the version catalog with AGP 8.13.2 and Kotlin 2.2.21.


17-24: The plugin registration and implementation are correct. The AndroidLibraryPlugin class exists and properly applies the required base plugins (Android library, Kotlin Android, and Maven Publish), along with appropriate SDK and toolchain configuration. The version catalog correctly maps project-androidLibrary to com.pouyaheydari.androidLibraryPlugin.

build-logic/settings.gradle.kts (2)

1-13: LGTM!

The dependency resolution configuration correctly establishes repositories and creates a version catalog sourcing from the parent project's libs.versions.toml, enabling shared dependency versions across build logic and application modules.


15-16: LGTM!

Project name and convention module inclusion are correctly configured.

build-logic/convention/src/main/java/com/pouyaheydari/appupdater/convention/plugins/AndroidLibraryPlugin.kt (2)

14-21: LGTM on plugin application pattern.

The plugin correctly applies base plugins via the version catalog, ensuring consistent versioning across modules. The use of baseLibs.findPlugin() pattern is a good approach for centralized plugin management.


23-33: LGTM on LibraryExtension configuration.

The Android library configuration correctly uses helper functions for compileSdk() and minSdk(), and the compile options use the centralized javaVersion() helper. This ensures consistency across library modules.

build-logic/convention/src/main/java/com/pouyaheydari/appupdater/convention/helpers/ProjectHelper.kt (1)

12-13: LGTM on baseLibs extension property.

The extension property correctly retrieves the version catalog using the Gradle DSL and provides a clean API for accessing catalog entries throughout the convention plugins.

appupdater/build.gradle.kts (1)

3-5: LGTM on convention plugin adoption.

The migration to libs.plugins.project.androidLibrary correctly centralizes the Android library configuration. The simplified android block retains only module-specific settings (buildFeatures, namespace), which is the intended pattern for convention plugins.

gradle/libs.versions.toml (2)

7-7: **Verify Kotlin version 2.2.21 exists.**Kotlin 2.2.21 is a valid release, released on October 23rd. The version is confirmed.


57-58: LGTM on new plugin infrastructure entries.

The android-gradlePlugin and kotlin-gradlePlugin library entries are correctly defined for use in the build-logic composite build. The project-androidLibrary plugin entry correctly omits a version since it's a local convention plugin resolved via the included build.

Also applies to: 67-67

…d library configurations

* Added build-logic module with convention plugin infrastructure
* Updated all library modules (store, directdownload, compose, appupdater) to use the new convention plugin
@HeyPouya HeyPouya force-pushed the chore/gradle-plugins branch from a119cf0 to 5a45c1b Compare December 14, 2025 19:46
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

♻️ Duplicate comments (3)
build-logic/convention/src/main/java/com/pouyaheydari/appupdater/convention/helpers/ProjectHelper.kt (1)

8-10: Add defensive error handling for missing version catalog entries.

The .get() calls on findVersion() will throw NoSuchElementException if the version keys are missing from the catalog, producing cryptic build configuration errors.

Consider using orElseThrow with a descriptive message:

+import org.gradle.api.GradleException
+
-fun Project.compileSdk(): Int = baseLibs.findVersion("compileSdkVersion").get().requiredVersion.toInt()
+fun Project.compileSdk(): Int = baseLibs.findVersion("compileSdkVersion")
+    .orElseThrow { GradleException("Missing 'compileSdkVersion' in version catalog") }
+    .requiredVersion.toInt()

-fun Project.minSdk(): Int = baseLibs.findVersion("minSdkVersion").get().requiredVersion.toInt()
+fun Project.minSdk(): Int = baseLibs.findVersion("minSdkVersion")
+    .orElseThrow { GradleException("Missing 'minSdkVersion' in version catalog") }
+    .requiredVersion.toInt()
build-logic/convention/src/main/java/com/pouyaheydari/appupdater/convention/plugins/AndroidLibraryPlugin.kt (1)

34-38: Replace hardcoded Java version with centralized helper.

Line 36 hardcodes 17 while lines 30-31 use the javaVersion() helper, creating maintenance inconsistency.

Consider extracting the numeric version to maintain consistency:

+private const val JAVA_VERSION = 17
+
 extensions.configure<KotlinAndroidProjectExtension> {
     jvmToolchain {
-        languageVersion.set(JavaLanguageVersion.of(17))
+        languageVersion.set(JavaLanguageVersion.of(JAVA_VERSION))
     }
 }

Alternatively, update JavaVersionHelper.kt to expose the numeric version and reference it here.

gradle/libs.versions.toml (1)

23-23: Fix the typo in the version key.

The key is spelled "roboelectric" but should be "robolectric" to match the correct library name.

Apply this diff:

-roboelectric = "4.16"
+robolectric = "4.16"

Also update the library reference on line 45:

-roboelectric = { group = "org.robolectric", name = "robolectric", version.ref = "roboelectric" }
+robolectric = { group = "org.robolectric", name = "robolectric", version.ref = "robolectric" }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a119cf0 and 5a45c1b.

📒 Files selected for processing (13)
  • appupdater/build.gradle.kts (2 hunks)
  • build-logic/convention/.gitignore (1 hunks)
  • build-logic/convention/build.gradle.kts (1 hunks)
  • build-logic/convention/src/main/java/com/pouyaheydari/appupdater/convention/helpers/JavaVersionHelper.kt (1 hunks)
  • build-logic/convention/src/main/java/com/pouyaheydari/appupdater/convention/helpers/ProjectHelper.kt (1 hunks)
  • build-logic/convention/src/main/java/com/pouyaheydari/appupdater/convention/plugins/AndroidLibraryPlugin.kt (1 hunks)
  • build-logic/settings.gradle.kts (1 hunks)
  • build.gradle.kts (0 hunks)
  • compose/build.gradle.kts (1 hunks)
  • directdownload/build.gradle.kts (2 hunks)
  • gradle/libs.versions.toml (3 hunks)
  • settings.gradle.kts (1 hunks)
  • store/build.gradle.kts (1 hunks)
💤 Files with no reviewable changes (1)
  • build.gradle.kts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (11)
build-logic/convention/.gitignore (1)

1-1: LGTM!

Standard gitignore pattern for Gradle build artifacts.

settings.gradle.kts (1)

2-3: LGTM!

The composite build inclusion is correctly placed and enables the new convention plugin infrastructure.

build-logic/convention/src/main/java/com/pouyaheydari/appupdater/convention/helpers/JavaVersionHelper.kt (1)

1-5: LGTM!

The standalone helper function is appropriate since it returns a project-agnostic constant.

build-logic/settings.gradle.kts (1)

1-16: LGTM!

The composite build settings are correctly configured with proper repository management and version catalog references.

gradle/libs.versions.toml (2)

6-7: LGTM!

Version updates are reasonable and align with the convention plugin infrastructure.

Also applies to: 9-10, 16-20, 21-23, 26-26


57-58: LGTM!

New gradle plugin library entries and project-androidLibrary plugin alias correctly support the convention plugin infrastructure.

Also applies to: 67-67

directdownload/build.gradle.kts (1)

1-7: LGTM!

The migration to the convention plugin is correct. Android DSL configuration is now centralized in the AndroidLibraryPlugin, reducing boilerplate.

store/build.gradle.kts (1)

1-8: Verify convention plugin provides all removed Android configuration.

The store module has been successfully simplified to rely entirely on the convention plugin for SDK versions, compiler options, and Kotlin toolchain configuration. Ensure AndroidLibraryPlugin is correctly configured with appropriate defaults for all library modules.

The configuration is clean and minimal post-migration. Pending verification of the convention plugin implementation.

appupdater/build.gradle.kts (1)

3-5: Verify convention plugin applies jetbrainsKotlinAndroid plugin.

The explicit alias(libs.plugins.jetbrainsKotlinAndroid) alias has been removed, assuming the convention plugin now applies it. Confirm AndroidLibraryPlugin.kt includes this plugin in its apply() chain.

compose/build.gradle.kts (2)

1-4: The plugin alias is correctly registered in gradle/libs.versions.toml and maps to the convention plugin ID "com.pouyaheydari.androidLibraryPlugin". No action needed.


1-24: AndroidLibraryPlugin correctly applies jetbrainsKotlinAndroid plugin.

Confirmed that AndroidLibraryPlugin.kt applies the jetbrainsKotlinAndroid alias (line 19) along with androidLibrary and maven.publish. All centralized Android SDK configuration (compileSdk, minSdk, compileOptions, jvmToolchain) is properly configured in the convention plugin, supporting the removal from this file.

@HeyPouya HeyPouya merged commit 42eb560 into master Dec 16, 2025
2 checks passed
@HeyPouya HeyPouya deleted the chore/gradle-plugins branch December 16, 2025 10:43
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