ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rebhan, Gilbert" <Gilbert.Reb...@huk-coburg.de>
Subject RE: How can I override property value?
Date Tue, 24 Jun 2008 07:18:19 GMT

-----Original Message-----
From: Simple Easy [mailto:random_simple_easy@yahoo.com] 
Sent: Monday, June 23, 2008 5:53 AM
To: user@ant.apache.org
Subject: How can I override property value?
/*
Hi,
I would like to override the property value entered by <INPUT> task. How
can I go about doing that?
*/

/*
<property name="version" value="" />
*/

that's wrong if you want to fill the version property with <input> task
in ant properties are normally immutable after they have been set
so here ${version} would be "" as it doesn't get overwritten with
<input>

instead you simply create and fill the version property with <input>
task

/*
<input message="Please enter the version number:" addproperty="version"
/>
*/

overwriting properties =
beside the <var> task from antcontrib, you may use the <script> task
combined
with a VM / BSF compatible language and use the ant api, f.e.

<project name="bla" default="main" basedir=".">

<target name="depends">
<input message="Please enter version :" addproperty="version"/>
 <echo>$${version} == ${version}</echo>
</target>

<target name="main" depends="depends">
  <script language="ruby">
  <![CDATA[
   a = ['v_2_3_4','v_1_2_2','v_1_2_3']    
   $project.setProperty "version", a[rand(a.size)]
  ]]>
  </script
  <echo>$${version} == ${version}</echo>
</target>

depends:
     [echo] ${version} == v_4_5_6_7
main:
     [echo] ${version} == v_2_3_4
BUILD SUCCESSFUL


Regards, Gilbert




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


Mime
View raw message