<!--
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:artifact="antlib:org.apache.maven.artifact.ant">
  <tstamp/>
  <property name="dist" location="dist" />
  <loadfile property="version" srcfile="${dist}/VERSION" failonerror="false" />
  <property name="version" value="nightly-${DSTAMP}" />
  <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}.jar" />
  <property name="validator-javadoc-jar" value="${dist}/${artifactId}-${version}-javadoc.jar" />
  <property name="validator-sources-jar" value="${dist}/${artifactId}-${version}-sources.jar" />
  <property name="validator-bundle-jar" value="${dist}/${artifactId}-${version}-bundle.jar" />
  <property name="commons-codec-version" value="1.15" />
  <property name="commons-fileupload-version" value="1.4" />
  <property name="commons-io-version" value="2.11.0" />
  <property name="commons-logging-version" value="1.2" />
  <property name="httpclient-version" value="4.5.13" />
  <property name="httpcore-version" value="4.4.14" />
  <property name="icu4j-version" value="70.1" />
  <property name="javax.servlet-api-version" value="4.0.1" />
  <property name="jchardet-version" value="1.0" />
  <property name="jetty-version" value="9.4.44.v20210927" />
  <property name="log4j-version" value="1.2.17" />
  <property name="salvation-version" value="2.7.2" />
  <!-- module dependencies -->
  <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="mail-version" value="1.4.7" />
  <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="build" depends="jar"/>
  <target name="clean">
    <delete dir="${dist}"/>
  </target>
  <target name="jar">
    <jar destfile="${dist}/vnu.jar" duplicate="preserve">
      <zipgroupfileset dir="../jars" includes="*.jar"/>
      <zipfileset src="../css-validator/css-validator.jar"/>
      <zipfileset src="../jing-trang/build/jing.jar"/>
      <zipfileset src="../jing-trang/lib/saxon9.jar"/>
      <zipfileset src="../dependencies/commons-codec-${commons-codec-version}.jar"/>
      <zipfileset src="../dependencies/commons-fileupload-${commons-fileupload-version}.jar"/>
      <zipfileset src="../dependencies/commons-io-${commons-io-version}.jar"/>
      <zipfileset src="../dependencies/commons-logging-${commons-logging-version}.jar"/>
      <zipfileset src="../dependencies/commons-logging-${commons-logging-version}-adapters.jar"/>
      <zipfileset src="../dependencies/commons-logging-${commons-logging-version}-api.jar"/>
      <zipfileset src="../dependencies/httpclient-${httpclient-version}.jar"/>
      <zipfileset src="../dependencies/httpcore-${httpcore-version}.jar"/>
      <zipfileset src="../dependencies/icu4j-${icu4j-version}.jar"/>
      <zipfileset src="../dependencies/javax.servlet-api-${javax.servlet-api-version}.jar"/>
      <zipfileset src="../dependencies/jchardet-${jchardet-version}.jar"/>
      <zipfileset src="../dependencies/jetty-http-${jetty-version}.jar">
        <exclude name="META-INF/services/**"/>
      </zipfileset>
      <zipfileset src="../dependencies/jetty-io-${jetty-version}.jar"/>
      <zipfileset src="../dependencies/jetty-security-${jetty-version}.jar"/>
      <zipfileset src="../dependencies/jetty-server-${jetty-version}.jar"/>
      <zipfileset src="../dependencies/jetty-servlet-${jetty-version}.jar"/>
      <zipfileset src="../dependencies/jetty-servlets-${jetty-version}.jar"/>
      <zipfileset src="../dependencies/jetty-util-${jetty-version}.jar"/>
      <zipfileset src="../dependencies/jetty-util-ajax-${jetty-version}.jar"/>
      <zipfileset src="../dependencies/log4j-${log4j-version}.jar"/>
      <zipfileset src="../dependencies/salvation-${salvation-version}.jar"/>
      <!-- module dependencies -->
      <zipfileset src="../jing-trang/lib/ant.jar"/>
      <zipfileset src="../jing-trang/lib/ant-launcher.jar"/>
      <zipfileset src="../jing-trang/lib/isorelax.jar"/>
      <zipfileset src="../dependencies/avalon-framework-api-${avalon-framework-api-version}.jar"/>
      <zipfileset src="../dependencies/avalon-logkit-${avalon-logkit-version}.jar"/>
      <zipfileset src="../dependencies/cdi-api-${cdi-api-version}.jar"/>
      <zipfileset src="../dependencies/el-api-${el-api-version}.jar"/>
      <zipfileset src="../dependencies/javax.activation-${javax-activation-version}.jar"/>
      <zipfileset src="../dependencies/javax.inject-${javax-inject-version}.jar"/>
      <zipfileset src="../dependencies/javax.interceptor-api-${javax-interceptor-api-version}.jar"/>
      <zipfileset src="../dependencies/javax.jms-api-${javax-jms-api-version}.jar"/>
      <zipfileset src="../dependencies/jetty-jmx-${jetty-version}.jar"/>
      <zipfileset src="../dependencies/jsr305-${jsr305-version}.jar"/>
      <zipfileset src="../dependencies/mail-${mail-version}.jar"/>
      <zipfileset src="../dependencies/portlet-api-${portlet-api-version}.jar"/>
      <zipfileset src="../dependencies/slf4j-api-${slf4j-api-version}.jar"/>
      <zipfileset src="../dependencies/slf4j-log4j12-${slf4j-log4j12-version}.jar"/>
      <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="org.relaxng.datatype.DatatypeLibraryFactory">
        <provider classname="com.thaiopensource.datatype.xsd.DatatypeLibraryFactoryImpl"/>
        <provider classname="nu.validator.datatype.Html5DatatypeLibraryFactory"/>
      </service>
    </jar>
  </target>
  <target name="war">
    <mkdir dir="${dist}/war" />
    <echo file="${dist}/war/web.xml" append="false"
