title: How to add product flavor to version name in Gradle
body: <p>I have a Android Gradle project that has multiple flavors like so.</p>
  
  <pre><code>android {
      ...
      productFlavors {
          apple {
              applicationId "com.myapp.apple"
          }
  
          orange {
              applicationId "com.myapp.orange"
          }
  
          banana {
              applicationId "com.myapp.banana"
          }
      }
      ...
  }
  </code></pre>
  
  <p>In my <code>build.gradle</code> I also have the following piece of code that sets the <code>versionName</code> to either <strong>0.8-dev</strong> if it's an local build or <strong>0.8-123</strong> if it's a Jenkin's build.</p>
  
  <pre><code>android {
      ...
      defaultConfig {
          ...
          // Get the build number from Jenkins, otherwise use 'dev'
          ext.buildNumber = System.getenv("BUILD_NUMBER") ?: "dev"
          versionName "0.8-$buildNumber"
          ...
      }
  }
  </code></pre>
  
  <p>Since I now have different flavors of the same project, I'd like to prefix the <code>versionName</code> with the flavor so it looks something like this <strong>apple-0.8-dev</strong> or <strong>orange-0.8-dev</strong>, depending on which flavor is built.</p>
  
  <p>How do I go about doing this?</p>
  
  <p>I've tried using <code>BuildConfig.FLAVOR</code> but I can't access that in <code>build.gradle</code>.</p>