Skip to content

feat(android): add auto_increment_version_code option for Android builds - #9

Open
tomerqodo wants to merge 7 commits into
coderabbit_only-issues-20260113-coderabbit_base_featandroid_add_auto_increment_version_code_option_for_android_builds__pr32from
coderabbit_only-issues-20260113-coderabbit_head_featandroid_add_auto_increment_version_code_option_for_android_builds__pr32
Open

feat(android): add auto_increment_version_code option for Android builds #9
tomerqodo wants to merge 7 commits into
coderabbit_only-issues-20260113-coderabbit_base_featandroid_add_auto_increment_version_code_option_for_android_builds__pr32from
coderabbit_only-issues-20260113-coderabbit_head_featandroid_add_auto_increment_version_code_option_for_android_builds__pr32

Conversation

@tomerqodo

@tomerqodo tomerqodo commented Jan 17, 2026

Copy link
Copy Markdown

Benchmark PR from qodo-benchmark#32

Summary by CodeRabbit

  • New Features

    • Added support for automatic Android version code incrementation during builds, configurable through a new option in your Android bundle configuration.
  • Documentation

    • Updated configuration schema documentation to reflect the new Android versioning capability.

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

@coderabbitai

coderabbitai Bot commented Jan 17, 2026

Copy link
Copy Markdown

Walkthrough

This PR introduces an Android-specific feature enabling automatic incrementation of the Android version code during builds. The implementation adds a new autoIncrementVersionCode configuration option, refactors the Gradle generation to simplify config handling, and implements a new generate_tauri_properties function to manage Android version properties.

Changes

Cohort / File(s) Summary
Configuration Schema Updates
crates/tauri-cli/config.schema.json, crates/tauri-schema-generator/schemas/config.schema.json
Added new boolean property autoIncrementVersionCode to Android bundle configuration with default value false and descriptive documentation for both schema files.
Configuration Struct
crates/tauri-utils/src/config.rs
Added auto_increment_version_code: bool field to AndroidConfig struct with serde alias and default implementation set to false.
Android Version Properties Implementation
crates/tauri-cli/src/mobile/android/mod.rs
Introduced new private function generate_tauri_properties() that computes and writes Android version name and code to app/tauri.properties, supporting auto-increment logic, explicit code override, and semantic version parsing with validation.
Build and Dev Integration
crates/tauri-cli/src/mobile/android/build.rs, crates/tauri-cli/src/mobile/android/dev.rs
Added imports and calls to generate_tauri_properties() in both build and dev flows to ensure properties are generated during Android initialization.
Build System Refactoring
crates/tauri-build/src/lib.rs, crates/tauri-build/src/mobile.rs
Removed config parameter from generate_gradle_files() function signature and eliminated config-dependent version handling logic, simplifying Gradle file generation to focus on build and settings files only.
Changelog
.changes/auto-increment-android-version-code.md
Added changelog entry documenting the new Android version code auto-increment feature and config plumbing updates.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A hop through configs, a bounce through the code,
Android versions now auto-increment on the road,
No manual tweaks when you build with a care,
The version code grows—magic in the air!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 accurately describes the main change: adding an auto_increment_version_code option for Android builds, which is the primary feature across all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 55453e8 and 5a26145.

📒 Files selected for processing (9)
  • .changes/auto-increment-android-version-code.md
  • crates/tauri-build/src/lib.rs
  • crates/tauri-build/src/mobile.rs
  • crates/tauri-cli/config.schema.json
  • crates/tauri-cli/src/mobile/android/build.rs
  • crates/tauri-cli/src/mobile/android/dev.rs
  • crates/tauri-cli/src/mobile/android/mod.rs
  • crates/tauri-schema-generator/schemas/config.schema.json
  • crates/tauri-utils/src/config.rs
🧰 Additional context used
🧬 Code graph analysis (5)
crates/tauri-utils/src/config.rs (3)
crates/tauri-runtime/src/lib.rs (1)
  • default (105-107)
crates/tauri/src/app.rs (2)
  • default (1447-1449)
  • default (1455-1457)
crates/tauri-utils/src/config_v1/mod.rs (9)
  • default (61-63)
  • default (255-257)
  • default (387-397)
  • default (430-432)
  • default (579-581)
  • default (630-632)
  • default (681-693)
  • default (1061-1097)
  • default (1129-1131)
crates/tauri-cli/src/mobile/android/build.rs (2)
crates/tauri-cli/src/mobile/android/mod.rs (1)
  • generate_tauri_properties (625-686)
crates/tauri-cli/src/mobile/mod.rs (1)
  • write_options (367-403)
crates/tauri-build/src/mobile.rs (1)
crates/tauri-utils/src/lib.rs (1)
  • write_if_changed (391-403)
