// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
	repositories {
		jcenter()
		mavenCentral()
	}
	dependencies {
		classpath 'com.android.tools.build:gradle:2.3.1'
		// NOTE: Do not place your application dependencies here; they belong
		// in the individual module build.gradle files

		classpath 'org.ajoberstar:grgit:1.1.0'

		// https://github.com/Triple-T/gradle-play-publisher#usage
		classpath 'com.github.triplet.gradle:play-publisher:1.2.0'
	}
}

plugins {
	// obtain revision from git
	id 'org.ajoberstar.grgit' version '1.6.0'
}

allprojects {
	repositories {
		jcenter()
	}
}

/////////////// yaxim specific build rules ///////////////
apply plugin: 'com.android.application'
apply plugin: 'com.github.triplet.play'

ext {
	build_date = "${new Date().format('yyyy-MM-dd')}"
	build_revision = "${grgit.describe()}"
	build_version = "yaxim ${build_revision} ${build_date}"
}

task buildVersion (type: Copy) {
	from("template") {
		include "version.xml"
		expand( build_date: build_date,
			build_revision: build_revision,
			build_version: build_version)
	}
	into("res/values")
	outputs.upToDateWhen {
		false
	}
}

play {
	track = 'beta'
}

android {
	compileSdkVersion 22
	buildToolsVersion "25.0.0"
	playAccountConfigs {
		defaultAccountConfig {
			jsonFile = file('play-publish-credentials.json')
		}
	}
	defaultConfig {
		minSdkVersion 7
		targetSdkVersion 17
		versionName "$build_revision"
		playAccountConfig = playAccountConfigs.defaultAccountConfig
	}

	signingConfigs {
		release {
			storeFile file(RELEASE_STORE_FILE)
			storePassword RELEASE_STORE_PASSWORD
			keyAlias RELEASE_KEY_ALIAS
			keyPassword RELEASE_KEY_PASSWORD
		}
	}

	buildTypes {
		debug {
			minifyEnabled true
			proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg'
		}
		release {
			minifyEnabled true
			proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg'
			signingConfig signingConfigs.release
		}
	}

	sourceSets {
		main {
			manifest.srcFile 'AndroidManifest.xml'
			java.srcDirs = ['src']
			resources.srcDirs = ['src']
			aidl.srcDirs = ['src']
			renderscript.srcDirs = ['src']
			res.srcDirs = ['res']
			assets.srcDirs = ['assets']
		}
	}
	lintOptions {
		disable 'MissingTranslation'
	}
}

dependencies {
	compile project('actionbarsherlock')
	compile project('MemorizingTrustManager')
	compile fileTree(include: ['*.jar'], dir: 'libs')
	compile "me.leolin:ShortcutBadger:1.1.21@aar"
	compile 'org.hsluv:hsluv:0.2'
	compile 'com.koushikdutta.urlimageviewhelper:urlimageviewhelper:1.0.4'
	compile 'com.google.zxing:core:3.2.1'
}

preBuild.dependsOn buildVersion
