5

I am trying to include my application's version through git using gradle build system. I want to run the following command to get the version info from git:

git describe --tags --match "v[0-9]*"

After reading the reference from here, I am using the following gradle syntax:

commandLine 'git', 'describe', '--tags', '--long', '--match "v[0-9]*"'

but it gives error in execution.

error: unknown option `match v[0-9]*'

I have tried escaping the double quote with backslash, but that does not work either. Can someone please point me towards a correct way of executing above command through gradle?

Community
  • 1
  • 1
Bhoot
  • 2,614
  • 1
  • 19
  • 36

2 Answers2

3

I guess it should be:

commandLine 'git', 'describe', '--tags', '--long', '--match', 'v[0-9]*'
Opal
  • 81,889
  • 28
  • 189
  • 210
1

I think '--match "v[0-9]*"' the version number should be part of the command. So you can put them in an own section something like this:

commandLine 'git', 'describe', '--tags', '--long', '--match', 'v[0-9]*'

https://docs.gradle.org/current/dsl/org.gradle.api.tasks.Exec.html

When you look here at the description

commandLine The full command line, including the executable plus its arguments.

René Höhle
  • 26,716
  • 22
  • 73
  • 82