You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Michael Böckling <mi...@giniality.com> on 2006/01/16 14:03:08 UTC

Variable number of parameters for a task

Hi,

I have a situation where I don't know whether or not a property is set 
at runtime.
As we all know, if a property is not set, its literal value is passed.

Example:
<someTask var1="${var1}" var2="${var2}"/>

I don't know beforehand if ${var2} is set at runtime or not, so 
sometimes the literal "${var2}" is passed to the task, which I want to 
avoid.

Maybe I can use conditionals to set a property to null (which would be 
ok) if it is not set (Is there a way to set a property to null?!)?
Does anyone know a solution to this problem?

Would be really great if anyone could help me!

Bye,
    Michael


P.S.: I searched the archives, but couldn't find the answer to my 
problem... Sorry if this one is getting asked regularly.

-- 
Giniality AG - Michael Böckling; Steinenberg 21, CH-4051 Basel
P: +41 61 226 99 63 - F: +41 61 226 99 69
michael.boeckling@giniality.ch; http://www.giniality.com/



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


Re: Variable number of parameters for a task

Posted by Petar Tahchiev <pa...@gmail.com>.
On 16/01/06, Michael Böckling <mi...@giniality.com> wrote:
>
> Hi,
>
> I have a situation where I don't know whether or not a property is set
> at runtime.
> As we all know, if a property is not set, its literal value is passed.
>
> Example:
> <someTask var1="${var1}" var2="${var2}"/>
>
> I don't know beforehand if ${var2} is set at runtime or not, so
> sometimes the literal "${var2}" is passed to the task, which I want to
> avoid.
>
> Maybe I can use conditionals to set a property to null (which would be
> ok) if it is not set (Is there a way to set a property to null?!)?
> Does anyone know a solution to this problem?
>
> Would be really great if anyone could help me!
>
> Bye,
>     Michael
>
>
> P.S.: I searched the archives, but couldn't find the answer to my
> problem... Sorry if this one is getting asked regularly.
>
> --
> Giniality AG - Michael Böckling; Steinenberg 21, CH-4051 Basel
> P: +41 61 226 99 63 - F: +41 61 226 99 69
> michael.boeckling@giniality.ch; http://www.giniality.com/
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
You can use the "if" or "unless" attributes of a target - in that case
targets will be executed only if a property is set(not set). Example:

<target name="build-module-A" if="module-A-present"/>

Also you can use conditionals, as you said. Example(Something like this):

<condition property="your_property_to_set">
      <and>
                 <isset property="property_to_check" />
                 <not>
                       <isset property="your_property_to_check" />
                 </not>
      </and>
</condition>*
*
--

Regards, Petar!

Re: Variable number of parameters for a task

Posted by Stefan Bodewig <bo...@apache.org>.
On Mon, 16 Jan 2006, Michael <mi...@giniality.com> wrote:

> Maybe I can use conditionals to set a property to null (which would
> be ok) if it is not set (Is there a way to set a property to
> null?!)?

No, but will an empty string work as well?  If so, just use <property>
to set it.  If the property has been set, the value won't get
overridden.

Stefan

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