I am using Apache Ant to build my XML to PDF pipeline. Every PC using this build file has their own version of Adobe Acrobat. How do I make Ant look in several places to find the correct executable path? Currently I am hard coding the path like below but have to change it when a new person uses it. Any help is appreciated.
<property name="browser" location="C:\Program Files (x86)\Adobe\Acrobat 11.0\Acrobat\Acrobat.exe"/>
<property name="file" location="${dstDir}/${output}"/>
<exec executable="${browser}" spawn="true">
<arg value="${file}"/>
</exec>
Instead of hard-coding a path to Acrobat.exe, consider letting Windows run the program registered to handle PDF files. The start
command of cmd.exe
can do this:
<!-- No need for the "spawn" attribute because the "start" command -->
<!-- will launch the PDF program without waiting. -->
<exec executable="cmd" failonerror="true">
<arg value="/c"/>
<arg value="start"/>
<!-- The first argument of "start" is "Title to display in -->
<!-- window title bar." This argument must be surrounded by -->
<!-- quotation marks. Since this code doesn't launch a -->
<!-- Command Prompt window, we give a dummy value. -->
<arg value='"unused title"'/>
<arg value="${file}"/>
</exec>