title: Set custom applicationId depending on flavor combination with Kotlin Gradle for Android
body: <p>With gradle scripts in groovy it's possible to customize the <code>applicationId</code> or <code>applicationIdSuffix</code> depending on combination of flavors. </p>
  
  <pre><code>applicationVariants.all { variant -&gt;
      def name = variant.getName()
      if (name.contains("Prod") &amp;&amp; name.contains("Paid")) {
         variant.mergedFlavor.applicationIdSuffix = ".foo"
      } else if (name.contains("Prod") &amp;&amp; name.contains("Free")) {
         variant.mergedFlavor.applicationIdSuffix = ".bar"
      } 
      // else if ... and so on
  }
  </code></pre>
  
  <p>I'm trying now to convert the gradle build scripts in kotlin (<code>*.kts</code>) and it seems like there is no way to do it, because there is no more setter methods for <code>applicationId</code> and <code>applicationIdSuffix</code> properties.</p>
  
  <pre><code>applicationVariants.all {
      mergedFlavor.applicationIdSuffix = ".foo" // error here
  }
  </code></pre>
  
  <p>Is there any other way to do it with kotlin scripts?</p>
  
  <p>I'm currently using:</p>
  
  <pre><code>gradle-5.6
  com.android.tools.build:gradle:3.5.3
  org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50
  </code></pre>