Listing 2 A script to archive log files then send the same files by mail
<project name="example2" default="Archive" >
<property file="default.properties"/>
<target name="Archive" description="Archive and send mail" >
<!-- Init-->
<tstamp prefix="today"/>
<delete dir="${log.dir}" />
<mkdir dir="${log.dir}/${today.DSTAMP}" />
<!-- Copy and rewrite names -->
<copy toDir="${log.dir}/${today.DSTAMP}">
<fileset dir="${log.tree}" includes= "**/*.log"/>
<chainedmapper>
<flattenmapper/>
<globmapper from="*.log" to="*_${today.DSTAMP}.log" />
</chainedmapper>
</copy>
<!-- Zip file -->
<zip zipfile="${log.dir}/logs_${today.DSTAMP}.zip"
basedir="${log.dir}/${today.DSTAMP}"/>
<!-- Call another method which uses the property mail.message -->
<property name="mail.message" value="Have a nice day \
${today.TODAY}" />
<ant antfile="example1.xml"/>
<echo message="${mail.message}" />
</target>
</project>
|