Is there any way to define a constant value to Java at compile time

后端 未结 7 997
不知归路
不知归路 2020-12-18 22:59

When I used to write libraries in C/C++ I got into the habit of having a method to return the compile date/time. This was always a compiled into the library so would differe

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-18 23:15

    AFAIK there is not a way to do this with javac. This can easily be done with Ant -- I would create a first class object called BuildTimestamp.java and generate that file at compile time via an Ant target.

    Here's an Ant type that will be helpful.

提交回复
热议问题