You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by sukanya <su...@yahoo.co.in> on 2008/07/10 08:32:50 UTC

How to have Dynamic Propert in ant

Hi,

Here is the problem I am now facing:

<project default='init'>
    
    <target name='init'>
            <tstamp>
                    <format property='TSTAMP' pattern='MM/dd/yyyy HH:MM:SS
z'/>
            </tstamp>
            <echo file='Time-Log.txtl' append='yes'> ${TSTAMP}</echo>
            <buildnumber file='${builddeployv3.dir}/build.number'/>
            <echo>ant.version:  '${ant.version}'</echo>
            <echo>ant.home:  '${ant.home}'</echo>
            <echo>java.version:  '${java.version}'</echo>
<echo file='Time-Log.sql' append='yes'> ${TSTAMP}</echo>
    </target>
</project>

Here the time values are added to a file.
Where the file has the same time value twice. But i need to have different
time values with a single <tstamp> element and property. How property values
can be changed dynamically?

Appreciate your suggestion to solve this problem.

Thanks,
Sukanya

-- 
View this message in context: http://www.nabble.com/How-to-have-Dynamic-Propert-in-ant-tp18376782p18376782.html
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


Re: How to have Dynamic Propert in ant

Posted by André Pilz <an...@pcvisit.de>.
Hello,

interesting problem. No dynamic properties. Following works:

<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="test" default="test">
     <target name="test">
	<!-- Sets the value to the current time -->
         <tstamp>
             <format property="NOW" pattern="MM/dd/yyyy HH:mm:ss"/> 

         </tstamp>
         <echo>${NOW}</echo>
         <echo>waiting 5 seconds</echo>
         <sleep seconds="5"/>
         <tstamp>
	        <format property="THEN" pattern="MM/dd/yyyy HH:mm:ss"/>
         </tstamp>
         <echo>${THEN}</echo>
     </target>
</project>

Cheers,
André

sukanya schrieb:
> Hi,
> 
> Here is the problem I am now facing:
> 
> <project default='init'>
>     
>     <target name='init'>
>             <tstamp>
>                     <format property='TSTAMP' pattern='MM/dd/yyyy HH:MM:SS
> z'/>
>             </tstamp>
>             <echo file='Time-Log.txtl' append='yes'> ${TSTAMP}</echo>
>             <buildnumber file='${builddeployv3.dir}/build.number'/>
>             <echo>ant.version:  '${ant.version}'</echo>
>             <echo>ant.home:  '${ant.home}'</echo>
>             <echo>java.version:  '${java.version}'</echo>
> <echo file='Time-Log.sql' append='yes'> ${TSTAMP}</echo>
>     </target>
> </project>
> 
> Here the time values are added to a file.
> Where the file has the same time value twice. But i need to have different
> time values with a single <tstamp> element and property. How property values
> can be changed dynamically?
> 
> Appreciate your suggestion to solve this problem.
> 
> Thanks,
> Sukanya
> 

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


Re: How to have Dynamic Propert in ant

Posted by sukanya <su...@yahoo.co.in>.
Thank you all,

I can able make it by <antcall>

sukanya


glenn opdycke-hansen wrote:
> 
> Use <antcall> (the proper way)
> 
> The following test script demonstrates how antcall can take parameters and
> that the timestamp is recomputed.
> 
> --glenn
> 
> <project name="antcall" default="default">
> 
>  <target name="default">
> 
>   <antcall target="doSomethingElse">
>    
>   </antcall>
> 
>   <antcall target="doSomethingElse">
>    
>   </antcall>
> 
>  </target>
> 
>  <target name="doSomethingElse">
>   <echo message="param1=${param1}"/>
>   <tstamp>
>    <format property="touch.time" pattern="MM/dd/yyyy hh:mm:ss.SSS aa" />
>   </tstamp>
> 
>   <echo>${touch.time}
> </echo>
>  </target>
> 
> </project>
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-set-Dynamic-Property-in-ant-tp18376782p18396429.html
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


Re: How to have Dynamic Propert in ant

Posted by glenn opdycke-hansen <gl...@gmail.com>.
Use <antcall> (the proper way)

The following test script demonstrates how antcall can take parameters and
that the timestamp is recomputed.

--glenn

<project name="antcall" default="default">

 <target name="default">

  <antcall target="doSomethingElse">
   <param name="param1" value="valueA"/>
  </antcall>

  <antcall target="doSomethingElse">
   <param name="param1" value="valueB"/>
  </antcall>

 </target>

 <target name="doSomethingElse">
  <echo message="param1=${param1}"/>
  <tstamp>
   <format property="touch.time" pattern="MM/dd/yyyy hh:mm:ss.SSS aa" />
  </tstamp>

  <echo>${touch.time}
</echo>
 </target>

</project>

Re: How to have Dynamic Propert in ant

Posted by "Scot P. Floess" <fl...@mindspring.com>.
True, however, unless the timestamp is recomputed it won't matter... 
Meaning the timestamp will be the same for each use of the property 
containing the initially computed timestamp.

On Thu, 10 Jul 2008, Andrew Clegg wrote:

