<commit_before><?xml version="1.0" encoding="UTF-8"?>
<!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at
 
      http://www.apache.org/licenses/LICENSE-2.0
 
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->

<project name="NIO Build" default="build" basedir=".">
    <description>Build for NIO component</description>

    <!-- import common properties -->
    <property name="hy.hdk" location="${basedir}/../../deploy" />
    <property name="hy.jdk" location="${hy.hdk}/jdk" />
    <property name="hy.jre" location="${hy.jdk}/jre" />
    <import file="${hy.hdk}/build/ant/properties.xml" />

    <property name="tests.output" location="../../build/test_report" />

    <!-- set global properties for this build. -->

    <property name="hy.nio.src.main.java.platform"
              value="src/main/java/common/../${hy.os.family}" />

    <property name="hy.nio.src.test.java.platform"
              value="src/test/java/common/../${hy.os.family}" />

    <property name="tests.hdk.dir" value="${hy.hdk}/build/test/nio" />
    <property name="nio.exclude.file"
              location="${tests.hdk.dir}/test.exclude" />

    <fileset id="classes" dir="../../build/classes">
        <or>
            <present targetdir="src/main/java/common" />
            <present targetdir="src/main/java/common">
                <mapper type="regexp"
                        from="^(.*?)(\$$[^/\\\.]*)?\.class$$"
                        to="\1.java" />
            </present>
            <present targetdir="${hy.nio.src.main.java.platform}" />
            <present targetdir="${hy.nio.src.main.java.platform}">
                <mapper type="regexp"
                        from="^(.*?)(\$$[^/\\\.]*)?\.class$$"
                        to="\1.java" />
            </present>
        </or>
    </fileset>

    <target name="build" depends="compile-java, copy-resources, build-jar" />

    <target name="test" depends="-test-module">
        <fail message="Some tests failed">
            <condition>
                <or>
                    <isset property="test.failures" />
                    <isset property="test.errors" />
                </or>
            </condition>
        </fail>
    </target>

    <!-- internal target for local and global test run sequence -->
    <target name="-test-module"
            depends="build, compile-tests, prepare-exclude, run-tests" />

    <!-- Build natives.-->
    <target name="build-native" depends="build-native-all" />
    <target name="build-native-all" >
        <make dir="src/main/native/nio/${hy.os.family}" />

        <!-- Copy the built shared libs over to the jre/bin dir -->
        <copy todir="${hy.jdk}/jre/bin" overwrite="yes">
            <fileset dir="src/main/native/nio">
                <include name="*${shlib.suffix}*" />
                <include name="*${progdb.suffix}*" if="is.windows" />
                <exclude name="*${manifest.suffix}" />
            </fileset>
        </copy>
        <!-- Copy link exports file on z/OS -->
        <copy todir="${hy.hdk}/lib" overwrite="yes">
            <fileset dir="src/main/native/nio/${hy.os.family}">
                <include name="*${linklib.suffix}" if="is.zos" />
            </fileset>
        </copy>
    </target>

    <target name="clean">
        <delete file="${hy.jdk}/jre/lib/boot/nio.jar" />
        <delete file="${hy.jdk}/jre/lib/boot/nio-src.jar" />
        <delete includeemptydirs="true" failonerror="false">
            <fileset refid="classes" />
        </delete>
        <delete failonerror="false" dir="bin" />
    </target>

    <!-- Clean natives. -->
    <target name="clean-native">
        <make dir="src/main/native/nio/${hy.os.family}"
              target="clean" />
    </target>

    <target name="compile-java">
        <echo message="Compiling NIO classes" />

        <mkdir dir="../../build/classes" />

        <javac sourcepath=""
               destdir="../../build/classes"
               compiler="${hy.javac.compiler}"
               memoryMaximumSize="${hy.javac.maxmem}"
               source="${hy.javac.source}"
               target="${hy.javac.target}"
               debug="${hy.javac.debug}">

            <compilerarg line="${build.compilerarg}" />

            <src>
                <pathelement location="src/main/java/common" />
                <pathelement location="${hy.nio.src.main.java.platform}" />
            </src>

            <bootclasspath>
                <fileset dir="${hy.jdk}/jre/lib/boot">
                    <include name="**/*.jar" />
                </fileset>
            </bootclasspath>
        </javac>
    </target>

    <target name="copy-resources">
        <mkdir dir="../../build/classes" />
        <copy todir="../../build/classes" includeemptydirs="false">
            <fileset dir="src/main/java/common">
                <exclude name="**/*.java" />
            </fileset>
        </copy>
    </target>

    <target name="build-jar" depends="svn-info">
        <jar destfile="${hy.jdk}/jre/lib/boot/nio.jar"
             manifest="./META-INF/MANIFEST.MF"
             compress="${hy.jar.compress}">
            <fileset refid="classes" />
            <manifest>
                <attribute name="Implementation-Version" value="${svn.info}" />
            </manifest>

            <metainf refid="hy.required.metainf-files" />
        </jar>

        <jar destfile="${hy.jdk}/jre/lib/boot/nio-src.jar">
            <fileset dir="src/main/java/common" />
            <manifest>
                <attribute name="Implementation-Version" value="${svn.info}" />
            </manifest>

            <metainf refid="hy.required.metainf-files" />
        </jar>
    </target>

    <target name="compile-tests" depends="copy-test-resources">
        <echo message="Compiling NIO tests" />

        <mkdir dir="bin/test" />

        <javac destdir="bin/test"
               sourcepath=""
               compiler="${hy.javac.compiler}"
               memoryMaximumSize="${hy.javac.maxmem}"
               source="${hy.javac.source}"
               target="${hy.javac.target}"
               debug="${hy.javac.debug}">

            <compilerarg line="${build.compilerarg}" />

            <src>
                <pathelement location="src/test/java/common" />
                <pathelement location="${hy.nio.src.test.java.platform}" />
            </src>
            <bootclasspath>
                <fileset dir="${hy.jdk}/jre/lib/boot">
                    <include name="**/*.jar" />
                </fileset>
            </bootclasspath>
            <classpath location="${hy.hdk}/build/test/support.jar" />
        </javac>
    </target>

    <target name="prepare-exclude">
        <prepare-exclude-list moduleName="nio"<commit_msg>Convert nio module to use compile-tests macro.<commit_after><?xml version="1.0" encoding="UTF-8"?>
