-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
81 lines (62 loc) · 3.11 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
task commitVersion {
if (project.hasProperty("commit")) {
print("commiting version")
def versionPropsFile = file('version.properties')
Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
def versionPatchStaged = versionProps['VERSION_PATCH_STAGED'].toInteger()
def versionBuildStaged = versionProps['VERSION_BUILD_STAGED'].toInteger()
def versionNumberStaged = versionProps['VERSION_NUMBER_STAGED'].toInteger()
def versionPatch = versionProps['VERSION_PATCH'].toInteger() + versionPatchStaged
def versionBuild = versionProps['VERSION_BUILD'].toInteger() + versionBuildStaged
def versionNumber = versionProps['VERSION_NUMBER'].toInteger() + versionNumberStaged
versionProps['VERSION_PATCH_STAGED'] = 0.toString()
versionProps['VERSION_BUILD_STAGED'] = 0.toString()
versionProps['VERSION_NUMBER_STAGED'] = 0.toString()
versionProps['VERSION_PATCH'] = versionPatch.toString()
versionProps['VERSION_BUILD'] = versionBuild.toString()
versionProps['VERSION_NUMBER'] = versionNumber.toString()
versionProps.store(versionPropsFile.newWriter(), null)
}
}
def autoincrementVersion() {
print("Incrementing version")
def versionPropsFile = file('version.properties')
def runTasks = gradle.getStartParameter().getTaskRequests().toString()
def value = 0
if (runTasks.contains('assemble') || runTasks.contains('assembleRelease') || runTasks.contains('aR')) {
value = 1
}
Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
def versionPatch = versionProps['VERSION_PATCH_STAGED'].toInteger() + value
def versionBuild = versionProps['VERSION_BUILD_STAGED'].toInteger() + 1
def versionNumber = versionProps['VERSION_NUMBER_STAGED'].toInteger() + value
versionProps['VERSION_PATCH_STAGED'] = versionPatch.toString()
versionProps['VERSION_BUILD_STAGED'] = versionBuild.toString()
versionProps['VERSION_NUMBER_STAGED'] = versionNumber.toString()
versionProps.store(versionPropsFile.newWriter(), null)
}
android{
// ... snip
def versionPropsFile = file('version.properties')
if (versionPropsFile.canRead()) {
Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
def versionMajor = versionProps['VERSION_MAJOR'].toInteger()
def versionMinor = versionProps['VERSION_MINOR'].toInteger()
def versionPatch = versionProps['VERSION_PATCH'].toInteger()
def versionBuild = versionProps['VERSION_BUILD'].toInteger()
def versionNumber = versionProps['VERSION_NUMBER'].toInteger()
defaultConfig {
applicationId "com.application.myapplicationhere"
minSdkVersion 23
targetSdkVersion 28
versionCode versionNumber
versionName "${versionMajor}.${versionMinor}.${versionPatch} (${versionBuild})"
}
} else {
throw new GradleException("Could not read version.properties!")
}
//snip ...
}