feat(android): generate BuildConfig.java per variant with default + user fields - #11
Merged
Conversation
…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.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 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. Comment |
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BuildConfig codegen for the android plugin. Every variant now generates a
BuildConfig.javasource file with nine default fields derived from theandroid {}block, plus any user-defined fields declared viabuildConfigFieldtriples.Changes
parse_build_config_fields— extracts list triples from the android block'sbuildConfigFieldkeygenerate_buildconfig_source/BuildConfigParams— produces valid Java sourcegenerateBuildConfig<V>WriteFile task per variant, depends onprepareBuildDir, outputs to<build>/<variant>/generated/buildconfig/<namespace>/BuildConfig.javacompile_argsupdated withbuildconfig_dir: Option<&Path>for-sourcepathcompileJava<V>depends ongenerateBuildConfig<V>merge_variant_sourcesfix: base paths resolved before deduplicationquote_stringhelper,BuildConfigFieldstruct,#[derive(Debug)]onFlavorInfoDSL syntax
Default fields
APPLICATION_ID, BUILD_TYPE, DEBUG, FLAVOR, VERSION_CODE, VERSION_NAME, MIN_SDK_VERSION, TARGET_SDK_VERSION, COMPILE_SDK_VERSION
DoD