<!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at
 
      http://www.apache.org/licenses/LICENSE-2.0
 
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->

<project name="NIO Build" default="build" basedir=".">
    <description>Build for NIO component</description>

    <!-- import common properties -->
    <property name="hy.hdk" location="${basedir}/../../deploy" />
    <property name="hy.jdk" location="${hy.hdk}/jdk" />
    <property name="hy.jre" location="${hy.jdk}/jre" />
    <import file="${hy.hdk}/build/ant/properties.xml" />

    <property name="tests.output" location="../../build/test_report" />

    <!-- set global properties for this build. -->

    <property name="hy.nio.src.main.java.platform"
              value="src/main/java/common/../${hy.os.family}" />

    <property name="hy.nio.src.test.java.platform"
              value="src/test/java/common/../${hy.os.family}" />

    <property name="tests.hdk.dir" value="${hy.hdk}/build/test/nio" />
    <property name="nio.exclude.file"
              location="${tests.hdk.dir}/test.exclude" />

    <fileset id="classes" dir="../../build/classes">
        <or>
            <present targetdir="src/main/java/common" />
            <present targetdir="src/main/java/common">
                <mapper type="regexp"
                        from="^(.*?)(\$$[^/\\\.]*)?\.class$$"
                        to="\1.java" />
            </present>
            <present targetdir="${hy.nio.src.main.java.platform}" />
            <present targetdir="${hy.nio.src.main.java.platform}">
                <mapper type="regexp"
                        from="^(.*?)(\$$[^/\\\.]*)?\.class$$"
                        to="\1.java" />
            </present>
        </or>
    </fileset>

    <target name="build" depends="compile-java, copy-resources, build-jar" />

    <target name="test" depends="-test-module">
        <fail message="Some tests failed">
            <condition>
                <or>
                    <isset property="test.failures" />
                    <isset property="test.errors" />
                </or>
            </condition>
        </fail>
    </target>

    <!-- internal target for local and global test run sequence -->
    <target name="-test-module"
            depends="build, compile-tests, prepare-exclude, run-tests" />

    <!-- Build natives.-->
    <target name="build-native" depends="build-native-all" />
    <target name="build-native-all" >
        <make dir="src/main/native/nio/${hy.os.family}" />

        <!-- Copy the built shared libs over to the jre/bin dir -->
        <copy todir="${hy.jdk}/jre/bin" overwrite="yes">
            <fileset dir="src/main/native/nio">
                <include name="*${shlib.suffix}*" />
                <include name="*${progdb.suffix}*" if="is.windows" />
                <exclude name="*${manifest.suffix}" />
            </fileset>
        </copy>
        <!-- Copy link exports file on z/OS -->
        <copy todir="${hy.hdk}/lib" overwrite="yes">
            <fileset dir="src/main/native/nio/${hy.os.family}">
                <include name="*${linklib.suffix}" if="is.zos" />
            </fileset>
        </copy>
    </target>

    <target name="clean">
        <delete file="${hy.jdk}/jre/lib/boot/nio.jar" />
        <delete file="${hy.jdk}/jre/lib/boot/nio-src.jar" />
        <delete includeemptydirs="true" failonerror="false">
            <fileset refid="classes" />
        </delete>
        <delete failonerror="false" dir="bin" />
    </target>

    <!-- Clean natives. -->
    <target name="clean-native">
        <make dir="src/main/native/nio/${hy.os.family}"
              target="clean" />
    </target>

    <target name="compile-java">
        <echo message="Compiling NIO classes" />

        <mkdir dir="../../build/classes" />

        <javac sourcepath=""
               destdir="../../build/classes"
               compiler="${hy.javac.compiler}"
               memoryMaximumSize="${hy.javac.maxmem}"
               source="${hy.javac.source}"
               target="${hy.javac.target}"
               debug="${hy.javac.debug}">

            <compilerarg line="${build.compilerarg}" />

            <src>
                <pathelement location="src/main/java/common" />
                <pathelement location="${hy.nio.src.main.java.platform}" />
            </src>

            <bootclasspath>
                <fileset dir="${hy.jdk}/jre/lib/boot">
                    <include name="**/*.jar" />
                </fileset>
            </bootclasspath>
        </javac>
    </target>

    <target name="copy-resources">
        <mkdir dir="../../build/classes" />
        <copy todir="../../build/classes" includeemptydirs="false">
            <fileset dir="src/main/java/common">
                <exclude name="**/*.java" />
            </fileset>
        </copy>
    </target>

    <target name="build-jar" depends="svn-info">
        <jar destfile="${hy.jdk}/jre/lib/boot/nio.jar"
             manifest="./META-INF/MANIFEST.MF"
             compress="${hy.jar.compress}">
            <fileset refid="classes" />
            <manifest>
                <attribute name="Implementation-Version" value="${svn.info}" />
            </manifest>

            <metainf refid="hy.required.metainf-files" />
        </jar>

        <jar destfile="${hy.jdk}/jre/lib/boot/nio-src.jar">
            <fileset dir="src/main/java/common" />
            <manifest>
                <attribute name="Implementation-Version" value="${svn.info}" />
            </manifest>

            <metainf refid="hy.required.metainf-files" />
        </jar>
    </target>

    <target name="compile-tests" depends="copy-test-resources">
        <compile-tests description="nio tests"
                       destdir="bin/test">
            <javac-elements>
                <src>
                    <pathelement location="src/test/java/common" />
                    <pathelement location="${hy.nio.src.test.java.platform}" />
                </src>
            </javac-elements>
        </compile-tests>
    </target>

    <target name="prepare-exclude">
        <prepare-exclude-list moduleName="nio"
{'fraction_non_alphanumeric': 0.17378797446151686, 'fraction_numerical': 0.0012628920227320563, 'mean_word_length': 1.8755295541658261, 'pattern_counts': {'":': 0, '<': 258, '<?xml version=': 2, '>': 256, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5991759', 'n_tokens_mistral': 4192, 'n_tokens_neox': 4009, 'n_words': 808}