如何使用build.xml创建一个名称由创建日期和时间组成的文件。示例:25.03.19_15:40.jar
这可以使用tstamp Ant任务完成,例如:
<target name="test.timestamp">
<!-- create a timestamp with the specified format -->
<tstamp>
<format property="now" pattern="yyyy-MM-dd_hh-mm"/>
</tstamp>
<!-- create an empty jar file (except for the manifest) with the generated name -->
<jar destfile="${now}.jar" basedir="." excludes="**/*" filesonly="true"/>
</target>
请注意,在示例中,日期格式使用-
而不是:
,因为文件名中的冒号在Windows操作系统上无效。