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

Android SigningConfig must be placed before buildTypes element #38

Open marianobntz-silohub opened 2 years ago

marianobntz-silohub commented 2 years ago

The android plugin requires (it is a bug in my opinion) that the signingConfigs element is placed BEFORE the buildTypes element. When I use capacitor/config to create the signingConfigs element it is created after buildTypes (guess it is done in alphabetical order)... This makes it hard to create a valid build configuration. Thanks! it is a great tool!!

marianobntz-silohub commented 2 years ago

actually I see it is not alphabetical, it just goes at the end of the other elements...

mlynch commented 2 years ago

Meaning the Gradle file? Then perhaps this needs to support some kind of XPath syntax to specifically target where you want things. Will leave this open, thanks

marianobntz-silohub commented 2 years ago

Yes, the gradle file. android/app/build.gradle (normally). XPath would be nice, it should support preceding-sibling or following-sibling to make it work. Thanks!!! PS: support for editing a value and not just inserting would be nice.

ciekawy commented 1 year ago

there is replace for editing. Still while thats clear that editing gradle files is non trivial. This is essential to full automation. I have similar need to add plugins {} section and insert just appends while this needs to be earlier - ideally on top. Currently the only way is to use patch - and I think it would make sense for trapeze to support patch as well

kvashninag commented 9 months ago

You can insert it at the end of a block that is previous to the target one. Trapeze does not check the validity of the inserted data - this can be used. Example:

Before build.gradle:

android {
    defaultConfig {
        ....
     }

    buildTypes {
        ....
    }
}

Run:

    gradle:
      - file: app/build.gradle
        target:
          android:
            defaultConfig:
        insert: |
          }

          signingConfigs {
               {
          .....
        }

After build.gradle:

android {
    defaultConfig {
        ....
    }

    signingConfigs {
      ...
    }    

    buildTypes {
        ....
    }
}