Ant multi OS <exec> advice  
Author Message
Meetlint





PostPosted: 2005-4-8 1:23:00 Top

java-programmer, Ant multi OS <exec> advice Hi,

I have the following Ant code which I would like to also use on Linux:

<target name="build.XmlJaxb">
<exec dir="${checkout.dest}/XmlJaxb" executable="cmd">
<arg line="/C ant -logger org.apache.tools.ant.XmlLogger
-logfile ant_log_dist.xml dist" />
</exec>
</target>

For Linux I woul dneed to replace "cmd" and "/C" with "bash" or something?

I know there is the <exec> OS option but then I would need to copy the
<exec> tags with a Windows and Linux version. Gives maintenance errors.

I know I could make variables for "cmd" and "/C" and use the <if>
contrib to look at the os Java system property.

I cannot use <ant> task because I do not seem to be able to specify the
Xml logger and the output file.

any ideas?

thanks,
Peter
 
darrell





PostPosted: 2005-4-9 0:15:00 Top

java-programmer >> Ant multi OS <exec> advice On Thu, 7 Apr 2005, Meetlint wrote:

> Hi,
>
> I have the following Ant code which I would like to also use on Linux:
>
> <target name="build.XmlJaxb">
> <exec dir="${checkout.dest}/XmlJaxb" executable="cmd">
> <arg line="/C ant -logger org.apache.tools.ant.XmlLogger
> -logfile ant_log_dist.xml dist" />
> </exec>
> </target>
>
> For Linux I woul dneed to replace "cmd" and "/C" with "bash" or something?
>
> I know there is the <exec> OS option but then I would need to copy the
> <exec> tags with a Windows and Linux version. Gives maintenance errors.
>
> I know I could make variables for "cmd" and "/C" and use the <if>
> contrib to look at the os Java system property.
>
> I cannot use <ant> task because I do not seem to be able to specify the
> Xml logger and the output file.
>
> any ideas?

I usually do something like:

<condition property="cmd" value="cmd.exe>
<os family="windows"/>
</condition>
<property name="cmd" value="bash"/>

Now I can use ${cmd} for the executable. I can do the same thing for the
command line arguments.

The way it works is, if the condition (os family="windows") is true then
cmd=cmd.exe. The <property> tag will do nothing if cmd is already set. If
the condition is false then the <property> tag will set cmd=bash.

--
Send e-mail to: darrell dot grainger at utoronto dot ca