Unresolve reference MergedFlavor

I’m developing android plugin that will beside replacing resources provided from Jenkins config, it also changes the Android applicationId of all product flavors declared in the project (and flavors of all variants)

Everything worked fine until after upgrading to plugin 4.1.3 and gradle 6.5 I’m experiencing failure when finding MergedFlavor class

This the snippet that I have.

open class SetApplicaitonIdTask: MyOverhaulingTask() {

override fun updateApplicationidFromConfig(project: Project, config: MyConfig, flavor: BaseFlavor, myExtension: MyExtension) {
      project.android.app.applicationVariants.all { variant ->
          val mergedFlavor = variant.mergedFlavor as MergedFlavor 
          mergedFlavor.applicationId = config.bundleIdentifier.android
          true
      }
      config.run {
          flavor.resValue("string", "app_launcher_name", appName)
          flavor.resValue("string", "product_number", productNumber)
      }
  }

val Project.android: BaseExtension
    get() = extensions.findByName("android") as? BaseExtension
        ?: error("Project '$name' is not an Android module. Can't access 'android' extension.")

/**
 * Accesses the app module-specific extensions of an Android module.
 */
val BaseExtension.app: AppExtension
    get() = this as? AppExtension
        ?: error("Android module is not an app module. Can't access 'android' app extension.")

Although the import import com.android.build.gradle.internal.core.MergedFlavor is present, it can’t recognize it for some reason. Is it because that it’s form .internal.core package?

What I’m doing wrong? How can I update applicationId alternatively?

Previously I was running on 5.6.4 gradle and 1.3.6 gradle plugin

Studio Build: 4.1 and 4.2 Canary
Version of Gradle Plugin: 4.1.3
Version of Gradle: 6.5
Version of Java: 11 OS: Win 10