Skip to content

✨Fix: Support dot-notation in customConfig when generating Kotlin DSL#391

Open
Uvais-Mohammad wants to merge 5 commits intoAngeloAvv:masterfrom
Uvais-Mohammad:fix-customConfig-dot-notation
Open

✨Fix: Support dot-notation in customConfig when generating Kotlin DSL#391
Uvais-Mohammad wants to merge 5 commits intoAngeloAvv:masterfrom
Uvais-Mohammad:fix-customConfig-dot-notation

Conversation

@Uvais-Mohammad
Copy link
Copy Markdown

When using keys like:

customConfig:
  manifestPlaceholders.appScheme: "value"

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.

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.
@AngeloAvv
Copy link
Copy Markdown
Owner

AngeloAvv commented Nov 22, 2025

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:

customConfig:
  manifestPlaceholders.appScheme: "value"

I think it could be better to have the following declaration:

customConfig:
  manifestPlaceholders:
    appScheme: "value"

And then iterate recursively through customConfig

What do you think?

@Uvais-Mohammad
Copy link
Copy Markdown
Author

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.
@Uvais-Mohammad
Copy link
Copy Markdown
Author

Uvais-Mohammad commented Nov 24, 2025

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:

customConfig:
  manifestPlaceholders:
    appScheme: "appleScheme"
    deep:
      level:
        item: "x"

Kotlin DSL output:

manifestPlaceholders["appScheme"] = "appleScheme"
manifestPlaceholders["deep"]["level"]["item"] = "x"

Legacy Groovy DSL output:

manifestPlaceholders.appScheme = "appleScheme"
manifestPlaceholders.deep.level.item = "x"

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.

2 participants