-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
sign.gradle
executable file
·43 lines (38 loc) · 1.65 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
apply from: "../constants.gradle"
def versionPropsFile = file("../version.properties")
def codeKey = "VERSION_CODE"
if (versionPropsFile.canRead()) {
Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
project.ext.versionCode = versionProps[codeKey].toInteger()
} else {
throw new GradleException("Could not read version.properties. File exists: ${versionPropsFile.exists()}")
}
println "Version code:" + project.ext.versionCode
def signConfFile = file("../sign.properties")
if (signConfFile.canRead()) {
Properties signProps = new Properties()
signProps.load(new FileInputStream(signConfFile))
project.ext.storeFileProp = signProps["file"].toString()
aliasProp = signProps["alias"].toString()
pwdProp = signProps["pwd"].toString()
} else {
throw new GradleException("Could not read sign.properties. File exists: ${signConfFile.exists()}")
}
tasks.configureEach { task ->
if (task.name == "signReleaseBundle") {
task.doLast() {
println "Get And Increment Version code"
if (versionPropsFile.canRead()) {
Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
def code = versionProps[codeKey].toInteger() + 1
versionProps[codeKey] = code.toString()
versionProps.store(versionPropsFile.newWriter(), null)
println "Version code incremented to " + code
} else {
throw new GradleException("Could not read version.properties. File exists: ${versionPropsFile.exists()}")
}
}
}
}