<project>

    <import file="../ant/maven.xml" />

    <!--
    <mvn goal="compile" pomFile="${ant.file.get-dependency}/../../s2t/pom.xml" />
    -->
    <sequential>
        <mkdir dir="${ant.file.get-dependency}/../../s2t/target/classes" />
        <javac srcdir="${ant.file.get-dependency}/../../s2t/src"
               destdir="${ant.file.get-dependency}/../../s2t/target/classes"
               includeantruntime="false" source="1.8" target="1.8" encoding="UTF8" debug="true" optimize="yes" fork="yes">
            <compilerarg line="-Xlint:all" />
        </javac>
        <copy todir="${ant.file.get-dependency}/../../s2t/target/classes">
            <fileset dir="${ant.file.get-dependency}/../../s2t/resources" />
        </copy>
    </sequential>

    <!-- 简体转繁体 -->
    <macrodef name="copy-zh-CN-to-TW">
        <attribute name="dir" />
        <attribute name="todir" default="@{dir}" />
        <attribute name="encoding" default="GB18030" />
        <attribute name="overwrite" default="yes" />
        <element name="with-fileset" optional="no" />
        <element name="opt-mapper" optional="yes" />
        <element name="opt-filter" optional="yes" />
        <sequential>
            <copy todir="@{todir}" encoding="@{encoding}" outputencoding="@{encoding}" overwrite="@{overwrite}">
                <fileset dir="@{dir}">
                    <with-fileset />
                </fileset>
                <chainedmapper>
                    <mapper type="regexp" from="^(.*)_zh_CN\.(.*)" to="\1_zh_TW.\2" />
                    <opt-mapper />
                </chainedmapper>
                <filterchain>
                    <filterreader classname="cn.mailtech.zh.S2TFilter"
                                  classpath="${ant.file.get-dependency}/../../s2t/target/classes" />
                    <!-- 检查 filter 是否正确或存在遗漏
                         Find in project with file mask: *_zh_CN.*
                         pattern1 (match case, regex): _zh_CN\.
                         pattern2 (match case, regex): ([^_]|^)zh_CN|zh_CN([^.]|$)
                    -->
                    <replacestring from="_zh_CN." to="_zh_TW." />
                    <opt-filter />
                </filterchain>
            </copy>
        </sequential>
    </macrodef>

</project>
