ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject RE: getting a macro attribute in a script
Date Mon, 08 Mar 2004 06:51:08 GMT
If you want to work with <script> you have to initialize your variable.

<script>
    myvar = "@myattribute";
</script>


And especially for working with <macrodef> Peter has done an Entry [1] in
Bugzilla about local properties, which could also be helpful.


Jan

[1] http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23942


> -----Original Message-----
> From: Jacob Kjome [mailto:hoju@visi.com]
> Sent: Sunday, March 07, 2004 8:23 AM
> To: Ant Users List
> Subject: RE: getting a macro attribute in a script
> 
> 
> 
> Yep, you can use the value of an attribute as a property.  
> Generally, this 
> should be unique.  As such, you can set these properties to 
> your hearts 
> desire and make your macrodef totally reusable..
> 
> http://marc.theaimsgroup.com/?l=ant-dev&m=107026918307636&w=2
> 
> Note that the discussion there was slightly before the 
> current behavior of 
> macrodef became approved for 1.6.0.  Peter's example will 
> work with 1.6.0+.
> 
> 
> Jake
> 
> At 01:25 PM 3/6/2004 -0800, you wrote:
> >The problem is I want to use the macro several times, each 
> time with a 
> >different config.file attribute.  This means that I cant use 
> a property.
> >
> >Is there a way to get at the macro attribute from within the script 
> >without using a property?
> >
> >-----Original Message-----
> >
> >If you mean you want to set the value of the config_file 
> property then try 
> >this
> >
> ><property name="config_file" value="@{config.file}"/>
> >
> >but better would be to use the @{config.file} where you need 
> it in the 
> >macro and avoid the
> >property all together.
> >
> >Remember properties are immutable once set they cannot be reset.
> >
> >Thanks.  Bill
> >
> >Bill Rich
> >Wilandra Consulting LLC
> >1325 Addiewell Place
> >San Jose, CA  95120-3905
> >phone:      +1 408 268-2452
> >mobile:     +1 408 410-9713
> >Santa Cruz: +1 831 464-9007
> >fax:        +1 413 669-9716
> >billrich@wilandra.com or billrich@attglobal.net
> >http://www.wilandra.com
> >
> >-----Original Message-----
> >From: Sean Bridges [mailto:sbridges@smgtec.com]
> >Sent: Friday, March 05, 2004 5:38 PM
> >To: user@ant.apache.org
> >Subject: getting a macro attribute in a script
> >
> >
> >How do you get the value of a macro's attribute from within a script.
> >
> >My build file looks like,
> >
> >             <macrodef name="replaceClientConfig"
> >id="replaceClientConfig_id">
> >                         <attribute name="config.file"/>
> >                         <sequential>
> >                                     <script language="javascript">
> >
> >                                                 <![CDATA[
> >
> >                                                 //echo =
> >project.createTask("echo");
> >
> >//echo.setMessage(replaceClientConfig_id.toString());
> >                                                 //echo.perform();
> >
> >                                                 config_file  = ???
> >
> >
> >I want to set the config_file variable to the value of the 
> config.file
> >attribute.
> >
> >Thanks,
> >
> >Sean
> >
> >
> >
> >
> >
> >---------------------------------------------------------------------
> >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
> 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message