Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
81 lines (68 sloc) 2.29 KB
import java.text.SimpleDateFormat
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
def appNameRelease = "My app"
def appNameDebug = "My app debug"
def launcherIconRelease = "@drawable/ic_launcher"
def launcherIconDebug = "@drawable/ic_launcher_debug"
signingConfigs {
releaseConfig {
storeFile file("../key/android-debug-release-template.jks")
storePassword "SamplePassword1234"
keyAlias "android-debug-release-template"
keyPassword "SamplePassword1234"
}
}
defaultConfig {
applicationId "fp.com.debugreleasetemplate"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName gitSha() + '-' + buildTime()
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
debug {
applicationIdSuffix '.debug'
versionNameSuffix '-DEBUG'
resValue "string", "app_name", appNameDebug
}
release {
resValue "string", "app_name", appNameRelease
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.releaseConfig
}
}
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
output.processManifest.doLast {
if (variant.buildType.isDebuggable()) {
def manifestOutFile = output.processManifest.manifestOutputFile
def newFileContents = manifestOutFile.getText('UTF-8').replace(launcherIconRelease, launcherIconDebug)
manifestOutFile.write(newFileContents, 'UTF-8')
}
}
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.2'
}
def buildTime() {
def df = new SimpleDateFormat("yyyyMMddHHmmss")
df.setTimeZone(TimeZone.getTimeZone("Europe/Warsaw"))
return df.format(new Date())
}
def gitSha() {
return 'git rev-parse --short HEAD'.execute().text.trim()
}
task wrapper(type: Wrapper) {
gradleVersion = '2.2.1'
}