Hello, I have a problem I am trying to solve that I need some help with. What I'd like to do is check for the availability of an executable tool on the system path. If the tool is available, then allow extra (secret sauce) features to be enabled. Otherwise the extra (non-essential) build features are disabled. My thought was to use exec to determine if the tool exists. If someone has a better way, please let me know. So below you will see an attempt to use exec, and if it fails, set a property, and check for that property down stream. Unfortunately I get very bizzare results. FIRST ISSUE First, the state of the errorproperty makes no sense to me. Given the following example, when dot is not available, the script says it is. I would have thought that if there were an error, it would always be set. Therefore other tasks should use the "unless" syntax. But the opposite is true. This seems inconsistent with how the rest of Ant works. Try this fragment out! <target name="check-for-dot"> <exec executable="dot" failonerror="false" failifexecutionfails="false" errorproperty="dot.is.available"> <arg value="-help"/> </exec> </target>
<target name="do-dot" depends="check-for-dot" unless="dot.is.available"> <echo message="dot is available"/> </target> > ant -f make-dot.xml Buildfile: make-dot.xml check-for-dot: [exec] Execute failed: java.io.IOException: CreateProcess: dot -help error=2 do-dot: [echo] dot is available This result makes no sense. SECOND ISSUE Second, notice that nasty little "Execute failed" stuff? I want to supress it, but no matter what property I set in the exec task, the output (or something similar) still comes screaming through. I know exec may fail, I am doing this on purpose. So I want to tell ant to shut up in this one case only. I would have thought that using the output and error properties would help; they did not. Does anyone have any better suggestions for how to check for tool existence in Ant? Bob