-
Notifications
You must be signed in to change notification settings - Fork 0
/
sign.gradle
49 lines (39 loc) · 1.28 KB
/
sign.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
final Console console = System.console();
if (console != null) {
android.signingConfigs {
release {
project.ext.keyStorePath = System.getenv("ANDROID_KEYSTORE")
if( project.keyStorePath != null )
{
storeFile file( keyStorePath )
keyAlias System.getenv("ANDROID_KEY_ALIAS")
}
storePassword "password"
keyPassword "password"
}
}
task askForPasswords << {
// Must create String because System.readPassword() returns char[]
// (and assigning that below fails silently)
def storePw = new String(System.console().readPassword("\nKeystore password: "))
def keyPw = new String(System.console().readPassword("Key password: "))
android.signingConfigs.release.storePassword = storePw
android.signingConfigs.release.keyPassword = keyPw
}
tasks.whenTaskAdded { theTask ->
if (theTask.name.equals("packageRelease")) {
theTask.dependsOn "askForPasswords"
}
}
android.buildTypes {
release {
signingConfig android.signingConfigs.release
}
}
} else {
// Building from IDE's "Run" button
android.signingConfigs {
release {
}
}
}