title: How to get Current Build Type in Gradle
body: <p>My Question is very direct and easy to understand.</p>
  
  <p><strong>Question</strong></p>
  
  <p>In Gradle, is there any way I can get the current build type at runtime. For example, when running an assemble<strong>Debug</strong> task, can tasks within the build.gradle file make decisions based on the fact that this task is related to the debug build variant?</p>
  
  <p><strong>Sample Code</strong></p>
  
  <pre><code>apply plugin: 'com.android.library'
  ext.buildInProgress = "" 
  
  buildscript {
  
  repositories {
      maven {
          url = url_here
      }
  }
  
  dependencies {
      classpath 'com.android.tools.build:gradle:3.0.1'
  }
  }
  
  
  configurations {
       //get current build in progress here e.g buildInProgress = this.getBuildType()
  }
  
  android {
       //Android build settings here
  }
  
  buildTypes {
           release {
            //release type details here
        }
  
         debug {
             //debug type details here
         }
  
      anotherBuildType{
            //another build type details here
      }
  
     }
  }
  
  dependencies {
        //dependency list here
  }
  
  repositories{
           maven(url=url2_here)
  }
  
  
  task myTask{
        if(buildInProgress=='release'){
             //do something this way
        }
        else if(buildInProgress=='debug'){
            //do something this way
        }
        else if(buildInProgress=='anotherBuildType'){
           //do it another way
       }
  }
  </code></pre>
  
  <p><strong>In Summary</strong></p>
  
  <p>Is there a way for me to get exactly the build type in progress within <strong>myTask{}</strong>?</p>