><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
      http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
      version="3.0">
    <display-name>validator.nu</display-name>
    <description>Mark-up validation service</description>
    <filter>
        <filter-name>inbound-size-limit-filter</filter-name>
        <filter-class>nu.validator.servlet.InboundSizeLimitFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>inbound-size-limit-filter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <filter>
        <filter-name>inbound-gzip-filter</filter-name>
        <filter-class>nu.validator.servlet.InboundGzipFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>inbound-gzip-filter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <filter>
        <filter-name>multipart-form-data-filter</filter-name>
        <filter-class>nu.validator.servlet.MultipartFormDataFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>multipart-form-data-filter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <servlet>
        <servlet-name>validator</servlet-name>
        <servlet-class>nu.validator.servlet.VerifierServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>validator</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
</web-app>
]]></echo>
    <echo file="${dist}/war/log4j.xml" append="false"
><![CDATA[<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
  <appender name="console" class="org.apache.log4j.ConsoleAppender">
    <param name="Target" value="System.out"/>
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%-5p %c{1} - %m%n"/>
    </layout>
  </appender>

  <root>
    <priority value ="info" />
    <appender-ref ref="console" />
  </root>

</log4j:configuration>
]]></echo>
    <unzip dest="${dist}/war/classes">
      <fileset dir="../jars">
        <include name="*.jar"/>
      </fileset>
    </unzip>
    <copy todir="${dist}/war/lib">
      <fileset file="../css-validator/css-validator.jar"/>
      <fileset file="../jing-trang/build/jing.jar"/>
      <fileset file="../jing-trang/lib/saxon9.jar"/>
      <fileset file="../dependencies/commons-codec-${commons-codec-version}.jar"/>
      <fileset file="../dependencies/commons-fileupload-${commons-fileupload-version}.jar"/>
      <fileset file="../dependencies/commons-io-${commons-io-version}.jar"/>
      <fileset file="../dependencies/commons-logging-${commons-logging-version}.jar"/>
      <fileset file="../dependencies/commons-logging-${commons-logging-version}-adapters.jar"/>
      <fileset file="../dependencies/commons-logging-${commons-logging-version}-api.jar"/>
      <fileset file="../dependencies/httpclient-${httpclient-version}.jar"/>
      <fileset file="../dependencies/httpcore-${httpcore-version}.jar"/>
      <fileset file="../dependencies/icu4j-${icu4j-version}.jar"/>
      <fileset file="../dependencies/salvation-${salvation-version}.jar"/>
      <fileset file="../dependencies/jchardet-${jchardet-version}.jar"/>
      <fileset file="../dependencies/log4j-${log4j-version}.jar"/>
      <fileset file="../dependencies/jetty-util-ajax-${jetty-version}.jar"/>
      <fileset file="../dependencies/jetty-util-${jetty-version}.jar"/>
    </copy>
    <war destfile="${dist}/vnu.war" webxml="${dist}/war/web.xml">
      <lib dir="${dist}/war/lib"/>
      <classes dir="${dist}/war/classes">
        <exclude name="**/*.java"/>
      </classes>
      <classes file="${dist}/war/log4j.xml"/>
      <service type="org.relaxng.datatype.DatatypeLibraryFactory">
        <provider classname="com.thaiopensource.datatype.xsd.DatatypeLibraryFactoryImpl"/>
        <provider classname="nu.validator.datatype.Html5DatatypeLibraryFactory"/>
      </service>
    </war>
    <delete dir="${dist}/war"></delete>
  </target>
  <target name="validator-javadoc-jar">
    <property name="javadoc-dir" value="${dist}/javadoc" />
    <javadoc destdir="${javadoc-dir}" additionalparam="-Xdoclint:none">
      <fileset dir="${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/datatype/Pattern.java"/>
        <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/**"/>
      </fileset>
    </javadoc>
    <jar destfile="${validator-javadoc-jar}">
      <fileset dir="${javadoc-dir}" />
    </jar>
    <delete dir="${javadoc-dir}"/>
  </target>
  <target name="validator-sources-jar">
    <jar destfile="${validator-sources-jar}">
      <fileset dir="${src}"/>
    </jar>
  </target>
  <target name="validator-artifacts" depends="validator-javadoc-jar, validator-sources-jar">
    <delete file="${dist}/VERSION" />
    <artifact:pom
      id="pom"
      groupId="nu.validator"
      artifactId="validator"
      version="${version}"
      name="The Nu Html Checker"
      description="An HTML-checking library (used by https://checker.html5.org/ and https://html5.validator.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://hsivonen.iki.fi/"/>
      <developer
        name="Michael[tm] Smith"
        id="sideshowbarker"
        email="mike@w3.org"
        url="https://people.w3.org/mike/"/>
      <dependency groupId="com.ibm.icu" artifactId="icu4j" version="${icu4j-version}"/>
      <dependency groupId="com.shapesecurity" artifactId="salvation" version="${salvation-version}"/>
      <dependency groupId="commons-codec" artifactId="commons-codec" version="${commons-codec-version}"/>
      <dependency groupId="commons-fileupload" artifactId="commons-fileupload" 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="isorelax" artifactId="isorelax" version="20030108"/>
      <dependency groupId="javax.servlet" artifactId="javax.servlet-api" version="${javax.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="nu.validator" artifactId="langdetect" version="1.2"/>
      <dependency groupId="nu.validator" artifactId="galimatias" version="0.1.3"/>
      <dependency groupId="nu.validator" artifactId="htmlparser" version="1.4.16"/>
      <dependency groupId="nu.validator" artifactId="cssvalidator" version="1.0.8"/>
      <dependency groupId="nu.validator" artifactId="jing" version="20200702VNU"/>
      <dependency groupId="org.apache.httpcomponents" artifactId="httpclient" version="${httpclient-version}"/>
      <dependency groupId="org.apache.httpcomponents" artifactId="httpcore" version="${httpcore-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" artifactId="jetty-servlets" version="${jetty-version}"/>
      <dependency groupId="org.eclipse.jetty" artifactId="jetty-util" version="${jetty-version}"/>
      <dependency groupId="org.eclipse.jetty" artifactId="jetty-util-ajax" version="${jetty-version}"/>
    </artifact:pom>
    <artifact:writepom pomRefId="pom" file="${dist}/validator-${version}.pom"/>
    <jar destfile="${validator-jar}" duplicate="preserve">
      <zipfileset src="../jars/validator.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="org.relaxng.datatype.DatatypeLibraryFactory">
        <provider classname="com.thaiopensource.datatype.xsd.DatatypeLibraryFactoryImpl"/>
        <provider classname="nu.validator.datatype.Html5DatatypeLibraryFactory"/>
      </service>
    </jar>
  </target>
  <target name="validator-bundle">
    <jar basedir="${dist}" destfile="${validator-bundle-jar}"/>
  </target>
  <import file=".ant/build-langdetect.xml"/>
  <import file=".ant/build-galimatias.xml"/>
  <import file=".ant/build-htmlparser.xml"/>
  <import file=".ant/build-cssvalidator.xml"/>
  <import file=".ant/build-jing.xml"/>
</project>
