You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(2) will be the name of the current tag if any, or `null` if no tag is associated to the current `HEAD`.
@@ -119,6 +125,18 @@ For branches to type `release`, an additional computation occurs:
119
125
120
126
By using the `display` version when tagging a release, the `display` version will be automatically incremented, patch after patch, using the `release` base at a prefix.
121
127
128
+
### Version number
129
+
130
+
Version number is a container of several numbers computed from `display` by default . It is hosting major, minor, patch,
131
+
qualifier and versionCode.
132
+
133
+
- In a tag like `1.2.3`, then major is `1`, minor is `2` and patch is `3`
134
+
- Qualifier are taken from tags formatted like `1.2-beta.0` where qualifier is `-beta` here
135
+
- Version code is a integer computed from major, minor and patch version.
136
+
-`1.2.3` will give 10203
137
+
-`21.5.16` will give 210516
138
+
-`2.0-alpha.0` will give 20000
139
+
122
140
## Tasks
123
141
124
142
The `versioning` plug-in provides two tasks.
@@ -142,6 +160,11 @@ Displays the version information in the standard output. For example:
142
160
[version] tag =
143
161
[version] lastTag = 0.2.0
144
162
[version] dirty = false
163
+
[version] versionCode = 0
164
+
[version] major = 0
165
+
[version] minor = 0
166
+
[version] patch = 0
167
+
[version] qualifier =
145
168
```
146
169
147
170
### `versionFile`
@@ -163,6 +186,11 @@ VERSION_SCM=git
163
186
VERSION_TAG=
164
187
VERSION_LAST_TAG=0.2.0
165
188
VERSION_DIRTY=false
189
+
VERSION_VERSIONCODE=0
190
+
VERSION_MAJOR=0
191
+
VERSION_MINOR=0
192
+
VERSION_PATCH=0
193
+
VERSION_QUALIFIER=
166
194
```
167
195
168
196
This makes this file easy to integrate in a Bash script:
@@ -202,7 +230,7 @@ versioning {
202
230
* present, the type is the branch and the base is empty.
203
231
* F.e. if you want use tag name instead of branch you may provide something like:
204
232
*/
205
-
releaseParser = { scmInfo, separator = '/' -> ->
233
+
releaseParser = { scmInfo, separator = '/' ->
206
234
List<String> part = scmInfo.tag.split('/') + ''
207
235
new net.nemerosa.versioning.ReleaseInfo(type: part[0], base: part[1])
208
236
}
@@ -226,7 +254,6 @@ versioning {
226
254
* the tags in Git.
227
255
*/
228
256
lastTagPattern = /(\d+)$/
229
-
*/
230
257
}
231
258
```
232
259
@@ -387,6 +414,83 @@ versioning {
387
414
}
388
415
}
389
416
```
417
+
### Version number
418
+
419
+
Version number computation can be customised by setting some properties in the `versioning` extension.
420
+
421
+
```groovy
422
+
versioning {
423
+
/**
424
+
* Digit precision for computing version code.
425
+
*
426
+
* With a precision of 2, 1.25.3 will become 12503.
427
+
* With a precision of 3, 1.25.3 will become 1250003.
428
+
*/
429
+
int precision = 2
430
+
431
+
/**
432
+
* Default number to use when no version number can be extracted from version string.
433
+
*/
434
+
int defaultNumber = 0
435
+
436
+
/**
437
+
* Closure that takes major, minor and patch integers in parameter and is computing versionCode number.
438
+
*/
439
+
Closure<Integer> computeVersionCode = { int major, int minor, int patch ->
0 commit comments