<!--
Copyright (c) 2013-2020 Mozilla Foundation

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
-->
<project name="html5-validator" basedir=".." default="build"
  xmlns:if="ant:if"
  xmlns:unless="ant:unless"
  xmlns:artifact="antlib:org.apache.maven.artifact.ant">
  <tstamp/>
  <property name="dist" location="build/dist" />
  <property name="jarsDir" location="jars" />
  <property name="depsDir" location="dependencies" />
  <property name="jing-shaded-jar" location="build/jing-shaded.jar" />
  <property name="version" value="nightly-${DSTAMP}" />
  <loadresource property="version.number">
    <string value="${version}"/>
    <filterchain>
      <tokenfilter>
        <replaceregex pattern="^([^ ]+).*$" replace="\1"/>
      </tokenfilter>
    </filterchain>
  </loadresource>
  <property name="build.java.target.version" value="11" />
  <property name="groupId" value="nu.validator" />
  <property name="artifactId" value="validator" />
  <property name="src" location="src" />
  <property name="javadoc-dir" value="${dist}/javadoc" />
  <property name="validator-jar" value="${dist}/${artifactId}-${version.number}.jar" />
  <property name="validator-javadoc-jar" value="${dist}/${artifactId}-${version.number}-javadoc.jar" />
  <property name="validator-sources-jar" value="${dist}/${artifactId}-${version.number}-sources.jar" />
  <property name="validator-bundle-dir" value="${dist}/nu/validator/validator/${version.number}" />
  <property name="validator-bundle-jar" value="${dist}/validator-${version.number}-bundle.jar" />

  <!-- The default values of these 'validator.param.*' properties are supposed
  to be equal to the values in build.py -->
  <property name="validator.param.aboutFile" value="site/about.html"/>
  <property name="validator.param.formTemplate" value="site/FormEmitter.xml"/>
  <property name="validator.param.pageTemplate" value="site/PageEmitter.xml"/>
  <property name="validator.param.presetsFile" value="resources/presets.txt"/>
  <property name="validator.param.resultsTitle" value="Validation results"/>
  <property name="validator.param.scriptFile" value="site/script.js"/>
  <property name="validator.param.serviceName" value="Validator.nu"/>
  <property name="validator.param.stylesheetFile" value="site/style.css"/>
  <property name="validator.param.userAgent" value="Validator.nu/LV"/>

  <echo>Version is set to ${version}</echo>
  <echo if:true="${offline}">Building in offline mode as requested (assuming you already have all dependencies).</echo>

  <!-- Delete file and parent folder if it became empty -->
  <macrodef name="deleteFileWithEmptyParent">
    <attribute name="file"/>
      <sequential>
        <local name="parent"/>
        <dirname property="parent" file="@{file}"/>
        <echo>${parent} + @{file}</echo>
        <delete file="@{file}"/>
        <delete includeemptydirs="true" failonerror="false" quiet="true" verbose="true">
          <fileset dir="${parent}">
            <and>
              <size value="0"/>
              <type type="dir"/>
            </and>
          </fileset>
        </delete>
      </sequential>
  </macrodef>

  <macrodef name="get-and-checksum">
    <attribute name="url"/>
    <attribute name="destdir" default="${depsDir}"/>
    <attribute name="skipexisting" default="true"/>
    <attribute name="verbose" default="false"/>
    <attribute name="checksum.skip" default="false"/>
    <attribute name="checksum.pattern" default="{0}"/>
    <sequential>
      <local name="basename"/>
      <basename property="basename" file="@{url}"/>
      <mkdir dir="@{destdir}"/>

      <get dest="@{destdir}" skipexisting="@{skipexisting}" verbose="@{verbose}">
        <url url="@{url}"/>
        <url url="@{url}.sha1"/>
        <firstmatchmapper>
          <globmapper from="@{url}.sha1" to="${basename}.sha1"/>
          <globmapper from="@{url}" to="${basename}"/>
        </firstmatchmapper>
      </get>

      <local name="checksum.matches"/>
      <local name="checksum.matches.fail"/>
      <checksum file="@{destdir}/${basename}" algorithm="sha" fileext=".sha1"
                verifyproperty="checksum.matches"
                pattern="@{checksum.pattern}"/>
      <condition property="checksum.matches.fail">
        <and>
          <equals arg1="${checksum.matches}" arg2="false"/>
          <equals arg1="@{checksum.skip}" arg2="false"/>
        </and>
      </condition>
      <fail if="checksum.matches.fail">Checksum error on @{destdir}/${basename}</fail>
    </sequential>
  </macrodef>

  <property name="maven-ant-tasks-version" value="2.1.3" />
  <target name="dl-deps-antlib" unless="${offline}">
    <echo>Downloading dependencies (required antlib)</echo>
    <get-and-checksum url="https://repo1.maven.org/maven2/org/apache/maven/maven-ant-tasks/${maven-ant-tasks-version}/maven-ant-tasks-${maven-ant-tasks-version}.jar"/>
    <taskdef uri="antlib:org.apache.maven.artifact.ant"
             resource="org/apache/maven/artifact/ant/antlib.xml"
             classpath="${depsDir}/maven-ant-tasks-${maven-ant-tasks-version}.jar"/>
  </target>

  <property name="jetty-version" value="12.0.34" />
  <target name="dl-deps-jetty" unless="${offline}">
    <echo>Downloading dependencies (jetty)</echo>
    <get-and-checksum url="https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-client/${jetty-version}/jetty-client-${jetty-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-http/${jetty-version}/jetty-http-${jetty-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-io/${jetty-version}/jetty-io-${jetty-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-security/${jetty-version}/jetty-security-${jetty-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-server/${jetty-version}/jetty-server-${jetty-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/org/eclipse/jetty/ee10/jetty-ee10-servlet/${jetty-version}/jetty-ee10-servlet-${jetty-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/org/eclipse/jetty/ee10/jetty-ee10-servlets/${jetty-version}/jetty-ee10-servlets-${jetty-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-session/${jetty-version}/jetty-session-${jetty-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-util/${jetty-version}/jetty-util-${jetty-version}.jar"/>
  </target>

  <property name="commons-codec-version" value="1.15" />
  <property name="commons-fileupload-version" value="2.0.0-M5" />
  <property name="commons-io-version" value="2.22.0" />
  <property name="commons-logging-version" value="1.2" />
  <property name="commons-text-version" value="1.12.0" />
  <property name="icu4j-version" value="75.1" />
  <property name="jakarta.servlet-api-version" value="6.1.0" />
  <property name="jakarta.json-version" value="2.0.1" />
  <property name="jchardet-version" value="1.0" />
  <property name="log4j-version" value="1.2.17" />
  <property name="mail-version" value="1.4.7" />
  <property name="htmlunit-csp-version" value="4.22.0" />
  <property name="jacoco-version" value="0.8.14" />
  <target name="dl-deps" unless="${offline}">
    <echo>Downloading dependencies</echo>
    <get-and-checksum url="https://repo1.maven.org/maven2/com/ibm/icu/icu4j/${icu4j-version}/icu4j-${icu4j-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/org/htmlunit/htmlunit-csp/${htmlunit-csp-version}/htmlunit-csp-${htmlunit-csp-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/commons-codec/commons-codec/${commons-codec-version}/commons-codec-${commons-codec-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/org/apache/commons/commons-fileupload2-core/${commons-fileupload-version}/commons-fileupload2-core-${commons-fileupload-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/org/apache/commons/commons-fileupload2-jakarta-servlet6/${commons-fileupload-version}/commons-fileupload2-jakarta-servlet6-${commons-fileupload-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/commons-io/commons-io/${commons-io-version}/commons-io-${commons-io-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/commons-logging/commons-logging/${commons-logging-version}/commons-logging-${commons-logging-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/commons-logging/commons-logging/${commons-logging-version}/commons-logging-${commons-logging-version}-adapters.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/commons-logging/commons-logging/${commons-logging-version}/commons-logging-${commons-logging-version}-api.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/org/apache/commons/commons-text/${commons-text-version}/commons-text-${commons-text-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/javax/mail/mail/${mail-version}/mail-${mail-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/jakarta/servlet/jakarta.servlet-api/${jakarta.servlet-api-version}/jakarta.servlet-api-${jakarta.servlet-api-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/log4j/log4j/${log4j-version}/log4j-${log4j-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/net/sourceforge/jchardet/jchardet/${jchardet-version}/jchardet-${jchardet-version}.jar" checksum.pattern="{0} "/>
    <get-and-checksum url="https://repo1.maven.org/maven2/org/glassfish/jakarta.json/${jakarta.json-version}/jakarta.json-${jakarta.json-version}.jar"/>
  </target>

  <property name="avalon-framework-api-version" value="4.3.1" />
  <property name="avalon-logkit-version" value="2.2.1" />
  <property name="cdi-api-version" value="2.0" />
  <property name="el-api-version" value="2.2" />
  <property name="javax-activation-version" value="1.2.0" />
  <property name="javax-inject-version" value="1" />
  <property name="javax-interceptor-api-version" value="1.2.2" />
  <property name="javax-jms-api-version" value="2.0.1" />
  <property name="jsr305-version" value="3.0.2" />
  <property name="portlet-api-version" value="3.0.1" />
  <property name="slf4j-api-version" value="1.7.29" />
  <property name="slf4j-log4j12-version" value="1.7.32" />
  <target name="dl-deps-modules" unless="${offline}">
    <echo>Downloading dependencies (modules dependencies)</echo>
    <get-and-checksum url="https://repo1.maven.org/maven2/com/sun/activation/javax.activation/${javax-activation-version}/javax.activation-${javax-activation-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/org/apache/avalon/framework/avalon-framework-api/${avalon-framework-api-version}/avalon-framework-api-${avalon-framework-api-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/org/apache/avalon/logkit/avalon-logkit/${avalon-logkit-version}/avalon-logkit-${avalon-logkit-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/javax/enterprise/cdi-api/${cdi-api-version}/cdi-api-${cdi-api-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/javax/el/el-api/${el-api-version}/el-api-${el-api-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/javax/activation/javax.activation-api/${javax-activation-version}/javax.activation-api-${javax-activation-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/javax/inject/javax.inject/${javax-inject-version}/javax.inject-${javax-inject-version}.jar" checksum.pattern="{0} "/>
    <get-and-checksum url="https://repo1.maven.org/maven2/javax/interceptor/javax.interceptor-api/${javax-interceptor-api-version}/javax.interceptor-api-${javax-interceptor-api-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/javax/jms/javax.jms-api/${javax-jms-api-version}/javax.jms-api-${javax-jms-api-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-jmx/${jetty-version}/jetty-jmx-${jetty-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/com/google/code/findbugs/jsr305/${jsr305-version}/jsr305-${jsr305-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/javax/portlet/portlet-api/${portlet-api-version}/portlet-api-${portlet-api-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/org/slf4j/slf4j-api/${slf4j-api-version}/slf4j-api-${slf4j-api-version}.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/org/slf4j/slf4j-log4j12/${slf4j-log4j12-version}/slf4j-log4j12-${slf4j-log4j12-version}.jar"/>
  </target>

  <target name="dl-deps-jacoco" unless="${offline}">
    <echo>Downloading dependencies (JaCoCo)</echo>
    <get-and-checksum url="https://repo1.maven.org/maven2/org/jacoco/org.jacoco.agent/${jacoco-version}/org.jacoco.agent-${jacoco-version}-runtime.jar"/>
    <get-and-checksum url="https://repo1.maven.org/maven2/org/jacoco/org.jacoco.cli/${jacoco-version}/org.jacoco.cli-${jacoco-version}-nodeps.jar"/>
  </target>

  <target name="dl-html5spec" unless="${offline}">
    <echo>Downloading latest html5 specification</echo>
    <get src="https://html.spec.whatwg.org/" dest="${validator.basedir}/resources/spec/html5spec-single.html" tryGzipEncoding="true"/>
  </target>

  <target name="dl-all" depends="dl-deps, dl-deps-modules, dl-deps-jetty, dl-deps-jacoco, dl-deps-antlib"/>

  <target name="dl-clean">
    <echo>Remove ${depsDir}</echo>
    <delete dir="${depsDir}"/>
  </target>

  <target name="build" depends="jar"/>
  <target name="clean"
          depends="galimatias-clean,
          htmlparser-clean,
          langdetect-clean,
          validator-clean,
          cssvalidator-clean,
          jing-clean
          ">
    <delete dir="${dist}"/>
  </target>
  <target name="distclean" depends="clean, dl-clean"/>

  <target name="jar" depends="validator-jar, jing-shade">
    <jar destfile="${dist}/vnu.jar" duplicate="preserve">
      <zipfileset src="${jarsDir}/validator.jar"/>

      <zipfileset src="${jarsDir}/galimatias.jar" unless:true="${jar-without-deps}"/>
      <zipfileset src="${jarsDir}/htmlparser.jar" unless:true="${jar-without-deps}"/>
      <zipfileset src="${jarsDir}/langdetect.jar" unless:true="${jar-without-deps}"/>

      <zipfileset src="css-validator/css-validator.jar" unless:true="${jar-without-deps}"/>

      <zipfileset src="${jing-shaded-jar}" unless:true="${jar-without-deps}"/>
      <zipfileset src="jing-trang/lib/saxon9.jar" unless:true="${jar-without-deps}"/>

      <zipfileset src="${depsDir}/commons-codec-${commons-codec-version}.jar" unless:true="${jar-without-deps}"/>
      <zipfileset src="${depsDir}/commons-fileupload2-core-${commons-fileupload-version}.jar" unless:true="${jar-without-deps}"/>
      <zipfileset src="${depsDir}/commons-fileupload2-jakarta-servlet6-${commons-fileupload-version}.jar" unless:true="${jar-without-deps}"/>
      <zipfileset src="${depsDir}/commons-io-${commons-io-version}.jar" unless:true="${jar-without-deps}"/>
      <zipfileset src="${depsDir}/commons-logging-${commons-logging-version}.jar" unless:true="${jar-without-deps}"/>
      <zipfileset src="${depsDir}/commons-logging-${commons-logging-version}-adapters.jar" unless:true="${jar-without-deps}"/>
      <zipfileset src="${depsDir}/commons-logging-${commons-logging-version}-api.jar" unless:true="${jar-without-deps}"/>
      <zipfileset src="${depsDir}/commons-text-${commons-text-version}.jar" unless:true="${jar-without-deps}"/>
      <zipfileset src="${depsDir}/icu4j-${icu4j-version}.jar" unless:true="${jar-without-deps}"/>

      <zipfileset src="${depsDir}/jchardet-${jchardet-version}.jar" unless:true="${jar-without-deps}"/>
      <zipfileset src="${depsDir}/jetty-client-${jetty-version}.jar" unless:true="${jar-without-deps}">
        <exclude name="module-info.class" />
      </zipfileset>
      <zipfileset src="${depsDir}/jetty-http-${jetty-version}.jar" unless:true="${jar-without-deps}">
        <exclude name="module-info.class" />
        <exclude name="META-INF/services/**"/>
      </zipfileset>
      <zipfileset src="${depsDir}/jetty-io-${jetty-version}.jar" unless:true="${jar-without-deps}">
        <exclude name="module-info.class" />
      </zipfileset>
      <zipfileset src="${depsDir}/jakarta.servlet-api-${jakarta.servlet-api-version}.jar" unless:true="${jar-without-deps}">
        <exclude name="module-info.class" />
      </zipfileset>
      <zipfileset src="${depsDir}/jetty-security-${jetty-version}.jar" unless:true="${jar-without-deps}">
        <exclude name="module-info.class" />
      </zipfileset>
      <zipfileset src="${depsDir}/jetty-server-${jetty-version}.jar" unless:true="${jar-without-deps}">
        <exclude name="module-info.class" />
      </zipfileset>
      <zipfileset src="${depsDir}/jetty-ee10-servlet-${jetty-version}.jar" unless:true="${jar-without-deps}">
        <exclude name="module-info.class" />
      </zipfileset>
      <zipfileset src="${depsDir}/jetty-ee10-servlets-${jetty-version}.jar" unless:true="${jar-without-deps}">
        <exclude name="module-info.class" />
      </zipfileset>
      <zipfileset src="${depsDir}/jetty-session-${jetty-version}.jar" unless:true="${jar-without-deps}">
        <exclude name="module-info.class" />
      </zipfileset>
      <zipfileset src="${depsDir}/jetty-util-${jetty-version}.jar" unless:true="${jar-without-deps}">
        <exclude name="module-info.class" />
      </zipfileset>
      <zipfileset src="${depsDir}/jakarta.json-${jakarta.json-version}.jar" unless:true="${jar-without-deps}">
        <exclude name="module-info.class" />
      </zipfileset>
      <zipfileset src="${depsDir}/log4j-${log4j-version}.jar" unless:true="${jar-without-deps}"/>
      <zipfileset src="${depsDir}/htmlunit-csp-${htmlunit-csp-version}.jar" unless:true="${jar-without-deps}"/>
      <!-- module dependencies -->
      <!-- isorelax.jar classes are now included in jing-shaded.jar to avoid Maven conflicts -->
      <zipfileset src="${depsDir}/avalon-framework-api-${avalon-framework-api-version}.jar" unless:true="${jar-without-deps}"/>
      <zipfileset src="${depsDir}/avalon-logkit-${avalon-logkit-version}.jar" unless:true="${jar-without-deps}"/>
      <zipfileset src="${depsDir}/cdi-api-${cdi-api-version}.jar" unless:true="${jar-without-deps}"/>
      <zipfileset src="${depsDir}/el-api-${el-api-version}.jar" unless:true="${jar-without-deps}"/>
      <zipfileset src="${depsDir}/javax.activation-${javax-activation-version}.jar" unless:true="${jar-without-deps}"/>
      <zipfileset src="${depsDir}/javax.inject-${javax-inject-version}.jar" unless:true="${jar-without-deps}"/>
      <zipfileset src="${depsDir}/javax.interceptor-api-${javax-interceptor-api-version}.jar" unless:true="${jar-without-deps}"/>
      <zipfileset src="${depsDir}/javax.jms-api-${javax-jms-api-version}.jar" unless:true="${jar-without-deps}"/>
      <zipfileset src="${depsDir}/jetty-jmx-${jetty-version}.jar" unless:true="${jar-without-deps}">
        <exclude name="module-info.class" />
      </zipfileset>
      <zipfileset src="${depsDir}/jsr305-${jsr305-version}.jar" unless:true="${jar-without-deps}"/>
      <zipfileset src="${depsDir}/mail-${mail-version}.jar" unless:true="${jar-without-deps}"/>
      <zipfileset src="${depsDir}/portlet-api-${portlet-api-version}.jar" unless:true="${jar-without-deps}"/>
      <zipfileset src="${depsDir}/slf4j-api-${slf4j-api-version}.jar" unless:true="${jar-without-deps}"/>
      <zipfileset src="${depsDir}/slf4j-log4j12-${slf4j-log4j12-version}.jar" unless:true="${jar-without-deps}"/>
      <manifest>
        <attribute name="Main-Class" value="nu.validator.client.SimpleCommandLineValidator"/>
        <attribute name="Implementation-Title" value="The Nu Markup Checker (v.Nu)"/>
        <attribute name="Implementation-Version" value="${version}"/>
        <attribute name="Implementation-Vendor" value="http://validator.github.io/validator/"/>
      </manifest>
      <service type="nu.validator.vendor.relaxng.datatype.DatatypeLibraryFactory">
        <provider classname="nu.validator.vendor.thaiopensource.datatype.xsd.DatatypeLibraryFactoryImpl"/>
        <provider classname="nu.validator.datatype.Html5DatatypeLibraryFactory"/>
      </service>
    </jar>
  </target>

  <target name="war" depends="validator-split-core, jing-shade">
    <war destfile="${dist}/vnu.war" webxml="${validator.basedir}/resources/war/web.xml">
      <lib file="${jarsDir}/galimatias.jar"/>
      <lib file="${jarsDir}/htmlparser.jar"/>
      <lib file="${jarsDir}/langdetect.jar"/>
      <lib file="css-validator/css-validator.jar"/>
      <lib file="${jing-shaded-jar}"/>
      <lib file="jing-trang/lib/saxon9.jar"/>
      <lib file="${depsDir}/commons-codec-${commons-codec-version}.jar"/>
      <lib file="${depsDir}/commons-fileupload2-core-${commons-fileupload-version}.jar"/>
      <lib file="${depsDir}/commons-fileupload2-jakarta-servlet6-${commons-fileupload-version}.jar"/>
      <lib file="${depsDir}/commons-io-${commons-io-version}.jar"/>
      <lib file="${depsDir}/commons-logging-${commons-logging-version}.jar"/>
      <lib file="${depsDir}/commons-logging-${commons-logging-version}-adapters.jar"/>
      <lib file="${depsDir}/commons-logging-${commons-logging-version}-api.jar"/>
      <lib file="${depsDir}/commons-text-${commons-text-version}.jar"/>
      <lib file="${depsDir}/icu4j-${icu4j-version}.jar"/>
      <lib file="${depsDir}/htmlunit-csp-${htmlunit-csp-version}.jar"/>
      <lib file="${depsDir}/jchardet-${jchardet-version}.jar"/>
      <lib file="${depsDir}/log4j-${log4j-version}.jar"/>
      <lib file="${depsDir}/slf4j-api-${slf4j-api-version}.jar"/>
      <lib file="${depsDir}/jakarta.json-${jakarta.json-version}.jar"/>
      <lib file="${depsDir}/jakarta.servlet-api-${jakarta.servlet-api-version}.jar"/>
      <!-- PrudentHttpEntityResolver and VerifierServletTransaction use the
           Jetty HTTP client, so the war needs it and the jars it draws on.
           Only the client side is needed: the war is deployed into a
           servlet container and never starts a Jetty server itself. -->
      <lib file="${depsDir}/jetty-client-${jetty-version}.jar"/>
      <lib file="${depsDir}/jetty-http-${jetty-version}.jar"/>
      <lib file="${depsDir}/jetty-io-${jetty-version}.jar"/>
      <lib file="${depsDir}/jetty-util-${jetty-version}.jar"/>
      <classes dir="${validator.build.basedir}/core/classes"/>
      <classes dir="${validator.build.basedir}/resources"/>
      <classes file="${validator.basedir}/resources/war/log4j.xml"/>
      <!-- The service-provider file must go under WEB-INF/classes, which is
           on the webapp classpath. A <service> element would instead put it
           at the root of the archive, where no classloader looks for it. -->
      <classes dir="${validator.basedir}/resources/war"
               includes="META-INF/services/**"/>
    </war>
  </target>

  <property name="validator.basedir" location="." />
  <property name="validator.build.basedir" location="build/validator" />
  <path id="validator.classpath">
    <fileset dir="${depsDir}/" includes="commons-fileupload2-core-${commons-fileupload-version}.jar" />
    <fileset dir="${depsDir}/" includes="commons-fileupload2-jakarta-servlet6-${commons-fileupload-version}.jar" />
    <fileset dir="${depsDir}/" includes="commons-io-${commons-io-version}.jar" />
    <fileset dir="${depsDir}/" includes="commons-text-${commons-text-version}.jar" />
    <fileset dir="${depsDir}/" includes="icu4j-${icu4j-version}.jar" />
    <fileset dir="${depsDir}/" includes="jakarta.json-${jakarta.json-version}.jar" />
    <fileset dir="${depsDir}/" includes="jetty-client-${jetty-version}.jar" />
    <fileset dir="${depsDir}/" includes="jakarta.servlet-api-${jakarta.servlet-api-version}.jar" />
    <fileset dir="${depsDir}/" includes="jetty-server-${jetty-version}.jar" />
    <fileset dir="${depsDir}/" includes="jetty-ee10-servlet-${jetty-version}.jar" />
    <fileset dir="${depsDir}/" includes="jetty-session-${jetty-version}.jar" />
    <fileset dir="${depsDir}/" includes="jetty-util-${jetty-version}.jar" />
    <fileset dir="${depsDir}/" includes="jetty-http-${jetty-version}.jar" />
    <fileset dir="${depsDir}/" includes="jetty-io-${jetty-version}.jar" />
    <fileset dir="${depsDir}/" includes="log4j-${log4j-version}.jar" />
    <fileset dir="${depsDir}/" includes="htmlunit-csp-${htmlunit-csp-version}.jar" />
    <pathelement location="css-validator/css-validator.jar"/>
    <pathelement location="${jarsDir}/galimatias.jar"/>
    <pathelement location="${jarsDir}/htmlparser.jar"/>
    <pathelement location="${jarsDir}/langdetect.jar"/>
    <pathelement location="${jing-shaded-jar}"/>
  </path>

  <target name="validator-prepare" depends="validator-resources">
    <mkdir dir="${validator.build.basedir}/full/classes"/>
    <copy todir="${validator.build.basedir}/full/classes" preservelastmodified="true">
      <fileset dir="${validator.basedir}/src">
        <exclude name="**/*.java" />
      </fileset>
    </copy>
    <mkdir dir="${validator.build.basedir}/core/classes"/>
    <copy todir="${validator.build.basedir}/core/classes" preservelastmodified="true">
      <fileset dir="${validator.basedir}/src">
        <exclude name="**/*.java" />
      </fileset>
    </copy>
  </target>

  <target name="validator-emitters" depends="validator-prepare">
    <mkdir dir="${validator.build.basedir}/saxCompiler/classes"/>
    <javac srcdir="${validator.basedir}/src"
           destdir="${validator.build.basedir}/saxCompiler/classes"
           debug="true"
           encoding="UTF-8"
           includeantruntime="false"
           includes="nu/validator/xml/SaxCompiler.java"
           nowarn="true"
           release="${build.java.target.version}"
           />
    <mkdir dir="${validator.build.basedir}/builtSrc/nu/validator/servlet"/>
    <java classpath="${validator.build.basedir}/saxCompiler/classes"
          classname="nu.validator.xml.SaxCompiler">
      <arg file="${validator.param.pageTemplate}"/>
      <arg file="${validator.build.basedir}/builtSrc/nu/validator/servlet/PageEmitter.java"/>
    </java>
    <java classpath="${validator.build.basedir}/saxCompiler/classes"
          classname="nu.validator.xml.SaxCompiler">
      <arg file="${validator.param.formTemplate}"/>
      <arg file="${validator.build.basedir}/builtSrc/nu/validator/servlet/FormEmitter.java"/>
    </java>
  </target>

  <target name="validator-build"
          depends="validator-prepare,
          validator-emitters,
          cssvalidator-build,
          galimatias-jar,
          htmlparser-jar,
          jing-shade,
          langdetect-jar,
          dl-deps,
          dl-deps-modules,
          dl-deps-jetty">
    <javac destdir="${validator.build.basedir}/full/classes"
           classpathref="validator.classpath"
           debug="true"
           encoding="UTF-8"
           includeantruntime="false"
           nowarn="true"
           release="${build.java.target.version}"
           >
      <src path="${validator.basedir}/src"/>
      <src path="${validator.build.basedir}/builtSrc"/>
    </javac>
  </target>

  <target name="validator-split-core"
          depends="validator-prepare,
          validator-emitters,
          cssvalidator-build,
          galimatias-jar,
          htmlparser-jar,
          jing-shade,
          langdetect-jar,
          dl-deps,
          dl-deps-modules,
          dl-deps-jetty">
    <javac destdir="${validator.build.basedir}/core/classes"
           classpathref="validator-split-core.classpath"
           debug="true"
           encoding="UTF-8"
           includeantruntime="false"
           nowarn="true"
           release="${build.java.target.version}"
           >
      <src path="${validator.basedir}/src"/>
      <src path="${validator.build.basedir}/builtSrc"/>
      <exclude name="**/servlet/Main.java" />
    </javac>
  </target>


  <path id="validator-split-core.classpath">
    <!-- This should be the same as validator.classpath but without jetty server components -->
    <fileset dir="${depsDir}/" includes="commons-fileupload2-core-${commons-fileupload-version}.jar" />
    <fileset dir="${depsDir}/" includes="commons-fileupload2-jakarta-servlet6-${commons-fileupload-version}.jar" />
    <fileset dir="${depsDir}/" includes="commons-io-${commons-io-version}.jar" />
    <fileset dir="${depsDir}/" includes="commons-text-${commons-text-version}.jar" />
    <fileset dir="${depsDir}/" includes="icu4j-${icu4j-version}.jar" />
    <fileset dir="${depsDir}/" includes="jakarta.json-${jakarta.json-version}.jar" />
    <fileset dir="${depsDir}/" includes="jetty-client-${jetty-version}.jar" />
    <fileset dir="${depsDir}/" includes="jetty-http-${jetty-version}.jar" />
    <fileset dir="${depsDir}/" includes="jetty-io-${jetty-version}.jar" />
    <fileset dir="${depsDir}/" includes="jetty-util-${jetty-version}.jar" />
    <fileset dir="${depsDir}/" includes="jakarta.servlet-api-${jakarta.servlet-api-version}.jar" />
    <fileset dir="${depsDir}/" includes="log4j-${log4j-version}.jar" />
    <fileset dir="${depsDir}/" includes="htmlunit-csp-${htmlunit-csp-version}.jar" />
    <pathelement location="css-validator/css-validator.jar"/>
    <pathelement location="${jarsDir}/galimatias.jar"/>
    <pathelement location="${jarsDir}/htmlparser.jar"/>
    <pathelement location="${jarsDir}/langdetect.jar"/>
    <pathelement location="${jing-shaded-jar}"/>
  </path>

  <path id="validator-split-core.runtime.classpath">
    <!-- The ones required for a simple run of vnu-core.jar -->
    <fileset dir="${depsDir}/" includes="commons-logging-${commons-logging-version}.jar" />
    <fileset dir="${depsDir}/" includes="commons-logging-${commons-logging-version}-adaptesr.jar" />
    <fileset dir="${depsDir}/" includes="commons-logging-${commons-logging-version}-api.jar" />
  </path>

  <target name="validator-split-core-jar" depends="validator-split-core">
    <jar destfile="${validator.build.basedir}/vnu-core.jar"
         basedir="${validator.build.basedir}/core/classes"
         >
      <fileset dir="${validator.build.basedir}/resources"/>
      <manifest>
        <attribute name="Main-Class" value="nu.validator.client.SimpleCommandLineValidator"/>
        <attribute name="Implementation-Title" value="Core &amp; CLI of The Nu Markup Checker (v.Nu)"/>
        <attribute name="Implementation-Version" value="${version}"/>
        <attribute name="Implementation-Vendor" value="http://validator.github.io/validator/"/>
      </manifest>
    </jar>
  </target>

  <target name="validator-split-core-jar-run" depends="validator-split-core-jar">
    <tempfile property="temp.html.file" destdir="${validator.build.basedir}" prefix="minDoc" suffix=".html" deleteonexit="true"/>
    <echo file="${temp.html.file}">
      &lt;!doctype html&gt;&lt;html lang=""&gt;&lt;meta charset=utf-8&gt;&lt;title&gt;test&lt;/title&gt;
    </echo>
    <java classname="nu.validator.client.SimpleCommandLineValidator" fork="true" failonerror="true">
      <classpath>
        <path refid="validator-split-core.classpath"/>
        <path refid="validator-split-core.runtime.classpath"/>
        <path location="${validator.build.basedir}/vnu-core.jar"/>
      </classpath>
      <arg value="--verbose"/>
      <arg value="${temp.html.file}"/>
    </java>
  </target>


  <path id="validator-split-server.classpath">
    <fileset dir="${depsDir}/" includes="jakarta.servlet-api-${jakarta.servlet-api-version}.jar" />
    <fileset dir="${depsDir}/" includes="jetty-server-${jetty-version}.jar" />
    <fileset dir="${depsDir}/" includes="jetty-ee10-servlet-${jetty-version}.jar" />
    <fileset dir="${depsDir}/" includes="jetty-util-${jetty-version}.jar" />
    <fileset dir="${depsDir}/" includes="log4j-${log4j-version}.jar" />
    <pathelement path="${validator.build.basedir}/core/classes/"/>
  </path>

  <path id="validator-split-server.runtime.classpath">
    <!-- The ones required for a simple run of vnu-server.jar -->
    <pathelement location="${depsDir}/jetty-client-${jetty-version}.jar" />
    <pathelement location="${depsDir}/jetty-http-${jetty-version}.jar" />
    <pathelement location="${depsDir}/jetty-io-${jetty-version}.jar" />
    <pathelement location="${depsDir}/jetty-security-${jetty-version}.jar" />
    <pathelement location="${depsDir}/jetty-session-${jetty-version}.jar" />
    <pathelement location="${depsDir}/slf4j-api-${slf4j-api-version}.jar"/>
    <pathelement location="${depsDir}/slf4j-log4j12-${slf4j-log4j12-version}.jar"/>
  </path>

  <target name="validator-split-server"
          depends="validator-split-core, dl-deps-jetty">
    <mkdir dir="${validator.build.basedir}/server/classes"/>
    <javac srcdir="${validator.basedir}/src"
           destdir="${validator.build.basedir}/server/classes"
           classpathref="validator-split-server.classpath"
           debug="true"
           encoding="UTF-8"
           includeantruntime="false"
           nowarn="true"
           release="${build.java.target.version}"
           >
        <include name="**/servlet/Main.java" />
      </javac>
  </target>

  <target name="validator-split-server-jar" depends="validator-split-server">
    <jar destfile="${validator.build.basedir}/vnu-server.jar"
         basedir="${validator.build.basedir}/server/classes"
         >
      <manifest>
        <attribute name="Main-Class" value="nu.validator.servlet.Main"/>
        <attribute name="Implementation-Title" value="Standalone server of The Nu Markup Checker (v.Nu)"/>
        <attribute name="Implementation-Version" value="${version}"/>
        <attribute name="Implementation-Vendor" value="http://validator.github.io/validator/"/>
      </manifest>
    </jar>
  </target>

  <target name="validator-split-server-jar-run" depends="validator-split-server-jar">
    <java classname="nu.validator.servlet.Main" fork="true" failonerror="true">
      <classpath>
        <path refid="validator-split-server.classpath"/>
        <path refid="validator-split-server.runtime.classpath"/>
        <path refid="validator-split-core.classpath"/>
        <path refid="validator-split-core.runtime.classpath"/>
        <path refid="validator.classpath"/>
        <path location="${validator.build.basedir}/vnu-server.jar"/>
      </classpath>
    </java>
  </target>


  <target name="validator-split-client">
    <mkdir dir="${validator.build.basedir}/client/classes"/>
    <javac srcdir="${validator.basedir}/src"
           destdir="${validator.build.basedir}/client/classes"
           debug="true"
           encoding="UTF-8"
           includeantruntime="false"
           nowarn="true"
           release="${build.java.target.version}"
           >
      <include name="nu/validator/client/HttpClient.java" />
    </javac>
  </target>

  <target name="validator-split-client-jar" depends="validator-split-client">
    <jar destfile="${validator.build.basedir}/vnu-client.jar"
         basedir="${validator.build.basedir}/client/classes"
         >
      <manifest>
        <attribute name="Main-Class" value="nu.validator.client.HttpClient"/>
        <attribute name="Implementation-Title" value="HTTP Client for The Nu Markup Checker (v.Nu)"/>
        <attribute name="Implementation-Version" value="${version}"/>
        <attribute name="Implementation-Vendor" value="http://validator.github.io/validator/"/>
      </manifest>
    </jar>
  </target>

  <target name="validator-split-client-jar-run" depends="validator-split-client-jar">
    <tempfile property="temp.html.file" destdir="${validator.build.basedir}" prefix="minDoc" suffix=".html" deleteonexit="true"/>
    <echo file="${temp.html.file}">
      &lt;!doctype html&gt;&lt;html lang=""&gt;&lt;meta charset=utf-8&gt;&lt;title&gt;test&lt;/title&gt;
    </echo>
    <java jar="${validator.build.basedir}/vnu-client.jar" fork="true" failonerror="true">
