title: Gradle get current flavor for a specific task
body: <p>I'm trying to deal with google-services.json and different flavors. The documentation says that we need the file in the root folder.</p>
  
  <p>I got a task that can easily copy the file from the flavor folder to the root folder:</p>
  
  <pre><code>task CopyToRoot(type: Copy) {
      def appModuleRootFolder = '.'
      def srcDir = 'src'
      def googleServicesJson = 'google-services.json'
  
      outputs.upToDateWhen { false }
      def flavorName = android.productFlavors.flavor1.name
  
      description = "Switches to $flavorName $googleServicesJson"
      delete "$appModuleRootFolder/$googleServicesJson"
      from "${srcDir}/$flavorName/"
      include "$googleServicesJson"
      into "$appModuleRootFolder"
  }
  </code></pre>
  
  <p>Then, in the afterEvaluate I force</p>
  
  <pre><code>afterEvaluate {
      processFlavor1DebugGoogleServices.dependsOn CopyToRoot
      processFlavor1ReleaseGoogleServices.dependsOn CopyToRoot
  }
  </code></pre>
  
  <p>This works only for 1 flavor (defined statically). How to do this for every flavor? I got 4 flavors. How to get the current flavor that is being compiled?</p>
  
  <p>[<strong>UPDATE 1</strong>] - 
  Also tried:</p>
  
  <pre><code>task CopyToRoot(type: Copy) {
      def appModuleRootFolder = '.'
      def srcDir = 'src'
      def googleServicesJson = 'google-services.json'
  
      outputs.upToDateWhen { false }
      def flavorName = android.productFlavors.flavor1.name
  
      android.applicationVariants.all { variant -&gt;
          def flavorString = variant.getVariantData().getVariantConfiguration().getFlavorName()
          println('flavorString: ' + flavorString)
  
          description = "Switches to $flavorString $googleServicesJson"
          delete "$appModuleRootFolder/$googleServicesJson"
          from "${srcDir}/$flavorString/"
          include "$googleServicesJson"
          into "$appModuleRootFolder"
      }
   }
  </code></pre>
  
  <p>But this doesn't copy the correct file. Any help?</p>