In my build.gradle I also have the following piece of code that sets the versionName

I have a Android Gradle project that has multiple flavors like so.

android {
 
   ...
    productFlavors {
    apple {
        applicationId "com.myapp.apple"
    }

    orange {
        applicationId "com.myapp.orange"
    }

    banana {
        applicationId "com.myapp.banana"
    }
}
...

}

In my build.gradle I also have the following piece of code that sets the versionName to either 0.8-dev if it’s an local build or 0.8-123 if it’s a Jenkin’s build.

android {

    ...
    defaultConfig {
        ...
        // Get the build number from Jenkins, otherwise use 'dev'
        ext.buildNumber = System.getenv("BUILD_NUMBER") ?: "dev"
        versionName "0.8-$buildNumber"
        ...
    }
}

Since I presently have diverse kinds of a similar task, I’d like to prefix the versionName with the flavor so it looks something like this apple-0.8-dev or orange-0.8-dev, contingent upon which flavor is built.

How would I approach doing this?

I’ve had a go at using BuildConfig.FLAVOR however I can’t get to that in build.gradle.

Thanks,

Sailaja.