> Or use variables from ant-contrib...
>
> Andrew.
>
> 2008/7/10 Scot P. Floess <fl...@mindspring.com>:
>> Properties are immutable in Ant.  In your example, even if properties were
>> mutable, the timestamp would not be recomputed - you'd have to re-execute
>> the tstamp task.  The only way you can have this recomputation is by using a
>> second property as someone else has responded...
>>
>> On Wed, 9 Jul 2008, sukanya wrote:
>>
>>>
>>> Hi,
>>>
>>> Here is the problem I am now facing:
>>>
>>> <project default='init'>
>>>
>>>   <target name='init'>
>>>           <tstamp>
>>>                   <format property='TSTAMP' pattern='MM/dd/yyyy HH:MM:SS
>>> z'/>
>>>           </tstamp>
>>>           <echo file='Time-Log.txtl' append='yes'> ${TSTAMP}</echo>
>>>           <buildnumber file='${builddeployv3.dir}/build.number'/>
>>>           <echo>ant.version:  '${ant.version}'</echo>
>>>           <echo>ant.home:  '${ant.home}'</echo>
>>>           <echo>java.version:  '${java.version}'</echo>
>>> <echo file='Time-Log.sql' append='yes'> ${TSTAMP}</echo>
>>>   </target>
>>> </project>
>>>
>>> Here the time values are added to a file.
>>> Where the file has the same time value twice. But i need to have different
>>> time values with a single <tstamp> element and property. How property
>>> values
>>> can be changed dynamically?
>>>
>>> Appreciate your suggestion to solve this problem.
>>>
>>> Thanks,
>>> Sukanya
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/How-to-have-Dynamic-Propert-in-ant-tp18376782p18376782.html
>>> 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
>>>
>>>
>>
>> Scot P. Floess
>> 27 Lake Royale
>> Louisburg, NC  27549
>>
>> 252-478-8087 (Home)
>> 919-754-4592 (Work)
>>
>> Chief Architect JPlate   http://sourceforge.net/projects/jplate
>> Chief Architect JavaPIM  http://sourceforge.net/projects/javapim
>>
>> Architect Keros          http://sourceforge.net/projects/keros
>>
>> ---------------------------------------------------------------------
>> 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
>
>

Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087 (Home)
919-754-4592 (Work)

Chief Architect JPlate   http://sourceforge.net/projects/jplate
Chief Architect JavaPIM  http://sourceforge.net/projects/javapim

Architect Keros          http://sourceforge.net/projects/keros

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


Re: How to have Dynamic Propert in ant

Posted by Andrew Clegg <an...@gmail.com>.
Or use variables from ant-contrib...

Andrew.

2008/7/10 Scot P. Floess <fl...@mindspring.com>:
> Properties are immutable in Ant.  In your example, even if properties were
> mutable, the timestamp would not be recomputed - you'd have to re-execute
> the tstamp task.  The only way you can have this recomputation is by using a
> second property as someone else has responded...
>
> On Wed, 9 Jul 2008, sukanya wrote:
>
>>
>> Hi,
>>
>> Here is the problem I am now facing:
>>
>> <project default='init'>
>>
>>   <target name='init'>
>>           <tstamp>
>>                   <format property='TSTAMP' pattern='MM/dd/yyyy HH:MM:SS
>> z'/>
>>           </tstamp>
>>           <echo file='Time-Log.txtl' append='yes'> ${TSTAMP}</echo>
>>           <buildnumber file='${builddeployv3.dir}/build.number'/>
>>           <echo>ant.version:  '${ant.version}'</echo>
>>           <echo>ant.home:  '${ant.home}'</echo>
>>           <echo>java.version:  '${java.version}'</echo>
>> <echo file='Time-Log.sql' append='yes'> ${TSTAMP}</echo>
>>   </target>
>> </project>
>>
>> Here the time values are added to a file.
>> Where the file has the same time value twice. But i need to have different
>> time values with a single <tstamp> element and property. How property
>> values
>> can be changed dynamically?
>>
>> Appreciate your suggestion to solve this problem.
>>
>> Thanks,
>> Sukanya
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-have-Dynamic-Propert-in-ant-tp18376782p18376782.html
>> 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
>>
>>
>
> Scot P. Floess
> 27 Lake Royale
> Louisburg, NC  27549
>
> 252-478-8087 (Home)
> 919-754-4592 (Work)
>
> Chief Architect JPlate   http://sourceforge.net/projects/jplate
> Chief Architect JavaPIM  http://sourceforge.net/projects/javapim
>
> Architect Keros          http://sourceforge.net/projects/keros
>
> ---------------------------------------------------------------------
> 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


Re: How to have Dynamic Propert in ant

Posted by "Scot P. Floess" <fl...@mindspring.com>.
Properties are immutable in Ant.  In your example, even if properties were 
mutable, the timestamp would not be recomputed - you'd have to re-execute 
the tstamp task.  The only way you can have this recomputation is by using 
a second property as someone else has responded...

On Wed, 9 Jul 2008, sukanya wrote:

>
> Hi,
>
> Here is the problem I am now facing:
>
> <project default='init'>
>
>    <target name='init'>
>            <tstamp>
>                    <format property='TSTAMP' pattern='MM/dd/yyyy HH:MM:SS
> z'/>
>            </tstamp>
>            <echo file='Time-Log.txtl' append='yes'> ${TSTAMP}</echo>
>            <buildnumber file='${builddeployv3.dir}/build.number'/>
>            <echo>ant.version:  '${ant.version}'</echo>
>            <echo>ant.home:  '${ant.home}'</echo>
>            <echo>java.version:  '${java.version}'</echo>
> <echo file='Time-Log.sql' append='yes'> ${TSTAMP}</echo>
>    </target>
> </project>
>
> Here the time values are added to a file.
> Where the file has the same time value twice. But i need to have different
> time values with a single <tstamp> element and property. How property values
> can be changed dynamically?
>
> Appreciate your suggestion to solve this problem.
>
> Thanks,
> Sukanya
>
> -- 
> View this message in context: http://www.nabble.com/How-to-have-Dynamic-Propert-in-ant-tp18376782p18376782.html
> 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
>
>

Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087 (Home)
919-754-4592 (Work)

Chief Architect JPlate   http://sourceforge.net/projects/jplate
Chief Architect JavaPIM  http://sourceforge.net/projects/javapim

Architect Keros          http://sourceforge.net/projects/keros

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