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

后端 未结 7 967
不知归路
不知归路 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:30

    One suggestion I got from a co-worker was to get the ant file to create a file on the classpath and to package that into the JAR and have it read by the method. ... To my mind that's a hack and could be circumvented/broken by someone having a similarly named file outside the JAR, but on the classpath.

    I'm not sure that getting Ant to generate a file is a terribly egregious hack, if it's a hack at all. Why not generate a properties file and use java.util.Properties to handle it?

    0 讨论(0)
提交回复
热议问题