Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

build.xml to set date and time as file name

Tags:

ant

phing

behat

I want to set file name with date and time attached to it so I want to create file named as behat-20140913-195915.html however the example below sets the name as behat-yyyymmdd-hhiiss.html. Anyone know the solution to problem?

I followed this example

Note: These two don't work too: ${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>
like image 640
BentCoder Avatar asked Sep 13 '14 17:09

BentCoder


1 Answers

The tstamp task is documented in the ANT manual. It describes how the pattern format comes from the SimpleDateFormat object:

  • http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

I suggest trying the following:

Example

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>

Software versions

$ 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)
like image 104
Mark O'Connor Avatar answered Nov 01 '22 13:11

Mark O'Connor