title: android studio gradle version increment
body: <p>I'm trying to setup a nice little versioning script in gradle, android studio where the version name increases every time I make a build, while the version code only increases when I make a release build. Is this possible?</p>
  
  <p>What I think would solve it is checking in the if statement below if it is a release or not. But how can I check if it is a release?</p>
  
  <pre><code>android {
  compileSdkVersion 19
  buildToolsVersion "19.0.3"
  
  def versionPropsFile = file('version.properties')
  def code
  def name
  def Properties versionProps
  
  if (versionPropsFile.canRead()) {
      versionProps = new Properties()
  
      versionProps.load(new FileInputStream(versionPropsFile))
  
      code = versionProps['VERSION_CODE'].toInteger() + 1
      name = versionProps['VERSION_NAME'].toInteger() + 1
  
      versionProps['VERSION_CODE']=code.toString()
      versionProps['VERSION_NAME']=name.toString()
      versionProps.store(versionPropsFile.newWriter(), null)
  
      defaultConfig {
          versionCode code
          versionName "1.2." + name
          minSdkVersion 14
          targetSdkVersion 19
      }
  } else {
      throw new GradleException("Could not read version.properties!")
  }
  
  signingConfigs {
      debug {
          ...
      }
      releaseKey {
          ...
      }
  }
  
  buildTypes {
      debug {
          debuggable true
          packageNameSuffix ".debug"
          proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
          signingConfig signingConfigs.debug
      }
  
      release {
          proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
          signingConfig signingConfigs.releaseKey
      }
  }
  
  lintOptions {
      abortOnError false
  }
  }
  </code></pre>
  
  <p>I would like something like:</p>
  
  <pre><code>if (release) code = versionProps['VERSION_CODE'].toInteger() + 1
  else code = versionProps['VERSION_CODE'].toInteger()
  </code></pre>
  
  <p>Any suggestions?</p>