Skip to content

feat(android): generate BuildConfig.java per variant with default + user fields - #11

Merged
ulite-Amr merged 5 commits into
mainfrom
feat/buildconfig-generation
Aug 25, 2026
Merged

feat(android): generate BuildConfig.java per variant with default + user fields#11
ulite-Amr merged 5 commits into
mainfrom
feat/buildconfig-generation

Conversation

@ulite-Amr

Copy link
Copy Markdown
Contributor

Summary

BuildConfig codegen for the android plugin. Every variant now generates a BuildConfig.java source file with nine default fields derived from the android {} block, plus any user-defined fields declared via buildConfigField triples.

Changes

  • parse_build_config_fields — extracts list triples from the android block's buildConfigField key
  • generate_buildconfig_source / BuildConfigParams — produces valid Java source
  • generateBuildConfig<V> WriteFile task per variant, depends on prepareBuildDir, outputs to <build>/<variant>/generated/buildconfig/<namespace>/BuildConfig.java
  • compile_args updated with buildconfig_dir: Option<&Path> for -sourcepath
  • compileJava<V> depends on generateBuildConfig<V>
  • merge_variant_sources fix: base paths resolved before deduplication
  • quote_string helper, BuildConfigField struct, #[derive(Debug)] on FlavorInfo
  • 50 android plugin tests pass, clippy/fmt clean

DSL syntax

android {
  buildConfigField ["String", "API_KEY", "\"abc123\""]
  buildConfigField ["int", "MAX_RETRIES", "3"]
}

Default fields

APPLICATION_ID, BUILD_TYPE, DEBUG, FLAVOR, VERSION_CODE, VERSION_NAME, MIN_SDK_VERSION, TARGET_SDK_VERSION, COMPILE_SDK_VERSION

DoD

  • cargo build --all-targets
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo fmt --check
  • cargo test --workspace (88 tests)
  • PROGRESS.md updated
  • No process-tell in touched files

…ser fields

The android plugin now generates a BuildConfig.java source file for each
variant during the configure phase. The file contains nine default fields
derived from the module's android block (APPLICATION_ID, BUILD_TYPE,
DEBUG, FLAVOR, VERSION_CODE, VERSION_NAME, MIN_SDK_VERSION,
TARGET_SDK_VERSION, COMPILE_SDK_VERSION) plus any user-defined fields
declared via buildConfigField triples in the android block.

DSL syntax:
  buildConfigField ["TYPE", "NAME", "INITIALIZER"]

The generated file lives at
<build>/<variant>/generated/buildconfig/<namespace>/BuildConfig.java and
is added to javac's -sourcepath so compilation resolves it automatically.

New public items: BuildConfigField, BuildConfigParams, parse_build_config_fields,
generate_buildconfig_source, quote_string.

Also fixes: merge_variant_sources now resolves base paths before
deduplication so relative paths in base sources match resolved flavor
paths. Adds #[derive(Debug)] to FlavorInfo. Suppresses pre-existing
unused variable warnings in the top-level partition call.

50 tests, clippy clean, fmt clean.
Mark BuildConfig generation as done in the next-up list. Update
clippy-clean unused variable and useless_vec in the dedup test.
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 897340a1-28dd-4807-b36d-6f4b6d3ba11a


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

…eneration

generateBuildConfig<V> adds 2 tasks (one per variant), so:
- Java first build: 18→20 ran
- Java unchanged: 0 ran, 18→20 up-to-date
- Java resource change: 13→15 ran, 5 up-to-date
- Java source change: 8 ran, 10→12 up-to-date
- Kotlin first build: 20→22 ran
…igField parsing

The evaluator's insert_accumulating produces an irregular structure when
buildConfigField is declared multiple times: the first triple's elements
are flat strings, and subsequent triples are nested sub-arrays. Both the
plugin's parse_build_config_fields and the fixture's buildConfigProbe now
walk the array extracting triples from both forms. Also updates CI task
count assertions (18→20 for Java, 20→22 for Kotlin), unit tests, and
the resource-change assertion.
… harden tests

- quote_string now escapes backslashes and double quotes to produce valid
  Java string literals.
- Remove unused partition_sources call and _base in dedup test (dead code).
- Add 3-entry and non-dedup merge tests for better coverage.
- Document that merge_variant_sources returns absolute paths.
@ulite-Amr
ulite-Amr merged commit 5c96420 into main Aug 25, 2026
9 checks passed
@ulite-Amr
ulite-Amr deleted the feat/buildconfig-generation branch August 25, 2026 15:30
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