ionic-team / trapeze

The mobile project configuration toolbox. Manage native iOS, Android, Ionic/Capacitor, React Native, and Flutter apps through a simple YAML format.
https://trapeze.dev
Other
328 stars 40 forks source link

Replace mode in gradle config not working with arrays #219

Open Arturs-E opened 3 months ago

Arturs-E commented 3 months ago

When trying to replace an array value in app/build.gradle file, a new line is added instead of replacing the existing one.

I have a productFlavors section that i'm looking to update:

    productFlavors {
        prod {
            dimension "environment"
            manifestPlaceholders = [displayName:"My App"]
        }
    }

Replace mode works correctly for primitives, like the applicationIdSuffix property, however not so with manifestPlaceholders property, which is an array - instead of replacing the existing array, a new one - equal to the existing one - is created.

trapeze config.yaml file:

platforms:
  android:
    gradle:
      - file: app/build.gradle
        target:
          android:
            productFlavors:
              prod:
                manifestPlaceholders:
        replace:
          manifestPlaceholders: = [displayName:"My App"]

Currently it results in the following gradle config:

    productFlavors {
        prod {
            dimension "environment"
            manifestPlaceholders = [displayName:"My App"]
            manifestPlaceholders = [displayName:"My App"]
        }
    }

I've tried different configuration variants but nothing really seems to work. Is there something i'm missing in the configuration?