<!--       <sysproperty key="nu.validator.client.port" value="8080"/> -->
<!--       <sysproperty key="nu.validator.client.path" value="/vnu"/> -->
      <arg value="${temp.html.file}"/>
    </java>
  </target>

  <target name="validator-merge-split" depends="validator-split-core, validator-split-client, validator-split-server">
    <delete dir="${validator.build.basedir}/merged-split"/>
    <mkdir dir="${validator.build.basedir}/merged-split"/>
    <copy todir="${validator.build.basedir}/merged-split">
      <fileset dir="${validator.build.basedir}/core"/>
      <fileset dir="${validator.build.basedir}/client"/>
      <fileset dir="${validator.build.basedir}/server"/>
    </copy>
  </target>

  <target name="validator-compare-full-and-merged-split" depends="validator-merge-split, validator-build">
    <exec osfamily="unix" executable="diff" failonerror="true">
      <arg value="-r"></arg>
      <arg value="${validator.build.basedir}/full"></arg>
      <arg value="${validator.build.basedir}/merged-split"></arg>
    </exec>
  </target>

  <target name="validator-clean">
    <delete dir="${validator.build.basedir}"/>
    <deleteFileWithEmptyParent file="${jarsDir}/validator.jar"/>
    <delete dir="build/schema"/>
  </target>

  <target name="validator-jar" depends="validator-build">
    <mkdir dir="${validator.basedir}/jars"/>
    <jar destfile="${jarsDir}/validator.jar" basedir="${validator.build.basedir}/full/classes" excludes="**/*.java">
      <fileset dir="${validator.build.basedir}/resources"/>
    </jar>
  </target>

  <target name="validator-javadoc-jar"
          depends="
          validator-emitters,
          cssvalidator-build,
          galimatias-jar,
          htmlparser-jar,
          jing-shade,
          langdetect-jar,
          dl-deps,
          dl-deps-modules,
          dl-deps-jetty,
          cssvalidator-javadoc-jar,
          galimatias-javadoc-jar,
          htmlparser-javadoc-jar,
          jing-javadoc-jar,
          langdetect-javadoc-jar">
    <property name="javadoc-dir" value="${dist}/javadoc" />
    <javadoc destdir="${javadoc-dir}" additionalparam="-Xdoclint:none" classpathref="validator.classpath">
      <fileset dir="${validator.basedir}/src">
        <exclude name="META-INF/**"/>
        <exclude name="nu/validator/datatype/data/encodings.json"/>
        <exclude name="nu/validator/datatype/data/generate-encoding-data.py"/>
        <exclude name="nu/validator/gnu/xml/aelfred2/COPYING"/>
        <exclude name="nu/validator/gnu/xml/aelfred2/README"/>
        <exclude name="nu/validator/gnu/xml/aelfred2/package.html"/>
        <exclude name="nu/validator/localentities/files/**"/>
      </fileset>
      <fileset dir="${validator.build.basedir}/builtSrc"/>
    </javadoc>
    <jar destfile="${validator-javadoc-jar}">
      <fileset dir="${javadoc-dir}" />
      <zipfileset src="${jing-javadoc-jar}"/>
      <zipfileset src="${cssvalidator-javadoc-jar}"/>
      <zipfileset src="${galimatias-javadoc-jar}"/>
      <zipfileset src="${htmlparser-javadoc-jar}"/>
      <zipfileset src="${langdetect-javadoc-jar}"/>
    </jar>
    <delete dir="${javadoc-dir}"/>
    <delete file="${cssvalidator-javadoc-jar}"/>
    <delete file="${galimatias-javadoc-jar}"/>
    <delete file="${htmlparser-javadoc-jar}"/>
    <delete file="${jing-javadoc-jar}"/>
    <delete file="${langdetect-javadoc-jar}"/>
  </target>
  <target name="validator-sources-jar"
          depends="validator-emitters,
          cssvalidator-sources-jar,
          galimatias-sources-jar,
          htmlparser-sources-jar,
          jing-sources-jar,
          langdetect-sources-jar">
    <jar destfile="${validator-sources-jar}">
      <fileset dir="${validator.basedir}/src"/>
      <fileset dir="${validator.build.basedir}/builtSrc"/>
      <zipfileset src="${jing-sources-jar}"/>
      <zipfileset src="${cssvalidator-sources-jar}"/>
      <zipfileset src="${galimatias-sources-jar}"/>
      <zipfileset src="${htmlparser-sources-jar}"/>
      <zipfileset src="${langdetect-sources-jar}"/>
    </jar>
    <delete file="${cssvalidator-sources-jar}"/>
    <delete file="${galimatias-sources-jar}"/>
    <delete file="${htmlparser-sources-jar}"/>
    <delete file="${jing-sources-jar}"/>
    <delete file="${langdetect-sources-jar}"/>
  </target>
  <target name="validator-artifacts" depends="dl-deps-antlib, validator-jar, validator-javadoc-jar, validator-sources-jar, jing-shade">
    <artifact:pom
      id="pom"
      groupId="nu.validator"
      artifactId="validator"
      version="${version.number}"
      name="The Nu Html Checker (vnu)"
      description="An HTML-checking library (used by https://validator.w3.org/nu/)"
      url="https://validator.github.io/validator/"
      packaging="jar">
      <license
        name="The MIT License"
        distribution="repo"
        url="https://raw.githubusercontent.com/validator/validator/main/LICENSE"/>
      <scm
        connection="scm:git:git://github.com/validator/validator.git"
        developerConnection="scm:git:git://github.com/validator/validator.git"
        url="https://github.com/validator/validator"/>
      <issueManagement
        system="GitHub Issues"
        url="https://github.com/validator/validator/issues"/>
      <ciManagement
        system="GitHub Actions"
        url="https://github.com/validator/validator/actions"/>
      <developer
        name="Henri Sivonen"
        id="hsivonen"
        email="hsivonen@iki.fi"
        url="https://github.com/hsivonen"/>
      <developer
        name="sideshowbarker"
        id="sideshowbarker"
        email="sideshowbarker@gmail.com"
        url="https://github.com/sideshowbarker"/>
      <dependency groupId="com.ibm.icu" artifactId="icu4j" version="${icu4j-version}"/>
      <dependency groupId="org.htmlunit" artifactId="htmlunit-csp" version="${htmlunit-csp-version}"/>
      <dependency groupId="commons-codec" artifactId="commons-codec" version="${commons-codec-version}"/>
      <dependency groupId="org.apache.commons" artifactId="commons-fileupload2-core" version="${commons-fileupload-version}"/>
      <dependency groupId="org.apache.commons" artifactId="commons-fileupload2-jakarta-servlet6" version="${commons-fileupload-version}"/>
      <dependency groupId="commons-io" artifactId="commons-io" version="${commons-io-version}"/>
      <dependency groupId="commons-logging" artifactId="commons-logging" version="${commons-logging-version}"/>
      <dependency groupId="org.apache.commons" artifactId="commons-text" version="${commons-text-version}"/>
      <dependency groupId="isorelax" artifactId="isorelax" version="20030108"/>
      <dependency groupId="jakarta.servlet" artifactId="jakarta.servlet-api" version="${jakarta.servlet-api-version}"/>
      <dependency groupId="log4j" artifactId="log4j" version="${log4j-version}"/>
      <dependency groupId="net.sf.saxon" artifactId="Saxon-HE" version="9.6.0-4"/>
      <dependency groupId="org.eclipse.jetty" artifactId="jetty-client" version="${jetty-version}"/>
      <dependency groupId="org.eclipse.jetty" artifactId="jetty-http" version="${jetty-version}"/>
      <dependency groupId="org.eclipse.jetty" artifactId="jetty-io" version="${jetty-version}"/>
      <dependency groupId="org.eclipse.jetty" artifactId="jetty-security" version="${jetty-version}"/>
      <dependency groupId="org.eclipse.jetty" artifactId="jetty-server" version="${jetty-version}"/>
      <dependency groupId="org.eclipse.jetty.ee10" artifactId="jetty-ee10-servlets" version="${jetty-version}"/>
      <dependency groupId="org.eclipse.jetty" artifactId="jetty-session" version="${jetty-version}"/>
      <dependency groupId="org.eclipse.jetty" artifactId="jetty-util" version="${jetty-version}"/>
      <dependency groupId="org.glassfish" artifactId="jakarta.json" version="${jakarta.json-version}"/>
    </artifact:pom>
    <artifact:writepom pomRefId="pom" file="${dist}/validator-${version.number}.pom"/>
    <jar destfile="${validator-jar}" duplicate="preserve">
      <zipfileset src="${jarsDir}/validator.jar"/>
      <zipfileset src="css-validator/css-validator.jar"/>
      <zipfileset src="${jarsDir}/galimatias.jar"/>
      <zipfileset src="${jarsDir}/htmlparser.jar"/>
      <zipfileset src="${jing-shaded-jar}"/>
      <zipfileset src="${jarsDir}/langdetect.jar"/>
      <manifest>
        <attribute name="Implementation-Title" value="The Nu Markup Checker (v.Nu)"/>
        <attribute name="Implementation-Version" value="${version}"/>
        <attribute name="Implementation-Vendor" value="http://validator.github.io/validator/"/>
      </manifest>
      <service type="nu.validator.vendor.relaxng.datatype.DatatypeLibraryFactory">
        <provider classname="nu.validator.vendor.thaiopensource.datatype.xsd.DatatypeLibraryFactoryImpl"/>
        <provider classname="nu.validator.datatype.Html5DatatypeLibraryFactory"/>
      </service>
    </jar>
    <mkdir dir="${validator-bundle-dir}" />
    <move toDir="${validator-bundle-dir}">
      <fileset dir="${dist}">
        <include name="validator-${version.number}*.pom*" />
        <include name="validator-${version.number}*.jar*" />
      </fileset>
    </move>
    <checksum todir="${validator-bundle-dir}" fileext=".md5">
      <fileset dir="${validator-bundle-dir}">
        <exclude name="**/*.md5"/>
        <exclude name="**/*.sha1"/>
        <exclude name="**/*.asc"/>
      </fileset>
    </checksum>
    <checksum todir="${validator-bundle-dir}" algorithm="sha1" fileext=".sha1">
      <fileset dir="${validator-bundle-dir}">
        <exclude name="**/*.md5"/>
        <exclude name="**/*.asc"/>
      </fileset>
    </checksum>
  </target>
  <target name="validator-bundle">
    <mkdir dir="${validator-bundle-dir}/nu" />
    <zip destfile="${validator-bundle-jar}">
      <zipfileset dir="${dist}/nu" prefix="nu" />
    </zip>
  </target>

  <target name="maven-test" depends="validator-artifacts">
    <exec executable="bash" dir="${basedir}/tests/maven-integration" failonerror="true">
      <arg value="test-maven-integration.sh"/>
      <arg value="local"/>
    </exec>
  </target>

  <property name="python-executable" value="python3"/>

  <target name="validator-resources">
    <local name="filesDir"/>
    <property name="filesDir" value="${validator.build.basedir}/resources/nu/validator/localentities/files"/>
    <mkdir dir="${validator.build.basedir}/resources/nu/validator/localentities/files"/>

    <propertyfile file="${filesDir}/misc.properties">
      <entry key="nu.validator.servlet.service-name" value="${validator.param.serviceName}"/>
      <entry key="nu.validator.servlet.results-title" value="${validator.param.resultsTitle}"/>
      <entry key="nu.validator.servlet.version" value="${version}"/>
      <entry key="nu.validator.servlet.user-agent" value="${validator.param.userAgent}"/>
    </propertyfile>

    <copy file="${validator.param.aboutFile}" tofile="${filesDir}/about.html"/>
    <copy file="${validator.param.presetsFile}" tofile="${filesDir}/presets"/>
    <copy file="${validator.param.scriptFile}" tofile="${filesDir}/script.js"/>
    <copy file="${validator.param.stylesheetFile}" tofile="${filesDir}/style.css"/>
    <copy file="${validator.basedir}/docs/wiki/Microsyntax-descriptions.md" tofile="${filesDir}/syntax-descriptions"/>
    <copy file="${validator.basedir}/resources/alt_advice.html" tofile="${filesDir}/vnu-alt-advice"/>
    <copy file="${validator.basedir}/resources/language-subtag-registry.txt" tofile="${filesDir}/subtag-registry"/>
    <copy file="${validator.basedir}/resources/spec/html5spec-single.html" tofile="${filesDir}/html5spec"/>

    <copy todir="${filesDir}" preservelastmodified="true" flatten="true">
      <fileset dir="${validator.basedir}">
        <include name="site/icon.png"/>
        <include name="resources/language-profiles-list.txt"/>
        <include name="resources/log4j.properties"/>
      </fileset>
    </copy>

    <copy todir="${filesDir}/language-profiles" preservelastmodified="true" flatten="true">
      <fileset dir="resources/language-profiles"/>
    </copy>

    <exec executable="${python-executable}" failonerror="true" failifexecutionfails="true">
      <env key="JAVA_HOME" value="${java.home}"/>
      <arg file="build/build.py"/>
      <arg value="localent"/> <!-- prepareLocalEntityJar() -->
    </exec>
  </target>

  <property name="cssvalidator-base" location="${dist}/cssvalidator-${version}" />
  <property name="cssvalidator-src" location="css-validator/org" />
  <property name="cssvalidator-javadoc-jar" value="${cssvalidator-base}-javadoc.jar" />
  <property name="cssvalidator-sources-jar" value="${cssvalidator-base}-sources.jar" />
  <property name="cssvalidator.basedir" location="css-validator" />
  <target name="cssvalidator-build" depends="dl-deps, dl-deps-modules" unless="${use-system-cssvalidator}">
    <ant dir="${cssvalidator.basedir}" antfile="build.xml" target="jar-without-dependencies" inheritAll="false"/>
  </target>
  <target name="cssvalidator-clean" unless="${use-system-cssvalidator}">
    <ant dir="${cssvalidator.basedir}" antfile="build.xml" target="clean" inheritAll="false"/>
  </target>
  <target name="cssvalidator-javadoc-jar">
    <javadoc destdir="${javadoc-dir}" additionalparam="-html5 -Xdoclint:none">
      <fileset dir="${cssvalidator-src}"/>
    </javadoc>
    <jar destfile="${cssvalidator-javadoc-jar}">
      <fileset dir="${javadoc-dir}" />
    </jar>
    <delete dir="${javadoc-dir}"/>
  </target>
  <target name="cssvalidator-sources-jar">
    <jar destfile="${cssvalidator-sources-jar}">
      <fileset dir="${cssvalidator-src}"/>
    </jar>
  </target>
  <target name="cssvalidator-artifacts" depends="dl-deps-antlib, cssvalidator-build, cssvalidator-javadoc-jar, cssvalidator-sources-jar">
  </target>

  <property name="galimatias-base" location="${dist}/galimatias-${version}" />
  <property name="galimatias-src" location="galimatias/src" />
  <property name="galimatias-javadoc-jar" value="${galimatias-base}-javadoc.jar" />
  <property name="galimatias-sources-jar" value="${galimatias-base}-sources.jar" />
  <property name="galimatias.basedir" location="galimatias" />
  <property name="galimatias.build.basedir" location="build/galimatias" />
  <path id="galimatias.classpath">
    <fileset dir="${depsDir}/" includes="icu4j-${icu4j-version}.jar" />
  </path>
  <target name="galimatias-build" depends="dl-deps, dl-deps-modules" unless="${use-system-galimatias}">
    <mkdir dir="${galimatias.build.basedir}/classes"/>
    <javac srcdir="${galimatias.basedir}/src/main/java"
           destdir="${galimatias.build.basedir}/classes"
           classpathref="galimatias.classpath"
           debug="true"
           encoding="UTF-8"
           includeantruntime="false"
           nowarn="true"
           release="${build.java.target.version}"
           />
  </target>
  <target name="galimatias-clean" unless="${use-system-galimatias}">
    <delete dir="${galimatias.build.basedir}"/>
    <deleteFileWithEmptyParent file="${jarsDir}/galimatias.jar"/>
  </target>
  <target name="galimatias-jar" depends="galimatias-build" unless="${use-system-galimatias}">
    <jar destfile="${jarsDir}/galimatias.jar" basedir="${galimatias.build.basedir}/classes"/>
  </target>
  <target name="galimatias-javadoc-jar">
    <javadoc destdir="${javadoc-dir}"
             additionalparam="-html5 -Xdoclint:none"
             classpathref="galimatias.classpath">
      <fileset dir="${galimatias-src}"/>
    </javadoc>
    <jar destfile="${galimatias-javadoc-jar}">
      <fileset dir="${javadoc-dir}" />
    </jar>
    <delete dir="${javadoc-dir}"/>
  </target>
  <target name="galimatias-sources-jar">
    <jar destfile="${galimatias-sources-jar}">
      <fileset dir="${galimatias-src}"/>
    </jar>
  </target>
  <target name="galimatias-artifacts" depends="dl-deps-antlib, galimatias-jar, galimatias-javadoc-jar, galimatias-sources-jar"/>

  <property name="htmlparser-base" location="${dist}/htmlparser-${version}" />
  <property name="htmlparser-src" location="htmlparser/src" />
  <property name="htmlparser-javadoc-jar" value="${htmlparser-base}-javadoc.jar" />
  <property name="htmlparser-sources-jar" value="${htmlparser-base}-sources.jar" />
  <property name="htmlparser.basedir" location="htmlparser" />
  <property name="htmlparser.build.basedir" location="build/htmlparser" />
  <path id="htmlparser.classpath">
    <fileset dir="${depsDir}/" includes="icu4j-${icu4j-version}.jar" />
    <fileset dir="${depsDir}/" includes="jchardet-${jchardet-version}.jar" />
  </path>
  <target name="htmlparser-initialize" unless="${use-system-htmlparser}">
    <!-- copied over from htmlparser/pom.xml -->
    <delete dir="${htmlparser.build.basedir}/realsrc"/>
    <mkdir dir="${htmlparser.build.basedir}/realsrc"/>
    <copy todir="${htmlparser.build.basedir}/realsrc" preservelastmodified="true">
      <fileset dir="${htmlparser.basedir}/src"/>
    </copy>
  </target>
  <target name="htmlparser-process-sources" depends="htmlparser-initialize" unless="${use-system-htmlparser}">
    <!-- copied over from htmlparser/pom.xml -->
    <property name="translator.sources" value="${htmlparser.basedir}/translator-src"/>
    <property name="translator.classes" value="${htmlparser.build.basedir}/translator-classes"/>
    <mkdir dir="${translator.classes}"/>
    <javac srcdir="${translator.sources}" includes="nu/validator/htmlparser/generator/ApplyHotSpotWorkaround.java" destdir="${translator.classes}" includeantruntime="false"/>
    <java classname="nu.validator.htmlparser.generator.ApplyHotSpotWorkaround">
      <classpath>
        <pathelement location="${translator.classes}"/>
      </classpath>
      <arg value="${htmlparser.build.basedir}/realsrc/nu/validator/htmlparser/impl/Tokenizer.java"/>
      <arg value="${htmlparser.build.basedir}/realsrc/nu/validator/htmlparser/impl/HotSpotWorkaround.txt"/>
    </java>
  </target>
  <target name="htmlparser-build" depends="dl-deps, dl-deps-modules, htmlparser-process-sources" unless="${use-system-htmlparser}">
    <mkdir dir="${htmlparser.build.basedir}/classes"/>
    <javac srcdir="${htmlparser.basedir}/src"
           destdir="${htmlparser.build.basedir}/classes"
           classpathref="htmlparser.classpath"
           debug="true"
           encoding="UTF-8"
           excludes="nu/validator/htmlparser/xom/**"
           includeantruntime="false"
           nowarn="true"
           release="${build.java.target.version}"
           />
  </target>
  <target name="htmlparser-clean" unless="${use-system-htmlparser}">
    <delete dir="${htmlparser.build.basedir}"/>
    <deleteFileWithEmptyParent file="${jarsDir}/htmlparser.jar"/>
  </target>
  <target name="htmlparser-jar" depends="htmlparser-build" unless="${use-system-htmlparser}">
    <jar destfile="${jarsDir}/htmlparser.jar" basedir="${htmlparser.build.basedir}/classes"/>
  </target>
  <target name="htmlparser-javadoc-jar" depends="htmlparser-process-sources">
    <javadoc destdir="${javadoc-dir}"
             additionalparam="-html5 -Xdoclint:none"
             classpathref="htmlparser.classpath">
      <fileset dir="${htmlparser.build.basedir}/realsrc">
        <include name="**/*.java"/>
        <exclude name="nu/validator/htmlparser/xom/**"/>
      </fileset>
    </javadoc>
    <jar destfile="${htmlparser-javadoc-jar}">
      <fileset dir="${javadoc-dir}" />
    </jar>
    <delete dir="${javadoc-dir}"/>
  </target>
  <target name="htmlparser-sources-jar" depends="htmlparser-process-sources">
    <jar destfile="${htmlparser-sources-jar}">
      <fileset dir="${htmlparser.build.basedir}/realsrc"/>
    </jar>
  </target>
  <target name="htmlparser-artifacts" depends="dl-deps-antlib, htmlparser-jar, htmlparser-javadoc-jar, htmlparser-sources-jar"/>

  <property name="jing.basedir" location="jing-trang" />
  <property name="jing-base" location="${dist}/jing-${version}" />
  <property name="jing-src" location="jing-trang/mod" />
  <property name="jing-javadoc-jar" value="${jing-base}-javadoc.jar" />
  <property name="jing-sources-jar" value="${jing-base}-sources.jar" />
  <property name="jing-util-src" location="${jing-src}/util/src/main" />
  <property name="jing-datatype-src" location="${jing-src}/datatype/src/main" />
  <property name="jing-rng-parse-src" location="${jing-src}/rng-parse/src/main" />
  <property name="jing-validate-src" location="${jing-src}/validate/src/main" />
  <property name="jing-rng-validate-src" location="${jing-src}/rng-validate/src/main" />
  <property name="jing-nvdl-src" location="${jing-src}/nvdl/src/main" />
  <property name="jing-schematron-src" location="${jing-src}/schematron/src/main" />
  <property name="jing.basedir" location="jing-trang" />
  <target name="jing-build" unless="${use-system-jing}">
    <ant dir="${jing.basedir}" antfile="build.xml" inheritAll="false"/>
  </target>
  <target name="jing-shade" depends="jing-build" unless="${use-system-jing}">
    <exec executable="python3" failonerror="true">
      <arg value="build/shade-with-maven.py"/>
    </exec>
  </target>
  <target name="jing-clean" unless="${use-system-jing}">
    <ant dir="${jing.basedir}" antfile="build.xml" target="clean" inheritAll="false"/>
    <delete file="${jing.basedir}/modbuild.xml"/>
    <delete file="${jing.basedir}/modules.xml"/>
    <delete file="${jing-shaded-jar}"/>
  </target>
  <target name="jing-javadoc-jar">
    <javadoc destdir="${javadoc-dir}" additionalparam="-html5 -Xdoclint:none">
      <fileset dir="${jing-util-src}"/>
      <fileset dir="${jing-datatype-src}"/>
      <fileset dir="${jing-validate-src}"/>
      <fileset dir="${jing-rng-parse-src}"/>
      <fileset dir="${jing-rng-validate-src}"/>
      <fileset dir="${jing-nvdl-src}"/>
      <fileset dir="${jing-schematron-src}"/>
      <classpath>
        <fileset dir="jing-trang/lib/">
          <include name="**/*.jar" />
        </fileset>
      </classpath>
    </javadoc>
    <jar destfile="${jing-javadoc-jar}">
      <fileset dir="${javadoc-dir}" />
    </jar>
    <delete dir="${javadoc-dir}"/>
  </target>
  <target name="jing-sources-jar">
    <jar destfile="${jing-sources-jar}">
      <fileset dir="${jing-util-src}"/>
      <fileset dir="${jing-datatype-src}"/>
      <fileset dir="${jing-validate-src}"/>
      <fileset dir="${jing-rng-parse-src}"/>
      <fileset dir="${jing-rng-validate-src}"/>
      <fileset dir="${jing-nvdl-src}"/>
      <fileset dir="${jing-schematron-src}"/>
    </jar>
  </target>
  <target name="jing-artifacts" depends="dl-deps-antlib, jing-build, jing-javadoc-jar, jing-sources-jar"/>

  <property name="langdetect-base" location="${dist}/langdetect-${version}" />
  <property name="langdetect-src" location="langdetect/src" />
  <property name="langdetect-javadoc-jar" value="${langdetect-base}-javadoc.jar" />
  <property name="langdetect-sources-jar" value="${langdetect-base}-sources.jar" />
  <property name="langdetect.basedir" location="langdetect" />
  <property name="langdetect.build.basedir" location="build/langdetect" />
  <path id="langdetect.classpath">
    <fileset dir="${depsDir}/" includes="jakarta.json-${jakarta.json-version}.jar" />
  </path>
  <target name="langdetect-build" depends="dl-deps, dl-deps-modules" unless="${use-system-langdetect}">
    <mkdir dir="${langdetect.build.basedir}/classes"/>
    <javac srcdir="${langdetect.basedir}/src"
           destdir="${langdetect.build.basedir}/classes"
           classpathref="langdetect.classpath"
           debug="true"
           encoding="UTF-8"
           includeantruntime="false"
           nowarn="true"
           release="${build.java.target.version}"
           />
  </target>
  <target name="langdetect-clean" unless="${use-system-langdetect}">
    <delete dir="${langdetect.build.basedir}"/>
    <deleteFileWithEmptyParent file="${jarsDir}/langdetect.jar"/>
  </target>
  <target name="langdetect-jar" depends="langdetect-build" unless="${use-system-langdetect}">
    <copy file="${langdetect.basedir}/src/com/cybozu/labs/langdetect/util/messages.properties" todir="${langdetect.build.basedir}/classes/com/cybozu/labs/langdetect/util"/>
      <jar destfile="${jarsDir}/langdetect.jar" basedir="${langdetect.build.basedir}/classes"/>
  </target>
  <target name="langdetect-javadoc-jar">
    <javadoc destdir="${javadoc-dir}"
             additionalparam="-html5 -Xdoclint:none"
             classpathref="langdetect.classpath">
      <fileset dir="${langdetect-src}"/>
    </javadoc>
    <jar destfile="${langdetect-javadoc-jar}">
      <fileset dir="${javadoc-dir}" />
    </jar>
    <delete dir="${javadoc-dir}"/>
  </target>
  <target name="langdetect-sources-jar">
    <jar destfile="${langdetect-sources-jar}">
      <fileset dir="${langdetect-src}"/>
    </jar>
  </target>
  <target name="langdetect-artifacts" depends="dl-deps-antlib, langdetect-jar, langdetect-javadoc-jar, langdetect-sources-jar"/>

</project>
