• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Properties are not variables

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mike or anyone else,

I know that properties are not variables, but what do you do when you want a variable? I have sometimes been able use <property> nested inside an <ant> task, but this is not always ideal.

Any suggestions are appreciated. Or an explanation of why Ant does not support variables.

Thanks,
Mark
[ September 22, 2004: Message edited by: Mark Binau ]
 
author
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, properties are different than variables in the sense that properties are immutable. Once a property has been set, it cannot be changed.

Can you give a specific example where you want a property to act like a variable?

Mike
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Once you add variables, you need to add facilities to manipulate them, and then you have a scripting language. The Ant build file is meant to be declarative. I believe Mike pointed out in another topic that Groovy might fill that need (please correct me if I am mis-speaking).
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Without knowing what you want to do, it's hard to say how to do it...

BTW, Ant 2 is likely to have mutable (variable-like) properties, as far as I know.
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is one option that can be used in Ant, antcall
It allows modification of a param property.
However, please use it caution and sparingly.

Below is taken from

http://ant.apache.org/manual/CoreTasks/antcall.html

Examples

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

<target name="doSomethingElse">
<echo message="param1=${param1}"/>
</target>


Will run the target 'doSomethingElse' and echo 'param1=value'.

<antcall ... >
<reference refid="path1" torefid="path2"/>
</antcall>
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Notice that antcall creates a new project instance, though. That is,

<target name="init">
<echo message="init"/>
</target>

<target name="default" depends="init">
<antcall target="doSomethingElse">
<param name="param1" value="value"/>
</antcall>
</target>

<target name="doSomethingElse" depends="init">
<echo message="param1=${param1}"/>
</target>

will execute init *twice*. It's typically better to use 1.6 macros.
 
reply
    Bookmark Topic Watch Topic
  • New Topic