我想设置带有日期和时间的文件名,所以我想创建名为behat-20140913-195915.html
的文件,但下面的示例将名称设置为behat-yyyymmdd-hhiiss.html
。有人知道这个问题的解决方法吗?
我以为例
注意:这两个也不起作用:${DSTAMP} ${TSTAMP}
<?xml version="1.0" encoding="UTF-8"?>
<project name="Sport" default="build-default" basedir=".">
<tstamp>
<format property="TODAY_MY" pattern="yyyymmdd-hhiiss" locale="en,UK" />
</tstamp>
<target name="build" description="Runs everything in order ..." depends="behat-bdd" />
<target name="behat">
<echo msg="Running Behat tests ..." />
<exec logoutput="true" checkreturn="true"
command="bin/behat -f progress --format html --out ${dir-report}/behat-${TODAY_MY}.html" dir="./" />
</target>
</project>
tstamp任务记录在ANT手册中。它描述了模式格式如何来自SimpleDateFormat对象:
- http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
我建议尝试以下方法:
示例
Buildfile: build.xml
build:
[echo] date: 20140913-203419
build.xml
<project name="demo" default="build">
<tstamp>
<format property="TODAY_MY" pattern="yyyyMMdd-HHmmss" locale="en,UK" />
</tstamp>
<target name="build">
<echo message="date: ${TODAY_MY}"/>
</target>
</project>
软件版本
$ ant -v
Apache Ant(TM) version 1.9.4 compiled on April 29 2014
$ java -version
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)