Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java
Expertise: Intermediate
Jan 26, 2004

Build Output Using the Ant <tstamp/> Task

When you execute <tstamp/>, it generates the local ANT macros ${TSTAMP} and ${DSTAMP}. These are the time and date as numeric strings. They can then be used to dynamically generate timestamp strings. Here is an example in a simple ANT buildfile that generates a timestamped jarfile:

<?xml version="1.0"?>

<project name="tstamp" basedir="." default="jar">
    <property name="src"   value="src"/>
    <property name="obj"   value="obj"/>
	<property name="jar"   value="tstamp"/>

	<target name="clean">
		<delete file="${jar}.jar"/>
		<delete dir="${obj}"/>
		<delete dir="${doc}"/>
	</target>

    <target name="compile">
        <javac srcdir="${src}" destdir="${obj}" source="1.4" debug="true"
deprecation="true" />
    </target>

    <target name="jar" depends="compile">
		<tstamp/>
        <jar jarfile="${jar}-${DSTAMP}${TSTAMP}.jar" compress="true">
			<fileset dir="${obj}" includes="**/*"/>
			<fileset dir="${src}" includes="**/*"/>
        </jar>
    </target>
</project>
The above build.xml outputs a jarfile named 'tstamp-200307011540.jar'
David Howard
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date