Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#586] Migrate to build version catalog #591

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

ryan-conway
Copy link
Collaborator

@ryan-conway ryan-conway commented Nov 4, 2024

#586

What happened 👀

  • Created libs.versions.toml
  • Deleted Dependencies.kt and Plugins.kt
  • Migrated app, data, domain and project gradle files to use new version catalog file

TODO 🏃🏻

  • Update sample-compose after reviews on the template 🙇🏻

Insight 📝

  • We cannot delete Versions.kt as we cannot migrate all versions to the version catalog cleanly 🫠
  • COMPOSE_COMPILERversion will be removed in another PR 🙇🏻
  • We should handle version updates in a separate PR 👀

Proof Of Work 📹

App still builds and runs

Summary by CodeRabbit

  • Refactor

    • Migrated project to use centralized dependency management with TOML version catalog
    • Replaced manual dependency and plugin declarations with library aliases
    • Simplified build configuration across project modules
  • Chores

    • Updated Gradle build scripts to use more modern dependency management approach
    • Removed legacy version and dependency constant files

@ryan-conway ryan-conway added this to the 3.31.0 milestone Nov 4, 2024
@ryan-conway ryan-conway self-assigned this Nov 4, 2024
@ryan-conway ryan-conway changed the title [#586] Migrate to version catalog [#586] Migrate to build version catalog Nov 4, 2024
Copy link

github-actions bot commented Nov 4, 2024

1 Warning
⚠️ Uh oh! Your project is under 80% coverage!

Kover report for template-compose:

🧛 Template - Compose Unit Tests Code Coverage: 61.54%

Coverage of Modified Files:

File Coverage

Modified Files Not Found In Coverage Report:

Versions.kt
build.gradle.kts
build.gradle.kts
build.gradle.kts
build.gradle.kts
libs.versions.toml

Codebase cunningly covered by count Shroud 🧛

Generated by 🚫 Danger

Copy link

coderabbitai bot commented Jan 3, 2025

Walkthrough

The pull request introduces a comprehensive refactoring of dependency and plugin management in a Gradle-based Android project. The changes transition from using custom constant objects (Dependencies.kt, Plugins.kt, Versions.kt) to a more standardized approach using a centralized libs.versions.toml configuration file. This new approach leverages Gradle's version catalog feature, replacing hardcoded plugin and dependency references with alias-based declarations, which simplifies version management and improves build script readability across multiple modules.

Changes

File Change Summary
template-compose/app/build.gradle.kts Replaced plugin declarations and dependency management with libs aliases and bundles
template-compose/build.gradle.kts Updated plugin declarations to use libs aliases
template-compose/buildSrc/src/main/java/Dependencies.kt Completely removed
template-compose/buildSrc/src/main/java/Plugins.kt Completely removed
template-compose/buildSrc/src/main/java/Versions.kt Removed multiple version constants
template-compose/data/build.gradle.kts Migrated to libs aliases for plugins and dependencies
template-compose/domain/build.gradle.kts Updated plugin and dependency declarations using libs
template-compose/gradle/libs.versions.toml New file added to centralize version, library, bundle, and plugin management

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant Gradle as Gradle Build System
    participant LibsCatalog as libs.versions.toml
    participant BuildScript as build.gradle.kts

    Dev->>LibsCatalog: Define library versions
    Dev->>LibsCatalog: Define library references
    Dev->>LibsCatalog: Create library bundles
    Dev->>BuildScript: Use libs aliases
    Gradle->>LibsCatalog: Resolve versions
    Gradle->>BuildScript: Compile project
Loading

Poem

🐰 Hop, hop, dependencies dance!
From constants to aliases, a gradle prance
Version catalog sings its sweet song
Modules now lean, dependencies strong
Refactoring magic, with bundles so bright! 🌟


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc18919 and f31db82.

📒 Files selected for processing (8)
  • template-compose/app/build.gradle.kts (2 hunks)
  • template-compose/build.gradle.kts (1 hunks)
  • template-compose/buildSrc/src/main/java/Dependencies.kt (0 hunks)
  • template-compose/buildSrc/src/main/java/Plugins.kt (0 hunks)
  • template-compose/buildSrc/src/main/java/Versions.kt (0 hunks)
  • template-compose/data/build.gradle.kts (2 hunks)
  • template-compose/domain/build.gradle.kts (2 hunks)
  • template-compose/gradle/libs.versions.toml (1 hunks)
💤 Files with no reviewable changes (3)
  • template-compose/buildSrc/src/main/java/Dependencies.kt
  • template-compose/buildSrc/src/main/java/Plugins.kt
  • template-compose/buildSrc/src/main/java/Versions.kt
🔇 Additional comments (11)
template-compose/domain/build.gradle.kts (1)

2-4: Well-structured migration to version catalog!

The migration of both plugins and dependencies to the version catalog syntax is clean and follows Gradle best practices. The use of bundles for test dependencies is particularly good for maintainability.

Also applies to: 13-16

template-compose/build.gradle.kts (2)

19-19: Proper migration of detekt version!

The detekt tool version is correctly retrieved from the version catalog.


3-11: Clean migration of plugins to version catalog!

The plugin declarations have been properly migrated using the alias syntax, with appropriate use of apply false for plugins that shouldn't be applied to the root project.

Let's verify all plugin versions are properly defined in the version catalog:

✅ Verification successful

All plugin versions are properly defined in version catalog ✅

All plugins used in the root build.gradle.kts are correctly defined in the version catalog (template-compose/gradle/libs.versions.toml):

  • android-application: version from gradle (8.1.2)
  • android-library: version from gradle (8.1.2)
  • kotlin-jvm: version from kotlin (1.9.10)
  • kotlin-android: version from kotlin (1.9.10)
  • kotlin-kapt: version from kotlin (1.9.10)
  • kotlin-parcelize: version from kotlin (1.9.10)
  • hilt: version from hilt (2.48)
  • detekt: version from detekt (1.21.0)
  • kover: version from kover (0.7.3)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all plugins are defined in version catalog
# Expected: All plugin aliases should be defined in libs.versions.toml

# Check if libs.versions.toml exists and contains all plugin definitions
rg --type toml "plugins\." gradle/libs.versions.toml

Length of output: 120


Script:

#!/bin/bash
# Let's first locate the version catalog file
fd "libs.versions.toml"

# If not found with exact name, let's try to find any .toml files that might contain version definitions
fd ".+\.toml$"

Length of output: 126


Script:

#!/bin/bash
# Now that we found the correct path, let's check the plugin definitions
cat template-compose/gradle/libs.versions.toml

Length of output: 5669

template-compose/data/build.gradle.kts (2)

2-4: Clean migration of plugins to version catalog!

The plugin declarations have been properly migrated using the alias syntax.


49-63: Well-organized dependency management using version catalog!

The dependencies have been cleanly migrated to use the version catalog with effective use of bundles for related dependencies (retrofit, okhttp, testing).

Note: Some Android-specific versions (like ANDROID_COMPILE_SDK) are still using the Versions object. This is expected as mentioned in the PR objectives that Versions.kt cannot be fully migrated yet.

template-compose/app/build.gradle.kts (2)

4-9: LGTM! Clean migration of plugin declarations

The plugins have been properly migrated to use the version catalog syntax.


136-154: Well-structured dependency declarations using version catalog

Good use of bundles and individual declarations for better organization of dependencies.

template-compose/gradle/libs.versions.toml (4)

2-28: Update dependency versions to latest stable releases

Several dependencies are using outdated versions:

  • composeBom: 2023.09.02 -> 2024.10.01
  • composeNavigation: 2.5.3 -> 2.8.3
  • core: 1.10.1 -> 1.15.0
  • datastore: 1.0.0 -> 1.1.1
  • hiltNavigation: 1.0.0 -> 1.2.0
  • lifecycle: 2.6.1 -> 2.8.7

30-83: Well-organized library declarations with clear categorization

Good job organizing libraries into clear categories (AndroidX, Compose, Hilt, etc.) with proper version references.


84-132: Excellent bundle organization for related dependencies

The bundles are well-structured and logically grouped, making dependency management cleaner and more maintainable.


133-143: Complete and well-structured plugin declarations

All necessary plugins are properly declared with their version references.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ryan-conway ryan-conway deployed to template-compose January 3, 2025 03:41 — with GitHub Actions Active
Copy link

@thawzintoe-ptut thawzintoe-ptut left a comment

Choose a reason for hiding this comment

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

LGTM

lifecycle = "2.6.1"
security = "1.0.0"
junit = "4.13.2"
kotest = "5.6.2"
Copy link

@thawzintoe-ptut thawzintoe-ptut Jan 3, 2025

Choose a reason for hiding this comment

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

Small suggestion(Nit): It would be clearer if we sorted these items alphabetically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants