2017-03-14 21 views
0

我使用Apache Ant將我的XML構建爲PDF管道。每個使用這個構建文件的PC都有自己的Adobe Acrobat版本。我如何讓Ant在幾個地方查找正確的可執行文件路徑?目前我很難編碼像下面這樣的路徑,但是當新用戶使用它時必須改變它。任何幫助表示讚賞。在Windows上使用Ant產生PDF查看器

<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> 

回答

1

而不是硬編碼到Acrobat.exe的路徑,考慮讓Windows運行註冊的程序來處理PDF文件。的cmd.exestart命令可以做到這一點:

<!-- 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> 
+0

真棒。這工作表示感謝! – user3618078