@@ -29,13 +29,13 @@ import org.gradle.api.Plugin
2929
3030class SemverGitPlugin implements Plugin<Project > {
3131
32- def static String getGitVersion (String nextVersion , String snapshotSuffix , File projectDir = null ) {
33- def proc = " git describe --exact-match" . execute(null , projectDir);
32+ def static String getGitVersion (String nextVersion , String snapshotSuffix , String gitArgs , File projectDir = null ) {
33+ def proc = ( " git describe --exact-match " + gitArgs) . execute(null , projectDir);
3434 proc. waitFor();
3535 if (proc. exitValue() == 0 ) {
3636 return checkVersion(proc. text. trim());
3737 }
38- proc = " git describe" . execute(null , projectDir);
38+ proc = ( " git describe " + gitArgs) . execute(null , projectDir);
3939 proc. waitFor();
4040 if (proc. exitValue() == 0 ) {
4141 def describe = proc. text. trim()
@@ -105,13 +105,17 @@ class SemverGitPlugin implements Plugin<Project> {
105105 void apply (Project project ) {
106106 def nextVersion = " minor"
107107 def snapshotSuffix = " SNAPSHOT"
108+ def gitDescribeArgs = ' --match *[0-9].[0-9]*.[0-9]*'
108109 if (project. ext. properties. containsKey(" nextVersion" )) {
109110 nextVersion = project. ext. nextVersion
110111 }
111112 if (project. ext. properties. containsKey(" snapshotSuffix" )) {
112113 snapshotSuffix = project. ext. snapshotSuffix
113114 }
114- project. version = getGitVersion(nextVersion, snapshotSuffix, project. projectDir)
115+ if (project. ext. properties. containsKey(" gitDescribeArgs" )) {
116+ gitDescribeArgs = project. ext. gitDescribeArgs
117+ }
118+ project. version = getGitVersion(nextVersion, snapshotSuffix, gitDescribeArgs, project. projectDir)
115119 project. task(' showVersion' ) {
116120 group = ' Help'
117121 description = ' Show the project version'
0 commit comments