Orangevolt ANT Tasks » Tasks » sfx
Examplejstub

2.1.2.  Dynamic commandline example

The following example shows you how to use dynamic commandline feature of the sfx task.

<?xml version="1.0"?>  
<project basedir="." name="foo" default="main">
  <taskdef classpath="orangevolt-ant-tasks-1.3.2.jar" resource="com/orangevolt/tools/ant/taskdefs.properties"/>
    
  <target name="main">
    <sfx
    archive="foo.jar"
    mode="win32"
        icon="images/foo.gif"
    execute="javaw -cp lib; -Djava.ext.dirs=${env:TOMCAT_HOME|c:\tomcat}\common\lib -Ddesktop=${reg:HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Desktop} foo.bar"
    output="foo.exe"
  />
        
      <sfx
    archive="foo.jar"
    mode="unix"
    execute="java -cp lib; -Djava.ext.dirs=${env:TOMCAT_HOME|c:\tomcat}\common\lib -Ddesktop=${env:HOME\Desktop} foo.bar"
    output="foo.exe"
  />  
  </target>
</project>

The created executable will extract the contents to the temp directory, evaluates the ccommandline string and executes it.

The evaluation replaces ${env:TOMCAT_HOME|c:\tomcat} by the value of enviroment variable TOMCAT_HOME or (if it not exists) by c:\temp.

On windows: ${reg:HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Desktop} will be replaced by the path of the windows desktop directory or an empty string (if it is not found).

On unix: ${env:HOME\Desktop} will be replaced by the pathof the kde desktop directory or an empty string (if it is not found).