<?xml version="1.0" encoding="UTF-8"?>
<project name="SyntaxHighlighter Installer" default="compile">

  <property name="localRepository" value="${user.home}/.m2/repository"/>
  <property name="syntaxhighlighter.version" value="1.5.1"/>
  <property name="build.location" value="${basedir}/target/site/js/dp.SyntaxHighlighter"/>

  <!-- How to install -->
  <!-- Download SyntaxHighlighter_1.5.1.rar from http://code.google.com/p/syntaxhighlighter/ -->
  <!-- Convert rar to zip -->
  <!-- mvn install:install-file -DgroupId=syntaxhighlighter -DartifactId=syntaxhighlighter -Dversion=${syntaxhighlighter.version} -Dpackaging=zip -DgeneratePom=true -Dfile=SyntaxHighlighter_${syntaxhighlighter.version}.zip -->

  <target name="compile" depends="check-installed">
    <fail message="syntaxhighlighter zip file not installed in local repository: ${localRepository}" unless="already.installed"/>
    <mkdir dir="${localRepository}/syntaxhighlighter/syntaxhighlighter/${syntaxhighlighter.version}"/>
    <unzip src="${localRepository}/syntaxhighlighter/syntaxhighlighter/${syntaxhighlighter.version}/syntaxhighlighter-${syntaxhighlighter.version}.zip"
         dest="${localRepository}/syntaxhighlighter/syntaxhighlighter/${syntaxhighlighter.version}/" overwrite="false"/>
    <copy todir="${build.location}">
      <fileset dir="${localRepository}/syntaxhighlighter/syntaxhighlighter/${syntaxhighlighter.version}/dp.SyntaxHighlighter">
        <exclude name="Uncompressed/**"/>
      </fileset>
    </copy>
  </target>

  <target name="check-installed">
    <condition property="already.installed" >
      <available file="${localRepository}/syntaxhighlighter/syntaxhighlighter/${syntaxhighlighter.version}/syntaxhighlighter-${syntaxhighlighter.version}.zip"/>
    </condition>
    <condition property="maven.suffix" value="">
      <os family="unix"/>
    </condition>
    <condition property="maven.suffix" value=".bat">
      <os family="windows"/>
    </condition>
  </target>

  <target name="clean">
    <delete dir="${build.location}"/>
  </target>

</project>
