Ant - Build file to install xsltproc

By xngo on June 23, 2019

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
Description: Install xsltproc:
              -Decompress all zip files from zip directory to the defined destination directory.
              -Generate paths to add in the PATH environment variable(environment.path.txt).
-->
<project basedir="." default="nothing" name="xsltproc_install">
 
  <property name="dir.separator" value="\"/>
 
  <property name="iconv" value="iconv-1.9.2.win32"/>
  <property name="zlib" value="zlib-1.2.3.win32"/>
  <property name="libxml2" value="libxml2-2.7.6.win32"/>
  <property name="libxslt" value="libxslt-1.1.26.win32"/>
 
  <!--=======================
  DEFAULT TARGET
  =======================-->
  <target name="nothing" description="By default, it does nothing.">
    <echo>By default, it does nothing.</echo>
    <echo>${os.name}</echo>
  </target>
 
  <!--=======================
  INSTALL TARGET
  =======================-->
  <target name="install" description="Install xsltproc.">
    <antcall target="errors_checking"/>
    <mkdir dir="${To.Dir}"/>
    <unzip src="zip/${iconv}.zip" dest="${To.Dir}"/>
    <unzip src="zip/${zlib}.zip" dest="${To.Dir}"/>
    <unzip src="zip/${libxml2}.zip" dest="${To.Dir}"/>
    <unzip src="zip/${libxslt}.zip" dest="${To.Dir}"/>
 
    <echo file="environment.path.txt">;${To.Dir}${dir.separator}${iconv}${dir.separator}bin;${To.Dir}${dir.separator}${zlib}${dir.separator}bin;${To.Dir}${dir.separator}${libxml2}${dir.separator}bin;${To.Dir}${dir.separator}${libxslt}${dir.separator}bin;</echo>
  </target>
 
  <!--=======================
  ERROR CHECKING TARGET
  =======================-->  
  <target name="errors_checking" description="Do GENERIC errors checking before installing xsltproc.">
 
    <fail message="&#xa;To.Dir parameter is required.&#xa;Example: ant -f xsltproc_install.xml -DTo.Dir=&quot;c:\xsltproc&quot;">
      <!-- Stop running if To.Dir is not set or it is empty. -->
      <condition>
        <or>
          <not>
            <isset property="To.Dir"/>
          </not>
          <length string="${To.Dir}" length="0" />
        </or>
      </condition>
    </fail>
 
    <fail message="zip/${iconv}.zip is missing.">
      <condition><not><available file="zip/${iconv}.zip"/></not></condition>
    </fail>
 
    <fail message="zip/${zlib}.zip is missing.">
      <condition><not><available file="zip/${iconv}.zip"/></not></condition>
    </fail>
 
    <fail message="zip/${libxml2}.zip is missing.">
      <condition><not><available file="zip/${iconv}.zip"/></not></condition>
    </fail>
 
    <fail message="zip/${libxslt}.zip is missing.">
      <condition><not><available file="zip/${iconv}.zip"/></not></condition>
    </fail>
 
    <echo>Errors checking: Passed!</echo>
  </target>
 
</project>

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.