<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id$ -->
<project default="jar" name="W3C CSS Validator">

  <!-- =================================================================== -->
  <!-- User-overrideable properties                                      -->
  <!-- =================================================================== -->

  <property name="servlet.lib" value="/usr/share/java/servlet-2.3.jar"/>

  <!-- =================================================================== -->
  <!-- Project-wide properties                                           -->
  <!-- =================================================================== -->
  <!-- Overriding those properties works too, but is not advisable. -->

  <property name="app.name" value="css-validator"/>
  <property name="jar.file" value="${app.name}.jar"/>
  <property name="war.file" value="${app.name}.war"/>

  <!-- =================================================================== -->
  <!-- Targets                                                             -->
  <!-- =================================================================== -->

  <path id="build.class.path">
    <pathelement location="${servlet.lib}"/>
    <fileset dir="lib">
        <include name="*.jar"/>
    </fileset>
  </path>

  <target name="prepare.check">
    <condition property="prepare.run">
      <and>
        <available file="lib/jigsaw-2.2.6.jar"/>
        <available file="lib/commons-beanutils-1.10.0.jar"/>
        <available file="lib/commons-collections4-4.4.jar"/>
        <available file="lib/commons-digester3-3.2.jar"/>
        <available file="lib/commons-lang3-3.17.0.jar"/>
        <available file="lib/commons-logging-1.3.4.jar"/>
        <available file="lib/commons-text-1.13.0.jar"/>
        <available file="lib/commons-validator-1.9.0.jar"/>
        <available file="lib/velocity-2.4.1.jar"/>
        <available file="lib/xercesImpl-2.12.2.jar"/>
        <available file="lib/xml-apis-1.4.01.jar"/>
        <available file="lib/tagsoup-1.2.1.jar"/>
        <available file="lib/servlet-api-2.5-6.0.1.jar"/>
        <available file="lib/htmlparser-1.4.16.jar"/>
        <available file="lib/velocity-tools-generic-3.1.jar"/>
        <available file="lib/slf4j-api-1.7.36.jar"/>
        <available file="lib/slf4j-nop-1.7.36.jar"/>
      </and>
    </condition>
  </target>


  <target name="prepare" description="Downloads necessary libs" depends="prepare.check" unless="prepare.run">
    <mkdir dir="lib"/>
    <mkdir dir="tmp"/>

    <get dest="tmp/jigsaw-2.2.6.jar" src="https://repo1.maven.org/maven2/org/w3c/jigsaw/jigsaw/2.2.6/jigsaw-2.2.6.jar" usetimestamp="true"/>
    <get dest="tmp/commons-beanutils-1.10.0.jar" src="https://repo1.maven.org/maven2/commons-beanutils/commons-beanutils/1.10.0/commons-beanutils-1.10.0.jar" usetimestamp="true"/>
    <get dest="tmp/commons-collections4-4.4.jar" src="https://repo1.maven.org/maven2/org/apache/commons/commons-collections4/4.4/commons-collections4-4.4.jar" usetimestamp="true"/>
    <get dest="tmp/commons-digester3-3.2.jar" src="https://repo1.maven.org/maven2/org/apache/commons/commons-digester3/3.2/commons-digester3-3.2.jar" usetimestamp="true"/>
    <get dest="tmp/commons-lang3-3.17.0.jar" src="https://repo1.maven.org/maven2/org/apache/commons/commons-lang3/3.17.0/commons-lang3-3.17.0.jar" usetimestamp="true"/>
    <get dest="tmp/commons-text-1.13.0.jar" src="https://repo1.maven.org/maven2/org/apache/commons/commons-text/1.13.0/commons-text-1.13.0.jar" usetimestamp="true"/>
    <get dest="tmp/commons-logging-1.3.4.jar" src="https://repo1.maven.org/maven2/commons-logging/commons-logging/1.3.4/commons-logging-1.3.4.jar" usetimestamp="true"/>
    <get dest="tmp/commons-validator-1.9.0.jar" src="https://repo1.maven.org/maven2/commons-validator/commons-validator/1.9.0/commons-validator-1.9.0.jar" usetimestamp="true"/>
    <get dest="tmp/velocity-2.4.1.jar" src="https://repo1.maven.org/maven2/org/apache/velocity/velocity-engine-core/2.4.1/velocity-engine-core-2.4.1.jar" usetimestamp="true"/>
    <get dest="tmp/velocity-tools-3.1.jar" src="https://repo1.maven.org/maven2/org/apache/velocity/tools/velocity-tools-generic/3.1/velocity-tools-generic-3.1.jar" usetimestamp="true"/>
    <get dest="tmp/xercesImpl-2.12.1.jar" src="https://repo1.maven.org/maven2/xerces/xercesImpl/2.12.1/xercesImpl-2.12.1.jar" usetimestamp="true"/>
    <get dest="tmp/xml-apis-1.4.01.jar" src="https://repo1.maven.org/maven2/xml-apis/xml-apis/1.4.01/xml-apis-1.4.01.jar" usetimestamp="true"/>
    <get dest="tmp/tagsoup-1.2.1.jar" src="https://repo1.maven.org/maven2/org/ccil/cowan/tagsoup/tagsoup/1.2.1/tagsoup-1.2.1.jar" usetimestamp="true"/>
    <get dest="tmp/servlet-api-2.5-6.0.1.jar" src="https://repo1.maven.org/maven2/org/mortbay/jetty/servlet-api/2.5-6.0.1/servlet-api-2.5-6.0.1.jar" usetimestamp="true"/>
    <get dest="tmp/htmlparser-1.4.16.jar" src="https://repo1.maven.org/maven2/nu/validator/htmlparser/1.4.16/htmlparser-1.4.16.jar" usetimestamp="true"/>
    <get dest="tmp/slf4j-api-1.7.36.jar" src="https://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar" usetimestamp="true"/>
    <get dest="tmp/slf4j-nop-1.7.36.jar" src="https://repo1.maven.org/maven2/org/slf4j/slf4j-nop/1.7.36/slf4j-nop-1.7.36.jar" usetimestamp="true"/>


    <copy file="tmp/servlet-api-2.5-6.0.1.jar" tofile="lib/servlet-api-2.5-6.0.1.jar"/>
    <copy file="tmp/jigsaw-2.2.6.jar" tofile="lib/jigsaw-2.2.6.jar"/>
    <copy file="tmp/commons-beanutils-1.10.0.jar" tofile="lib/commons-beanutils-1.10.0.jar"/>
    <copy file="tmp/commons-collections4-4.4.jar" tofile="lib/commons-collections4-4.4.jar"/>
    <copy file="tmp/commons-digester3-3.2.jar" tofile="lib/commons-digester3-3.2.jar"/>
    <copy file="tmp/commons-lang3-3.17.0.jar" tofile="lib/commons-lang3-3.17.0.jar"/>
    <copy file="tmp/commons-text-1.13.0.jar" tofile="lib/commons-text-1.13.0.jar"/>
    <copy file="tmp/commons-logging-1.3.4.jar" tofile="lib/commons-logging-1.3.4.jar"/>
    <copy file="tmp/commons-validator-1.9.0.jar" tofile="lib/commons-validator-1.9.0.jar"/>
    <copy file="tmp/velocity-2.4.1.jar" tofile="lib/velocity-2.4.1.jar"/>
    <copy file="tmp/velocity-tools-3.1.jar" tofile="lib/velocity-tools-3.1.jar"/>
    <copy file="tmp/xercesImpl-2.12.1.jar" tofile="lib/xercesImpl-2.12.1.jar"/>
    <copy file="tmp/xml-apis-1.4.01.jar" tofile="lib/xml-apis-1.4.01.jar"/>
    <copy file="tmp/tagsoup-1.2.1.jar" tofile="lib/tagsoup-1.2.1.jar"/>
    <copy file="tmp/htmlparser-1.4.16.jar" tofile="lib/htmlparser-1.4.16.jar"/>
    <copy file="tmp/slf4j-api-1.7.36.jar" tofile="lib/slf4j-api-1.7.36.jar"/>
    <copy file="tmp/slf4j-nop-1.7.36.jar" tofile="lib/slf4j-nop-1.7.36.jar"/>
  </target>

  <target name="build" description="Builds the validator" depends="prepare">
    <mkdir dir="./build"/>
    <javac classpathref="build.class.path" destdir="./build" encoding="UTF-8"
           debug="yes" includes="org/w3c/**" srcdir="." source="8" target="8"
           includeantruntime="false"/>
    <copy todir="./build">
      <fileset dir="./">
        <include name="org/**"/>
        <exclude name="**/*.java"/>
        <exclude name="**/*.class"/>
      </fileset>
    </copy>
  </target>

  <target name="jigsaw" description="Builds the validator for Jigsaw" depends="prepare">
    <mkdir dir="./build"/>
    <javac classpathref="build.class.path" destdir="." encoding="UTF-8"
           debug="yes" source="8" target="8">
      <src path="./org/w3c"/>
    </javac>
  </target>

  <target name="javadoc" description="Generates API docs">
    <mkdir dir="./javadoc"/>
    <javadoc
      packagenames="org.w3c.*"
      sourcepath="./"
      destdir="./javadoc"
      author="true"
      version="true"
      windowtitle="W3C CSS Validator API"/>
  </target>

  <target name="jar" depends="build" description="Creates the lib archive with all dependency jars included">
    <delete file="${jar.file}"/>
    <jar jarfile="${jar.file}" basedir="build" excludes="org/**/*.java">
      <zipgroupfileset dir="lib" includes="*.jar"/>
      <include name="org/**"/>
      <manifest>
        <attribute name="Main-Class" value="org.w3c.css.css.CssValidator"/>
      </manifest>
    </jar>
  </target>

  <target name="jar-without-dependencies" depends="build" description="Creates the lib archive without dependency jars">
    <delete file="${jar.file}"/>
    <jar jarfile="${jar.file}" basedir="build" excludes="org/**/*.java">
      <include name="org/**"/>
      <manifest>
        <attribute name="Main-Class" value="org.w3c.css.css.CssValidator"/>
      </manifest>
    </jar>
  </target>

  <target name="war" depends="build" description="Creates the webapp module">
    <delete file="${war.file}"/>
    <war warfile="${war.file}" webxml="web.xml" basedir="." includes="*html*,favicon.ico,images/**,style/**,scripts/**,tabtastic/**" excludes="html,css-validator.*">
      <classes dir="build"/>
      <lib dir="lib">
        <exclude name="*servlet*.jar"/>
      </lib>
    </war>
  </target>

  <target name="autotest" depends="jar">
    <fail message="&#xa0;${line.separator}${line.separator}
  Usage: ant autotest -Dtestfile=testsuite/xml/FILENAME.xml">
      <condition>
        <not>
          <isset property="testfile"/>
        </not>
      </condition>
    </fail>
    <javac srcdir="autotest" classpath="css-validator.jar"
      includeantruntime="false"/>
    <java classname="autotest.AutoTest" classpath="css-validator.jar">
      <arg value="${testfile}"/>
    </java>
  </target>

  <target name="javacc">
    <ant antfile="build.xml" dir="javacc"/>
  </target>

  <target name="clean" description="Cleans up generated files">
    <delete file="${jar.file}"/>
    <delete file="${war.file}"/>
    <delete dir="./build"/>
    <delete dir="./javadoc"/>
    <delete dir="./tmp"/>
  </target>

</project>
