ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkhanna01 <dkhann...@yahoo.co.in>
Subject Re: TImestamping in ANT
Date Thu, 26 Jul 2007 15:36:43 GMT

first of all thanks for the information 

I tried to load antx libraries and it did worked, BUT while calculating the
duration its giving me an error as :

Unable to convert 'now' to time duration.
compile took -now

Here is my code:

<target name="usage" description="Displays a list of valid targets">
        <assign var="time" value="now"/>
        <copyproperty name="usage.start" variable="time"
transform="datetime"/>
        <echo level="info" message="usage started ${usage.start}"/>

        <antcall target="usage:default"/>

        <assign var="time" value="now"/>
        <copyproperty name="compile.duration" variable="time"
transform="duration"/>

        <echo level="info" message="compile took ${compile.duration}"/>
    </target>

Is there any thing I have missed.

THanks again




Wascally Wabbit wrote:
> 
> Hi,
> 
> The assign task is already defined for you as part of the
> AntXtras antlib. The easiest thing to do is to load the
> entire antlib and experiment. *See the Quick Start and
> User Guide for additional information*.
> 
> Example (assuming at least Ant 1.6.5, and AntXtras bin download
> to some local directory '${antextensions.d}/antx'):
> 
> [Top-Level]
> 
>    <path id="antx.classpath">
>      <fileset dir="${antextensions.d}/antx">
>        <include name="lib/*.jar"/>
>      </fileset>
>    </path>
> 
>    <taskdef resource="com/idaremedia/antx/install/antlib.xml"
>       classpathref="antx.classpath"/>
> 
> 
> [In any target or macrodef]
>     <assign var="duration" value="now"/>
>     ...
>     <assign var="duration" value="-now" .../>
>     ...
> 
> -The Wabbit
> 
> 
> dkhanna01 wrote:
>> Hi 
>> I downloaded the antxtras unility from the site but the two jar files in
>> that does not contain class file for assign task. SO when I try to run my
>> script after adding assing task it gave an error that " Problem: failed
>> to
>> create task or type assign"
>> 
>> THanks
>> 
>> 
>> Wascally Wabbit wrote:
>>> dkhanna01 wrote:
>>>> I need to find out the time taken by each of the process/target in our
>>>> build.xml file. Now for doing this I have use ANT tstamp task to
>>>> calculate
>>>> the start time and end time of the process. Now my question is how do I
>>>> find
>>>> out the total time taken by the process, I mean is there any way to
>>>> calculate difference between "End time" and "Start time" 
>>>>
>>>> Thanks
>>> If you can use thirdparty libraries you can use the AntXtra's
>>> <assign> task like so:
>>>
>>> <target name="compile" depends="-init" description="Compile stuff">
>>>    <assign var="time" value="now"/>
>>>    ...[all your compiling tasks here]
>>>    <assign var="time" value="-now" transform="duration"
>>>       copyproperty="compile.duration"/>
>>>    <echo level="info" message="compile took ${compile.duration}"/>
>>> </target>
>>>
>>> If you want to do this for lots of your targets you can leverage
>>> macrodefs to do this for every target using something like:
>>>
>>> <macrodef name="timedtarget">
>>>    <attribute name="name">
>>>    <attribute name="functions"/>
>>>    <sequential>
>>>      <assign var="time_" value="now"/>
>>>      <callinline targets="@{functions}"/> <!--do NOT switch projects-->
>>>      <assign var="time_" value="-now" transform="duration"
>>>         copyproperty="@{name}.duration"/>
>>>      <echo level="info" message="@{name} took ${@{name}.duration}"/>
>>>    </sequential>
>>> </macrodef>
>>>
>>> Then use it like so:
>>>
>>> <target name="-compile">
>>>     ...[all your compiling work here in private target]
>>> </target>
>>>
>>> <target name="compile" depends="-init" description="Compile stuff">
>>>    <timetarget name="compile" functions="-compile"/>
>>> </target>
>>>
>>> AntXtras is at: http://antxtras.sf.net/
>>>
>>> Hope that helps.
>>>
>>> -The Wabbit
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>> For additional commands, e-mail: user-help@ant.apache.org
>>>
>>>
>>>
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/TImestamping-in-ANT-tf4050746.html#a11813104
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message