@@ -22,21 +22,29 @@ This extension will set project versions, based on current **Git branch** or **G
22
22
23
23
### Add Plugin
24
24
25
- add plugin to ` buil.gradle ` file
26
-
25
+ #### Groovy DSL ` build.gradle `
27
26
``` groovy
28
27
plugins {
29
28
id 'me.qoomon.git-versioning' version '1.2.3'
30
29
}
31
30
```
32
31
32
+ #### Kotlin DSL ` build.gradle.kts `
33
+ ``` kotlin
34
+ plugins {
35
+ id(" me.qoomon.git-versioning" ) version " 1.2.3"
36
+ }
37
+ ```
38
+
33
39
ℹ Consider [ CI/CD] ( #cicd ) section when running this plugin in a CI/CD environment
34
40
35
41
## Configure Extension
36
42
37
43
You can configure the final version format for specific branches and tags separately.
38
44
39
- ** Example:** ` build.gradle `
45
+ ### Example Configuration
46
+
47
+ ##### Groovy DSL ` build.gradle `
40
48
``` groovy
41
49
gitVersioning {
42
50
branch {
@@ -56,6 +64,30 @@ gitVersioning {
56
64
}
57
65
}
58
66
```
67
+
68
+ #### Kotlin DSL ` build.gradle.kts `
69
+ ``` kotlin
70
+ import me.qoomon.gradle.gitversioning.GitVersioningPluginExtension.VersionDescription
71
+ import me.qoomon.gradle.gitversioning.GitVersioningPluginExtension.CommitVersionDescription
72
+ gitVersioning {
73
+ branch(closureOf<VersionDescription > {
74
+ pattern = " master"
75
+ versionFormat = " \$ {version}"
76
+ })
77
+ branch(closureOf<VersionDescription > {
78
+ pattern = " feature/(?<feature>.+)"
79
+ versionFormat = " \$ {feature}-SNAPSHOT"
80
+ })
81
+ tag(closureOf<VersionDescription >{
82
+ pattern = " v(?<tagVersion>[0-9].*)"
83
+ versionFormat = " \$ {tagVersion}"
84
+ })
85
+ commit(closureOf<CommitVersionDescription >{
86
+ versionFormat = " \$ {commit.short}"
87
+ })
88
+ }
89
+ ```
90
+
59
91
- * optional* ` preferTags ` global enable(` true ` )/disable(` false ` ) prefer tag rules over branch rules if both match.
60
92
61
93
- ` branch ` specific version format definition.
0 commit comments