crates/tauri-build/src/lib.rs (1)
crates/tauri-build/src/mobile.rs (1)
  • generate_gradle_files (10-63)
crates/tauri-cli/src/mobile/android/dev.rs (1)
crates/tauri-cli/src/mobile/android/mod.rs (1)
  • generate_tauri_properties (625-686)
🔇 Additional comments (17)
.changes/auto-increment-android-version-code.md (1)

1-8: LGTM!

The changelog entry is well-structured, correctly identifies all affected packages with appropriate semver bump types, and provides a clear description of the new configuration option.

crates/tauri-build/src/lib.rs (1)

501-503: LGTM!

The call site correctly reflects the simplified generate_gradle_files signature. The responsibility for generating tauri.properties (including version code logic) has been moved to the CLI layer, which is a sensible separation of concerns.

crates/tauri-cli/src/mobile/android/dev.rs (2)

18-21: LGTM!

The import is correctly placed alongside related mobile utilities.


274-275: LGTM!

The generate_tauri_properties call is correctly placed after configure_cargo and passes dev: true, which appropriately relaxes version validation for development builds (clamping versionCode instead of failing on edge cases).

crates/tauri-cli/src/mobile/android/build.rs (2)

18-18: LGTM!

The import correctly brings in generate_tauri_properties for use in the build flow.


183-188: LGTM!

The generate_tauri_properties call is correctly placed after build::setup and passes dev: false, ensuring strict version validation for production builds. The single invocation in the command function (not in run_build) ensures the version code is only incremented once per build invocation.

crates/tauri-utils/src/config.rs (2)

2932-2941: LGTM!

The new auto_increment_version_code field is well-designed:

  • Follows existing serde conventions with kebab-case alias
  • Safe default of false preserves backward compatibility
  • Documentation clearly explains the feature behavior and the requirement to track tauri.properties in version control

2944-2951: LGTM!

The Default implementation correctly initializes auto_increment_version_code to false, consistent with the field's #[serde(default)] annotation.

crates/tauri-cli/config.schema.json (1)

87-88: LGTM!

The schema changes are well-structured and consistent. The new autoIncrementVersionCode property is properly added in both default sections and the AndroidConfig definition with appropriate description, type, and default value.

Also applies to: 2286-2287, 3831-3836

crates/tauri-cli/src/mobile/android/mod.rs (3)

649-668: LGTM - Well-designed version code derivation and validation.

The semver-to-versionCode logic follows Google Play's common convention. The dev-mode clamping provides good UX during development by silently fixing edge cases, while production builds get clear error messages guiding users to fix their configuration.


671-683: Good optimization to write only when content changes.

The comparison before write prevents unnecessary file modifications, which helps with build caching and avoids spurious git diffs.


635-646: Auto-increment does not check the dev flag, unlike the semver-derived path.

The dev parameter is unused in the auto_increment branch (lines 635-646), while it is applied in the semver-derived path (lines 652-654) for clamping. If auto-increment should be skipped during development to preserve version code values, the condition should be if !dev && tauri_config.bundle.android.auto_increment_version_code.

Clarify whether auto-increment should be gated by dev mode. If intentional, the asymmetry with the semver path should be documented.

crates/tauri-schema-generator/schemas/config.schema.json (3)

87-88: LGTM!

The autoIncrementVersionCode default is correctly set to false in the bundle.android defaults section, consistent with the field definition.


2286-2287: LGTM!

The android default configuration correctly includes autoIncrementVersionCode: false, matching the bundle defaults and maintaining schema consistency.


3831-3836: LGTM!

The autoIncrementVersionCode property definition is well-structured with:

  • Clear description explaining the behavior and fallback logic
  • Helpful note about .gitignore for repository integration
  • Correct type (boolean) and default (false)
crates/tauri-build/src/mobile.rs (2)

5-10: LGTM!

The refactored imports and simplified function signature are clean:

  • PathBuf import is correctly scoped
  • Direct import of write_if_changed from tauri_utils aligns with the utility function location
  • Removing the config parameter is appropriate since version code/name handling has moved to the CLI layer per the PR's new generate_tauri_properties function

11-62: LGTM!

The function body is well-structured:

  • Clear autogenerated file headers for both Gradle files
  • Proper iteration over environment variables to discover Android library dependencies
  • Correct handling of the special "tauri" plugin name case
  • write_if_changed pattern avoids unnecessary rebuilds
  • Appropriate cargo:rerun-if-changed directives for build system integration

The removal of tauri.properties generation from this module aligns with the PR's architectural shift to handle auto-incrementing version codes in the CLI layer (crates/tauri-cli/src/mobile/android/mod.rs).

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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

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.

3 participants