/
build.gradle
81 lines (68 loc) · 2.29 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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'
}