2017-03-14 1 views
0

Ich verwende Apache Ant, um meine XML-in-PDF-Pipeline zu erstellen. Jeder PC, der diese Build-Datei verwendet, hat eine eigene Version von Adobe Acrobat. Wie mache ich Ant an mehreren Stellen, um den richtigen ausführbaren Pfad zu finden? Momentan bin ich hart den Pfad wie folgt zu kodieren, muss ihn aber ändern, wenn eine neue Person ihn benutzt. Jede Hilfe wird geschätzt.Erstellen eines PDF-Viewers mit Ant unter Windows

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

Antwort

1

Anstatt einen Pfad zur Acrobat.exe fest zu codieren, sollten Sie in Erwägung ziehen, Windows das für die Verarbeitung von PDF-Dateien registrierte Programm ausführen zu lassen. Der start Befehl von cmd.exe kann dies tun:

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

ehrfürchtig. Das funktioniert dank! – user3618078

Verwandte Themen