1

Is there a way to pass the output of git describe --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.

1
  • @Dustin: It looks like a valid compiler option for gcc. Commented Jul 7, 2011 at 4:45

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

2 Comments

Looks like a good solution. That would allow me to use System.getProperty to read the -D value?
Not directly; using the example above, you could add the value named property to your java task as a runtime parameter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.