-
Notifications
You must be signed in to change notification settings - Fork 64
/
versionTasks.gradle
67 lines (56 loc) · 1.92 KB
/
versionTasks.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
private def setVersionName(newVersionName) {
ant.propertyfile(file: 'gradle.properties') {
entry(key: "VERSION_NAME", value: newVersionName)
}
}
task incrementPatchVersion {
group 'publishing'
doLast {
def (_,majorStr, minorStr, patchStr, snapshotStr) = (VERSION_NAME =~ /^(\d+)\.(\d+)\.(\d+)(-SNAPSHOT)?/)[0]
def newVersionName = majorStr + "." + minorStr + "." + (Integer.parseInt(patchStr) + 1) +
((snapshotStr != null) ? snapshotStr : "")
setVersionName(newVersionName)
}
}
task incrementMinorVersion {
group 'publishing'
doLast {
def (_, majorStr, minorStr, patchStr, snapshotStr) = (VERSION_NAME =~ /^(\d+)\.(\d+)\.(\d+)(-SNAPSHOT)?/)[0]
def newVersionName = majorStr + "." + (Integer.parseInt(minorStr) + 1) + "." + patchStr +
((snapshotStr != null) ? snapshotStr : "")
setVersionName(newVersionName)
}
}
task incrementMajorVersion {
group 'publishing'
doLast {
def (_, majorStr, minorStr, patchStr, snapshotStr) = (VERSION_NAME =~ /^(\d+)\.(\d+)\.(\d+)(-SNAPSHOT)?/)[0]
def newVersionName = (Integer.parseInt(majorStr) + 1) + "." + minorStr + "." + patchStr +
((snapshotStr != null) ? snapshotStr : "")
setVersionName(newVersionName)
}
}
task setSnapshotVersionSuffix {
group 'publishing'
doLast {
def (_, versionPrefix, snapshotStr) = (VERSION_NAME =~ /^(\d+\.\d+\.\d+)(-SNAPSHOT)?/)[0]
if (snapshotStr == null) {
setVersionName(versionPrefix + "-SNAPSHOT")
}
}
}
task removeSnapshotVersionSuffix {
group 'publishing'
doLast {
def (_, versionPrefix, snapshotStr) = (VERSION_NAME =~ /^(\d+\.\d+\.\d+)(-SNAPSHOT)?/)[0]
if (snapshotStr != null) {
setVersionName(versionPrefix)
}
}
}
task printVersionName {
group 'publishing'
doLast {
println VERSION_NAME
}
}