1
+ private def setVersionName (newVersionName ) {
2
+ ant. propertyfile(file : ' gradle.properties' ) {
3
+ entry(key : " VERSION_NAME" , value : newVersionName)
4
+ }
5
+ }
6
+
7
+ task incrementPatchVersion {
8
+ group ' publishing'
9
+
10
+ doLast {
11
+ def (_,majorStr, minorStr, patchStr, snapshotStr) = (VERSION_NAME =~ / ^(\d +)\. (\d +)\. (\d +)(-SNAPSHOT)?/ )[0 ]
12
+ def newVersionName = majorStr + " ." + minorStr + " ." + (Integer . parseInt(patchStr) + 1 ) +
13
+ ((snapshotStr != null ) ? snapshotStr : " " )
14
+ setVersionName(newVersionName)
15
+ }
16
+ }
17
+
18
+ task incrementMinorVersion {
19
+ group ' publishing'
20
+
21
+ doLast {
22
+ def (_, majorStr, minorStr, patchStr, snapshotStr) = (VERSION_NAME =~ / ^(\d +)\. (\d +)\. (\d +)(-SNAPSHOT)?/ )[0 ]
23
+ def newVersionName = majorStr + " ." + (Integer . parseInt(minorStr) + 1 ) + " ." + patchStr +
24
+ ((snapshotStr != null ) ? snapshotStr : " " )
25
+ setVersionName(newVersionName)
26
+ }
27
+ }
28
+
29
+ task incrementMajorVersion {
30
+ group ' publishing'
31
+
32
+ doLast {
33
+ def (_, majorStr, minorStr, patchStr, snapshotStr) = (VERSION_NAME =~ / ^(\d +)\. (\d +)\. (\d +)(-SNAPSHOT)?/ )[0 ]
34
+ def newVersionName = (Integer . parseInt(majorStr) + 1 ) + " ." + minorStr + " ." + patchStr +
35
+ ((snapshotStr != null ) ? snapshotStr : " " )
36
+ setVersionName(newVersionName)
37
+ }
38
+ }
39
+
40
+ task setSnapshotVersionSuffix {
41
+ group ' publishing'
42
+
43
+ doLast {
44
+ def (_, versionPrefix, snapshotStr) = (VERSION_NAME =~ / ^(\d +\.\d +\.\d +)(-SNAPSHOT)?/ )[0 ]
45
+ if (snapshotStr == null ) {
46
+ setVersionName(versionPrefix + " -SNAPSHOT" )
47
+ }
48
+ }
49
+ }
50
+
51
+ task removeSnapshotVersionSuffix {
52
+ group ' publishing'
53
+
54
+ doLast {
55
+ def (_, versionPrefix, snapshotStr) = (VERSION_NAME =~ / ^(\d +\.\d +\.\d +)(-SNAPSHOT)?/ )[0 ]
56
+ if (snapshotStr != null ) {
57
+ setVersionName(versionPrefix)
58
+ }
59
+ }
60
+ }
61
+
62
+ task printVersionName {
63
+ group ' publishing'
64
+ doLast {
65
+ println VERSION_NAME
66
+ }
67
+ }
0 commit comments