apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-parcelize'

repositories {
	mavenCentral()
}

def travis = System.getenv("CI") == "true"

def getCommitCountTotal = { ->
	try
	{
		def commitCount = "git rev-list HEAD --count".execute().text.trim()
		return (commitCount == "") ? 0 : commitCount.toInteger()
	}
	catch (e)
	{
		return 1
	}
}

android {
	compileSdkVersion 31
	buildToolsVersion "31.0.0"

	defaultConfig {
		applicationId "me.anon.grow"
		minSdkVersion 17
		targetSdkVersion 31
		versionCode 2631//getCommitCountTotal()
		versionName "2.6.4"
		versionNameSuffix (travis ? "-alpha" : "")
		multiDexEnabled true

		compileOptions {
			sourceCompatibility 1.8
			targetCompatibility 1.8
		}

		resValue "string", "version_date", System.currentTimeMillis().toString()

		vectorDrawables.useSupportLibrary = true
	}

	buildFeatures {
		viewBinding true
	}


	flavorDimensions "default"

	productFlavors {
		production {
			dimension "default"
			buildConfigField "Boolean", "DISCRETE", "false"

			manifestPlaceholders = [
				"appType": "original"
			]

			resValue "string", "app_name", "GrowTracker"
		}

		en {
			resConfigs 'en'
			buildConfigField "Boolean", "DISCRETE", "false"

			manifestPlaceholders = [
				"appType": "en"
			]

			resValue "string", "app_name", "GrowTracker"
		}

		discrete {
			dimension "default"
			buildConfigField "Boolean", "DISCRETE", "true"

			manifestPlaceholders = [
				"appType": "discrete"
			]

			resValue "string", "app_name", "Tracker"
		}
	}

	signingConfigs {
		release {
			// configure keystore
			storeFile = file("../keystore.jks")
			storePassword = System.getenv("keystore_password")
			keyAlias = System.getenv("keystore_alias")
			keyPassword = System.getenv("keystore_alias_password")
			v2SigningEnabled = true
			v1SigningEnabled = true
		}
	}

	buildTypes {
		debug {
			resValue "string", "app_name", "Dev GrowTracker"
			applicationIdSuffix = ".debug"
		}

		release {
			signingConfig signingConfigs.release
		}
	}
	compileOptions {
		sourceCompatibility JavaVersion.VERSION_1_8
		targetCompatibility JavaVersion.VERSION_1_8
	}
	kotlinOptions {
		jvmTarget = '1.8'
	}
	lint {
		abortOnError false
	}
}

dependencies {
	implementation 'androidx.multidex:multidex:2.0.1'
	implementation 'androidx.core:core:1.7.0'
	implementation 'androidx.core:core-ktx:1.7.0'
	implementation 'androidx.appcompat:appcompat:1.4.1'
	implementation 'androidx.preference:preference:1.2.0'
	implementation 'androidx.recyclerview:recyclerview:1.2.1'
	implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
	implementation 'androidx.cardview:cardview:1.0.0'
	implementation 'androidx.exifinterface:exifinterface:1.3.3'
	implementation 'androidx.documentfile:documentfile:1.0.1'

	implementation 'com.github.prolificinteractive:material-calendarview:2.0.0'
	implementation 'com.jakewharton.threetenabp:threetenabp:1.2.4'

	implementation 'com.google.android.material:material:1.7.0-alpha01'
	implementation 'com.google.android.flexbox:flexbox:3.0.0'
	implementation 'com.esotericsoftware:kryo:3.0.3'
	implementation 'com.squareup.moshi:moshi-kotlin:1.13.0'
	implementation 'com.squareup:otto:1.3.8'
//	api 'com.github.PhilJay:MPAndroidChart:v2.1.6'
	implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
	implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
	implementation 'net.lingala.zip4j:zip4j:1.3.2'

	implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'

	api "org.jetbrains.kotlin:kotlin-reflect:1.6.21"
	api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21"

	kapt 'com.squareup.moshi:moshi-kotlin-codegen:1.13.0'
}
