开发者

pass "git describe" output to Java code

开发者 https://www.devze.com 2023-03-18 01:58 出处:网络
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 Eclips

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
0

精彩评论

暂无评论...
验证码 换一张
取 消