pass "git describe" output to Java code
Is there a way to pass the output of git de开发者_StackOverflow中文版scribe --tag
to my Java application at compile time? I'd like to use that in my about box to display version info. I'm using Eclipse to build, but I can use ant if necessary.
With C code, I can pass -D'REV="$(shell git describe --tag)"'
to my gcc compiler, and my code can pick that up. I'm hoping there's something similar in Java.
If ant
is acceptable, it supports a similar command line option.
As a concrete example, this line in an ant
script
<echo>property: ${property}</echo>
when invoked with the following command,
$ ant -Dproperty="$(git --version)"
produces the following output on the console,
[echo] property: git version 1.7.5.4
精彩评论