On 30/05/2010 11:27 AM, Bruce Atherton wrote:
<exec spawn="false" resultproperty="result" failonerror="false" ...>
I realized that I screwed up two ways with this answer. First, my
intention was 'resultproperty="${result}"' rather than as written. But
this won't work either because the PropertyHelper will just give back
the literal string when the setter is called. In fact, as far as I know
there is no way for PropertyHelper to pass a null to a setter. Somebody
correct me if this is wrong.
So there are two other ways I can see to do this. You could write a
PropertyHelper delegate that could return a null rather than the
original string, probably using an additional marker character so you
still got the original behaviour elsewhere. So you might write
'resultproperty="${#result}"' and have a property helper interpret that
and return null if necessary.
Probably a simpler solution is to use Antcall. Then you can go back to
your original macrodef with both spawn and resultproperty, but do an
Antcall with parameters for the spawn and the result. Something like this:
<macrodef name= ...>
<attribute name="spawn" default="false"/>
<attribute name="resultproperty" default="false"/>
<sequential>
<local name="one-param-set" />
<local name="use-result" />
<condition property="use-result">
<not>
<or>
<equals arg1="@{resultproperty}" arg2="false"
casesensitive="false" />
<equals arg1="@{resultproperty}" arg2="off" casesensitive="false"
/>
<equals arg1="@{resultproperty}" arg2="no" casesensitive="false"
/>
</or>
</not>
</condition>
<condition property="one-param-set">
<or>
<istrue value="@{spawn}" />
<isset property="use-result" />
</or>
</condition>
<antcall target="exec-command" inheritAll="false">
<param name="spawn" value="@{spawn}" />
<param name="use-result" value="${use-result}" />
<param name="resultproperty" value="@{resultproperty}" />
<param name="one-param-set" value="${one-param-set}" />
</antcall>
</sequential>
</macrodef>
<target name="exec-spawn-command" if="${spawn}">
<exec spawn="true" ... />
</target>
<target name="exec-result-command" if="${use-result}" unless="${spawn}">
<exec resultproperty="${resultproperty}" />
</target>
<target name="exec-command" depends="exec-spawn-command,exec-result-command"
unless="${one-param-set}">
<exec ... /> <!-- with no resultproperty or spawn -->
</target>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@ant.apache.org