✨Fix: Support dot-notation in customConfig when generating Kotlin DSL#391
✨Fix: Support dot-notation in customConfig when generating Kotlin DSL#391Uvais-Mohammad wants to merge 5 commits intoAngeloAvv:masterfrom
Conversation
Handle manifestPlaceholders in android flavor custom configuration by properly formatting them in the generated gradle.kts file. This allows for dynamic scheme configuration per flavor. Also update test files.
|
Hi @Uvais-Mohammad, thank you for your PR. IMHO, the dot notation could not be the proper way to fix this problem. Since customConfig is defined as a Map<String, dynamic>, it would be better to exploit the nature of the property to parse children. Also, your solution currently applies to the manifestPlaceholders field only. What if we need to apply the same logic to fields that behave the same? Instead of declaring fields as you proposed: I think it could be better to have the following declaration: And then iterate recursively through customConfig What do you think? |
|
Hey @AngeloAvv , You’re absolutely right that relying on dot-notation is a bit of a workaround and limits the solution to specific cases like manifestPlaceholders. Recursively iterating over them is a much cleaner and more future-proof approach. I can update the PR to implement above solution. Thanks again for the feedback💙. Really appreciate it. |
Move custom configuration processing logic to a dedicated method to improve code maintainability and handle nested configurations
…gradle Implement processing of nested manifestPlaceholders in Android legacy gradle configuration. The changes allow for deeper customization of Android flavors by supporting hierarchical placeholder values in the build configuration.
|
Hey @AngeloAvv, I’ve updated the implementation to support nested customConfig using recursive parsing for both Kotlin DSL and legacy Groovy DSL. Instead of relying on dot-notation keys, the processor now properly handles configurations like: Kotlin DSL output:Legacy Groovy DSL output: |
When using keys like:
flutter_flavorizr generates invalid Kotlin:
manifestPlaceholders.appScheme = "value"This PR transforms dot-notation into proper map syntax:
manifestPlaceholders["appScheme"] = "value"What This PR Fixes
This PR adds support for dot-notation in custom configuration keys by:
• Detecting keys that contain . (e.g., manifestPlaceholders.appScheme)
• Splitting the key into parent and child segments
• Generating valid Kotlin DSL map-style assignments
Why This Matters
Without this fix, any flavor configuration using manifestPlaceholders.* or similar nested structures produces invalid Gradle Kotlin DSL syntax, causing build failures.