当你引用ant时,我假设你使用的是Java.您可以将tstamp任务和echo用于属性文件.此属性文件可以捆绑到jar中,以便应用程序可以读取属性并根据需要显示值.
例如:
<target name="build.timestamp">
<tstamp>
<format property="build.timestamp" pattern="yyyy.MM.dd-hh.mm.ss" locale="en,UK"/>
</tstamp>
<echo message="tstamp=${build.timestamp}" file="build-timestamp.properties"/>
</target>
Run Code Online (Sandbox Code Playgroud)
这将在当前ant目录中创建build-timestamp.properties.将其作为常规资源文件与应用程序类一起使用,以便在应用程序运行时可用.