Add dynamic version code.
This commit is contained in:
		
							parent
							
								
									9941777497
								
							
						
					
					
						commit
						fa2af6dd90
					
				
					 1 changed files with 8 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -12,7 +12,7 @@ android {
 | 
			
		|||
        applicationId "com.pixelized.biblib"
 | 
			
		||||
        minSdk 23
 | 
			
		||||
        targetSdk 30
 | 
			
		||||
        versionCode 1
 | 
			
		||||
        versionCode generateVersionCode()
 | 
			
		||||
        versionName "0.1.2"
 | 
			
		||||
 | 
			
		||||
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
 | 
			
		||||
| 
						 | 
				
			
			@ -105,4 +105,11 @@ dependencies {
 | 
			
		|||
    // Test
 | 
			
		||||
    testImplementation 'junit:junit:4.13.2'
 | 
			
		||||
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.0.0-beta06"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static def generateVersionCode() {
 | 
			
		||||
    def result = "git rev-list HEAD --count".execute().text.trim() //unix
 | 
			
		||||
    if (result.empty) result = "PowerShell -Command git rev-list HEAD --count".execute().text.trim() //windows
 | 
			
		||||
    if (result.empty) throw new RuntimeException("Could not generate versioncode on this platform? Cmd output: ${result.text}")
 | 
			
		||||
    return result.toInteger()
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue