Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to escape double quotes while executing on command line through gradle?

Tags:

git

gradle

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?

like image 969
Bhoot Avatar asked Sep 26 '22 15:09

Bhoot


2 Answers

I guess it should be:

commandLine 'git', 'describe', '--tags', '--long', '--match', 'v[0-9]*'
like image 105
Opal Avatar answered Sep 30 '22 01:09

Opal


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.

like image 25
René Höhle Avatar answered Sep 30 '22 00:09

René Höhle