You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by st...@sungard.com on 2004/11/10 12:38:29 UTC
How does interpret an empty output property
Hi,
I have a macrodef passing on a logfile attribute to exec's output
property. If I want as default to have no logfile, how do write this in
the macrodef? The easiest logic for me would be if output="" means no
redirection as I then could use <attribute name="logfile" default=""/>.
Sten Rosendahl
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: How does interpret an empty output property
Posted by Peter Reilly <pe...@apache.org>.
The exec task does not process the string. Ant's core code
converts the string to a File object - in this case an empty string
will get converted to the base dir.
So with:
<project default="t">
<target name="t">
<exec executable="ls" output=""/>
</target>
</project>
one gets:
/home/preilly/learning/a/exec/build.xml:3: Execute failed:
java.io.FileNotFoundException: /home/preilly/learning/a/exec (Is a
directory)
One may one the ant-contribs's <if/> task to implement the logic.
Peter
sten.rosendahl@sungard.com wrote:
>Hi,
>
>I have a macrodef passing on a logfile attribute to exec's output
>property. If I want as default to have no logfile, how do write this in
>the macrodef? The easiest logic for me would be if output="" means no
>redirection as I then could use <attribute name="logfile" default=""/>.
>
>Sten Rosendahl
>
>---------------------------------------------------------------------
>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
Re: How does interpret an empty output property
Posted by Matt Benson <gu...@yahoo.com>.
--- sten.rosendahl@sungard.com wrote:
[SNIP]
> I have a macrodef passing on a logfile attribute to
> exec's output
> property. If I want as default to have no logfile,
> how do write this in
> the macrodef?
[SNIP]
If you have a fairly limited number of platforms to
work on, like Un*x vs. dos-based (Windows etc.), you
could do something like this:
<target name="foo" depends="defaultlogfile">
<!-- do something with ${logfile} -->
</target>
<target name="defaultlogfile">
<condition property="logfile" value="/dev/null">
<os family="unix" />
</condition>
<condition property="logfile" value="NUL">
<or>
<os family="windows" />
<!-- should work on netware as well -->
<os family="netware" />
</or>
</condition>
<fail unless="logfile" />
</target>
>
> Sten Rosendahl
-Matt
__________________________________
Do you Yahoo!?
Check out the new Yahoo! Front Page.
www.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org