ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fred Welland <fwell...@intelixinc.com>
Subject How Do I do conditionally set a prop (not OS specific prop).
Date Thu, 29 Mar 2001 14:05:46 GMT
I have a Exec target like the follwoing:

<target name="my_target">
    <property name="my_path" refid="some.other.path"/>
    <exec    dir="${outdir}"
                   excutable="${my_bin}/my_prog"
                   failonerror="yes">
                    <arg line="-debug -p ${my_path} parm1 parm2"/>
    </exec>
</target>\

I would like to conditionally include the "-debug" flag.   I am already
using a props file where we have a property called "be_verbose" which is
used  on delete tasks (e.g <delete verbose="${be_verbose}" ..../>).  I
would like this property to controll the inclusion of the -debug flag on
the exec arg line.

Here is a pseudo ANT target that expresses what I would like:

<target name="my_target">
    <property name="my_path" refid="some.other.path"/>
    <available name="cmdline" value="-debug -p ${my_path} parm1 parm2"
when="${be_verbose}==true"/>
    <available name="cmdline" value="-p ${my_path} parm1 parm2"
when="${be_verbose}==false"/>
    <exec    dir="${outdir}"
                   excutable="${my_bin}/my_prog"
                   failonerror="yes">
                    <arg line="${cmdline}"/>
    </exec>
</target>


I have made up  the "when" attribute to the available task such that the
prop is set when the expression is 'true' (or maybe have two value
attributes like truevalue="..." falevalue="..." or something like
that).  NOTE:  This is not really a feature request -  but the 'when'
attribute does sound like it could add some value.  Hmm...is there some
other task that does this kind of thing?

With ant 1.3 is there anyway to do something like (using vanialla ant  -
no special tasks, no preprocessing scripts, and low on the hack scale)?

On a related note:  how does the 'resource' attribute of available
work?  The docs don't provide an examples and just state "the resource
to look for in the JVM".  Could that be a property or some other
'thing'?  Anybody got an example of using this attribute?

Thanks in advance,

Fred Welland












Mime
View raw message