<commit_before><?xml version="1.0" encoding="UTF-8"?>

<!-- ======================================================================= -->
<!-- eXist build file                                                        -->
<!-- ======================================================================= -->

<!-- $Id$ -->

<project basedir="../.." default="all" name="exist">

    <!-- import default properties from file -->
    <property file="build.properties"/>

    <!-- setup properties -->
    <property name="jetty.dir" value="tools/jetty"/>
    <property name="src" value="./src"/>
    <property name="src.webapp" value="./webapp"/>
    <property name="samples" value="./samples"/>
    <property name="bin" value="./bin"/>
    <property name="lib.core" value="./lib/core"/>
    <property name="lib.optional" value="./lib/optional"/>
    <property name="lib.endorsed" value="./lib/endorsed"/>
    <property name="lib.user" value="./lib/user"/>
    <property name="lib.tools" value="./tools/lib"/>
    <property name="build" value="./build"/>
    <property name="build.src" value="${build}/src"/>
    <property name="build.soap" value="${build}/soap"/>
    <property name="build.classes" value="${build}/classes"/>
    <property name="build.docs" value="${build}/docs"/>
    <property name="build.docs.src" value="${build.docs}/source"/>
    <property name="build.docs.html" value="${build.docs}/html"/>
    <property name="ant.home" value="."/>
    <property name="dist" value="./dist"/>
    <property name="webapp.dir" value="${dist}/webapp"/>
    <property name="build.compiler" value="modern"/>
    <property name="build.compiler.source" value="1.4"/>
    <property name="build.compiler.target" value="1.4"/>
    <property name="build.debug" value="on"/>
    <property name="build.optimize" value="on"/>
    <property name="build.deprecation" value="on"/>
    <property name="jvmarg" value="-Xmx128000k -Xms32000k -Djetty.home=${jetty.dir} -Dexist.home=${basedir}"/>
    <property name="xmldb.src" value="undefined"/>
    <property name="dist.dir" value="${dist}/${project.name}-${project.version}"/>

    <!-- setup conditional properties -->
    <available file="${xmldb.src}" type="dir" property="has.xmldb.src"/>
    <available file="${catalina.home}/bin" property="catalina.present"/>
    <available file="key.store" property="key.store.present"/>

    <!-- setup class path -->
    <path id="classpath.core">
        <fileset dir="${lib.core}">
            <include name="*.jar"/>
        </fileset>
        <fileset dir="${lib.optional}">
            <include name="*.jar"/>
        </fileset>
        <fileset dir="${lib.endorsed}">
            <include name="*.jar"/>
        </fileset>
        <fileset dir="${lib.tools}">
            <include name="*.jar"/>
        </fileset>
        <fileset dir="${lib.user}">
            <include name="*.jar"/>
        </fileset>
        <pathelement path="exist.jar"/>
        <pathelement path="exist-optional.jar"/>
        <pathelement path="exist-modules.jar"/>
        <pathelement path="start.jar"/>
        <pathelement path="${java.class.path}"/>
    </path>
    
    <path id="classpath.jetty">
        <fileset dir="${jetty.dir}/lib">
            <include name="*.jar"/>
        </fileset>
    </path>

    <taskdef name="java2wsdl" classname="org.apache.axis.tools.ant.wsdl.Java2WsdlAntTask">
        <classpath refid="classpath.core"/>
    </taskdef>

    <taskdef name="wsdl2java" classname="org.apache.axis.tools.ant.wsdl.Wsdl2javaAntTask">
        <classpath refid="classpath.core"/>
    </taskdef>

    <taskdef name="axis-admin" classname="org.apache.axis.tools.ant.axis.AdminClientTask">
        <classpath refid="classpath.core"/>
    </taskdef>

    <taskdef name="cocoon" classname="org.apache.cocoon.CocoonTask">
        <classpath refid="classpath.core"/>
    </taskdef>
    
    <!-- =================================================================== -->
    <!-- Prepare the build                                                   -->
    <!-- =================================================================== -->
    <target name="prepare">
        <echo message="-------------------------"/>
        <echo message="eXist ${project.version} build"/>
        <echo message="-------------------------"/>
        <echo message="basedir=${basedir}"/>
        
        <mkdir dir="${build.classes}"/>
        <mkdir dir="${jetty.dir}/logs"/>
        <mkdir dir="${jetty.dir}/work"/>
        <tstamp/>
        <filter token="version" value="${project.version}-${DSTAMP}"/>
        <filter token="database" value="native"/>
        <copy
        file="${src.webapp}/header.xml.tmpl"
        tofile="${src.webapp}/header.xml" filtering="true"
        overwrite="true" />
        <copy file="${src.webapp}/header.xml.tmpl"
        tofile="${src.webapp}/xquery/header.xml" filtering="true"
        overwrite="true"/>
        <copy file="${basedir}/conf.xml.tmpl" tofile="${basedir}/conf.xml" filtering="true"/>
    </target>

    <!-- =================================================================== -->
    <!-- Compiles the source code                                            -->
    <!-- =================================================================== -->
    <target depends="prepare" name="compile" description="Compiles the source code">
        
        <echo message="Compiling with Java ${ant.java.version} from ${build.compiler.source} source to ${build.compiler.target} target, debug ${build.debug}, optimize ${build.optimize}, deprecation ${build.deprecation}"/>
        <javac debug="${build.debug}" deprecation="${build.deprecation}"
            destdir="${build.classes}" encoding="UTF-8"
            optimize="${build.optimize}" srcdir="${src}"
            source="${build.compiler.source}" target="${build.compiler.target}">

            <include name="org/**"/>
            <include name="org/exist/schema/**"/>
            <exclude name="org/exist/http/realm/**"/>
            <exclude name="doxygen" />
            <classpath>
                <path refid="classpath.core"/>
                <path refid="classpath.jetty"/>
            </classpath>
        </javac>
    </target>

    <!-- =================================================================== -->
    <!-- Compile the Tomcat realm                                            -->
    <!-- =================================================================== -->
    <target name="compile-tomcat-realm" if="catalina.present" description="Compile the Tomcat realm">
        <echo message="Compiling Tomcat Realm  with Java ${ant.java.version} from ${build.compiler.source} source to ${build.compiler.target} target, debug ${build.debug}, optimize ${build.optimize}, deprecation ${build.deprecation}"/>    	
        <javac debug="${build.debug}" deprecation="${build.deprecation}"
            destdir="${build.classes}" encoding="UTF-8"
            optimize="${build.optimize}" srcdir="${src}"
            source="${build.compiler.source}" target="${build.compiler.target}">
            <include name="org/exist/http/realm/**"/>
            <classpath>
                <path refid="classpath.core"/>
                <fileset dir="${catalina.home}/bin">
                    <include name="*.jar"/>
                </fileset>
                <fileset dir="${catalina.home}/server/lib">
                    <include name="*.jar"/>
                </fileset>
                <!--fileset dir="${catalina.home}/common/lib">
                <include name="*.jar"/>
                </fileset-->
            </classpath>
        </javac>
    </target>

    <!-- =================================================================== -->
    <!-- Run antlr parser generator										   -->
    <!-- needs antlr distribution-directory in the classpath				   -->
    <!-- =================================================================== -->
    <target depends="prepare" name="antlr">
        <echo message="Running ANTLR to generate XQuery parser"/>
        <delete failonerror="false">
            <fileset dir="${src}/org/exist/xquery/parser">
                <include name="*.java"/>
                <include name="*.txt"/>
                <exclude name="XQueryAST.java"/>
            </fileset>
        </delete>
        <antlr target="${src}/org/exist/xquery/parser/XQuery.g"
            outputdirectory="${src}/org/exist/xquery/parser"
            traceparser="${antlr.traceParser}"
            tracelexer="${antlr.traceLexer}">
            <classpath>
                <path refid="classpath.core"/>
            </classpath>
        </antlr>
        <antlr target="${src}/org/exist/xquery/parser/XQueryTree.g"
            outputdirectory="${src}/org/exist/xquery/parser">
            <classpath>
                <path refid="classpath.core"/>
            </classpath>
        </antlr>
        <antlr target="${src}/org/exist/xquery/parser/DeclScanner.g"
            outputdirectory="${src}/org/exist/xquery/parser">
            <classpath>
                <path refid="classpath.core"/>
            </classpath>
        </antlr>
    </target>

    <target depends="antlr,jar" name="xquery"/>
    
    <!-- ================================================================== -->
    <!-- Create samples                                                     -->
    <!-- ================================================================== -->
    <target depends="prepare" name="samples" description="Create samples">
        <delete failonerror="false" dir="${build}/examples"/>
        <mkdir dir="${build}/examples"/>
        <echo message="Compiling samples with Java ${ant.java.version} from ${build.compiler.source} source to ${build.compiler.target} target, debug ${build.debug}, optimize ${build.optimize}, deprecation ${build.deprecation}"/>
        <javac debug="${build.debug}"
            deprecation="${build.deprecation}"
            destdir="${build}/examples" srcdir="${samples}"
            source="${build.compiler.source}" target="${build.compiler.target}"
            optimize="${build.optimize}" encoding="UTF-8">
            <classpath>
                <path refid="classpath.core"/>
            </classpath>
        </javac>
        <jar basedir="${build}/examples" compress="true" jarfile="examples.jar">
            <include name="org/exist/examples/**"/>
        </jar>
    </target>
    
    <!-- ================================================================== -->
    <!-- Create jar files                    							   	-->
    <!-- ================================================================== -->
    <target name="jar" depends="compile, compile-tomcat-realm" description="Create eXist unsigned jar files">
        <filter token="version" value="${project.version}"/>
        <filter token="build" value="${DSTAMP}"/>
        <copy file="${src}/CatalogManager.properties" todir="${build.classes}"/>
        <copy todir="${build.classes}/org/exist/client">
            <fileset dir="${src}/org/exist/client">
                <include name="icons/**.png"/>
                <include name="icons/**.gif"/>
                <include name="*.xsl"/>
                <include name="**/*.xconf"/>
            </fileset>
        </copy>
        <copy todir="${build.classes}/org/exist/xquery/lib">
            <fileset dir="${src}/org/exist/xquery/lib">
                <include name="**.xq"/>
            </fileset>
        </copy>
        <copy todir="${build.classes}/org/exist/security/xacml/policies">
            <fileset dir="${src}/org/exist/security/xacml/policies">
                <include name="*.xml"/>
            </fileset>
        </copy>
        <copy file="${src}/org/exist/xquery/util/messages.properties"
             todir="${build.classes}/org/exist/xquery/util"/>
        <copy file="${src}/org/exist/ant/antlib.xml"
             todir="${build.classes}/org/exist/ant"/>
        <copy file="${src}/org/exist/exist.xsl"
             todir="${build.classes}/org/exist"/>
        <copy file="${src}/org/exist/xmldb.xsl"
             todir="${build.classes}/org/exist"/>
        <copy file="${src}/org/exist/xmldb2.xsl"
             todir="${build.classes}/org/exist"/>
        <copy file="${src}/org/exist/start/start.config"
             todir="${build.classes}/org/exist/start"/>
        <copy file="${src}/org/exist/security/security.properties"
             todir="${build.classes}/org/exist/security"/>
        <copy file="${src}/org/exist/system.properties"
             todir="${build.classes}/org/exist" filtering="true"/>
        <copy file="${src}/org/exist/util/mime-types.xml"
             todir="${build.classes}/org/exist/util"/>
        <copy todir="${build.classes}/org/exist/http/webdav/methods">
            <fileset dir="${src}/org/exist/http/webdav/methods">
                <include name="**.xq"/>
            </fileset>
        </copy>
        <echo message="Creating exist.jar ..."/>
        <jar basedir="${build.classes}" compress="true" jarfile="exist.jar">
            <exclude name="org/exist/start/**"/>
            <exclude name="org/exist/soap/**"/>
            <exclude name="org/exist/ant/**"/>
            <exclude name="org/exist/http/servlets/**"/>
            <exclude name="org/exist/xquery/functions/request/**"/><commit_msg>Fix: jUnit failed because some .xq files were not copied into exist.jar. This was a recent addition to build.xml, we might have lost this during recent build changes. Don't know why.....<commit_after><?xml version="1.0" encoding="UTF-8"?>

<!-- ======================================================================= -->
<!-- eXist build file                                                        -->
<!-- ======================================================================= -->

<!-- $Id$ -->

<project basedir="../.." default="all" name="exist">

    <!-- import default properties from file -->
    <property file="build.properties"/>

    <!-- setup properties -->
    <property name="jetty.dir" value="tools/jetty"/>
    <property name="src" value="./src"/>
    <property name="src.webapp" value="./webapp"/>
    <property name="samples" value="./samples"/>
    <property name="bin" value="./bin"/>
    <property name="lib.core" value="./lib/core"/>
    <property name="lib.optional" value="./lib/optional"/>
    <property name="lib.endorsed" value="./lib/endorsed"/>
    <property name="lib.user" value="./lib/user"/>
    <property name="lib.tools" value="./tools/lib"/>
    <property name="build" value="./build"/>
    <property name="build.src" value="${build}/src"/>
    <property name="build.soap" value="${build}/soap"/>
    <property name="build.classes" value="${build}/classes"/>
    <property name="build.docs" value="${build}/docs"/>
    <property name="build.docs.src" value="${build.docs}/source"/>
    <property name="build.docs.html" value="${build.docs}/html"/>
    <property name="ant.home" value="."/>
    <property name="dist" value="./dist"/>
    <property name="webapp.dir" value="${dist}/webapp"/>
    <property name="build.compiler" value="modern"/>
    <property name="build.compiler.source" value="1.4"/>
    <property name="build.compiler.target" value="1.4"/>
    <property name="build.debug" value="on"/>
    <property name="build.optimize" value="on"/>
    <property name="build.deprecation" value="on"/>
    <property name="jvmarg" value="-Xmx128000k -Xms32000k -Djetty.home=${jetty.dir} -Dexist.home=${basedir}"/>
    <property name="xmldb.src" value="undefined"/>
    <property name="dist.dir" value="${dist}/${project.name}-${project.version}"/>

    <!-- setup conditional properties -->
    <available file="${xmldb.src}" type="dir" property="has.xmldb.src"/>
    <available file="${catalina.home}/bin" property="catalina.present"/>
    <available file="key.store" property="key.store.present"/>

    <!-- setup class path -->
    <path id="classpath.core">
        <fileset dir="${lib.core}">
            <include name="*.jar"/>
        </fileset>
        <fileset dir="${lib.optional}">
            <include name="*.jar"/>
        </fileset>
        <fileset dir="${lib.endorsed}">
            <include name="*.jar"/>
        </fileset>
        <fileset dir="${lib.tools}">
            <include name="*.jar"/>
        </fileset>
        <fileset dir="${lib.user}">
            <include name="*.jar"/>
        </fileset>
        <pathelement path="exist.jar"/>
        <pathelement path="exist-optional.jar"/>
        <pathelement path="exist-modules.jar"/>
        <pathelement path="start.jar"/>
        <pathelement path="${java.class.path}"/>
    </path>
    
    <path id="classpath.jetty">
        <fileset dir="${jetty.dir}/lib">
            <include name="*.jar"/>
        </fileset>
    </path>

    <taskdef name="java2wsdl" classname="org.apache.axis.tools.ant.wsdl.Java2WsdlAntTask">
        <classpath refid="classpath.core"/>
    </taskdef>

    <taskdef name="wsdl2java" classname="org.apache.axis.tools.ant.wsdl.Wsdl2javaAntTask">
        <classpath refid="classpath.core"/>
    </taskdef>

    <taskdef name="axis-admin" classname="org.apache.axis.tools.ant.axis.AdminClientTask">
        <classpath refid="classpath.core"/>
    </taskdef>

    <taskdef name="cocoon" classname="org.apache.cocoon.CocoonTask">
        <classpath refid="classpath.core"/>
    </taskdef>
    
    <!-- =================================================================== -->
    <!-- Prepare the build                                                   -->
    <!-- =================================================================== -->
    <target name="prepare">
        <echo message="-------------------------"/>
        <echo message="eXist ${project.version} build"/>
        <echo message="-------------------------"/>
        <echo message="basedir=${basedir}"/>
        
        <mkdir dir="${build.classes}"/>
        <mkdir dir="${jetty.dir}/logs"/>
        <mkdir dir="${jetty.dir}/work"/>
        <tstamp/>
        <filter token="version" value="${project.version}-${DSTAMP}"/>
        <filter token="database" value="native"/>
        <copy
        file="${src.webapp}/header.xml.tmpl"
        tofile="${src.webapp}/header.xml" filtering="true"
        overwrite="true" />
        <copy file="${src.webapp}/header.xml.tmpl"
        tofile="${src.webapp}/xquery/header.xml" filtering="true"
        overwrite="true"/>
        <copy file="${basedir}/conf.xml.tmpl" tofile="${basedir}/conf.xml" filtering="true"/>
    </target>

    <!-- =================================================================== -->
    <!-- Compiles the source code                                            -->
    <!-- =================================================================== -->
    <target depends="prepare" name="compile" description="Compiles the source code">
        
        <echo message="Compiling with Java ${ant.java.version} from ${build.compiler.source} source to ${build.compiler.target} target, debug ${build.debug}, optimize ${build.optimize}, deprecation ${build.deprecation}"/>
        <javac debug="${build.debug}" deprecation="${build.deprecation}"
            destdir="${build.classes}" encoding="UTF-8"
            optimize="${build.optimize}" srcdir="${src}"
            source="${build.compiler.source}" target="${build.compiler.target}">

            <include name="org/**"/>
            <include name="org/exist/schema/**"/>
            <exclude name="org/exist/http/realm/**"/>
            <exclude name="doxygen" />
            <classpath>
                <path refid="classpath.core"/>
                <path refid="classpath.jetty"/>
            </classpath>
        </javac>
    </target>

    <!-- =================================================================== -->
    <!-- Compile the Tomcat realm                                            -->
    <!-- =================================================================== -->
    <target name="compile-tomcat-realm" if="catalina.present" description="Compile the Tomcat realm">
        <echo message="Compiling Tomcat Realm  with Java ${ant.java.version} from ${build.compiler.source} source to ${build.compiler.target} target, debug ${build.debug}, optimize ${build.optimize}, deprecation ${build.deprecation}"/>    	
        <javac debug="${build.debug}" deprecation="${build.deprecation}"
            destdir="${build.classes}" encoding="UTF-8"
            optimize="${build.optimize}" srcdir="${src}"
            source="${build.compiler.source}" target="${build.compiler.target}">
            <include name="org/exist/http/realm/**"/>
            <classpath>
                <path refid="classpath.core"/>
                <fileset dir="${catalina.home}/bin">
                    <include name="*.jar"/>
                </fileset>
                <fileset dir="${catalina.home}/server/lib">
                    <include name="*.jar"/>
                </fileset>
                <!--fileset dir="${catalina.home}/common/lib">
                <include name="*.jar"/>
                </fileset-->
            </classpath>
        </javac>
    </target>

    <!-- =================================================================== -->
    <!-- Run antlr parser generator										   -->
    <!-- needs antlr distribution-directory in the classpath				   -->
    <!-- =================================================================== -->
    <target depends="prepare" name="antlr">
        <echo message="Running ANTLR to generate XQuery parser"/>
        <delete failonerror="false">
            <fileset dir="${src}/org/exist/xquery/parser">
                <include name="*.java"/>
                <include name="*.txt"/>
                <exclude name="XQueryAST.java"/>
            </fileset>
        </delete>
        <antlr target="${src}/org/exist/xquery/parser/XQuery.g"
            outputdirectory="${src}/org/exist/xquery/parser"
            traceparser="${antlr.traceParser}"
            tracelexer="${antlr.traceLexer}">
            <classpath>
                <path refid="classpath.core"/>
            </classpath>
        </antlr>
        <antlr target="${src}/org/exist/xquery/parser/XQueryTree.g"
            outputdirectory="${src}/org/exist/xquery/parser">
            <classpath>
                <path refid="classpath.core"/>
            </classpath>
        </antlr>
        <antlr target="${src}/org/exist/xquery/parser/DeclScanner.g"
            outputdirectory="${src}/org/exist/xquery/parser">
            <classpath>
                <path refid="classpath.core"/>
            </classpath>
        </antlr>
    </target>

    <target depends="antlr,jar" name="xquery"/>
    
    <!-- ================================================================== -->
    <!-- Create samples                                                     -->
    <!-- ================================================================== -->
    <target depends="prepare" name="samples" description="Create samples">
        <delete failonerror="false" dir="${build}/examples"/>
        <mkdir dir="${build}/examples"/>
        <echo message="Compiling samples with Java ${ant.java.version} from ${build.compiler.source} source to ${build.compiler.target} target, debug ${build.debug}, optimize ${build.optimize}, deprecation ${build.deprecation}"/>
        <javac debug="${build.debug}"
            deprecation="${build.deprecation}"
            destdir="${build}/examples" srcdir="${samples}"
            source="${build.compiler.source}" target="${build.compiler.target}"
            optimize="${build.optimize}" encoding="UTF-8">
            <classpath>
                <path refid="classpath.core"/>
            </classpath>
        </javac>
        <jar basedir="${build}/examples" compress="true" jarfile="examples.jar">
            <include name="org/exist/examples/**"/>
        </jar>
    </target>
    
    <!-- ================================================================== -->
    <!-- Create jar files                    							   	-->
    <!-- ================================================================== -->
    <target name="jar" depends="compile, compile-tomcat-realm" description="Create eXist unsigned jar files">
        <filter token="version" value="${project.version}"/>
        <filter token="build" value="${DSTAMP}"/>
        <copy file="${src}/CatalogManager.properties" todir="${build.classes}"/>
        <copy todir="${build.classes}/org/exist/client">
            <fileset dir="${src}/org/exist/client">
                <include name="icons/**.png"/>
                <include name="icons/**.gif"/>
                <include name="*.xsl"/>
                <include name="**/*.xconf"/>
            </fileset>
        </copy>
        <copy todir="${build.classes}/org/exist/xquery/lib">
            <fileset dir="${src}/org/exist/xquery/lib">
                <include name="**.xq"/>
            </fileset>
        </copy>
        <copy todir="${build.classes}/org/exist/security/xacml/policies">
            <fileset dir="${src}/org/exist/security/xacml/policies">
                <include name="*.xml"/>
            </fileset>
        </copy>
        <copy file="${src}/org/exist/xquery/util/messages.properties"
             todir="${build.classes}/org/exist/xquery/util"/>
        <copy file="${src}/org/exist/ant/antlib.xml"
             todir="${build.classes}/org/exist/ant"/>
        <copy file="${src}/org/exist/exist.xsl"
             todir="${build.classes}/org/exist"/>
        <copy file="${src}/org/exist/xmldb.xsl"
             todir="${build.classes}/org/exist"/>
        <copy file="${src}/org/exist/xmldb2.xsl"
             todir="${build.classes}/org/exist"/>
        <copy file="${src}/org/exist/start/start.config"
             todir="${build.classes}/org/exist/start"/>
        <copy file="${src}/org/exist/security/security.properties"
             todir="${build.classes}/org/exist/security"/>
        <copy file="${src}/org/exist/system.properties"
             todir="${build.classes}/org/exist" filtering="true"/>
        <copy file="${src}/org/exist/util/mime-types.xml"
             todir="${build.classes}/org/exist/util"/>
        <copy todir="${build.classes}/org/exist/http/webdav/methods">
            <fileset dir="${src}/org/exist/http/webdav/methods">
                <include name="**.xq"/>
            </fileset>
        </copy>
        <copy todir="${build.classes}/org/exist/validation/internal/query">
            <fileset dir="${src}/org/exist/validation/internal/query">
                <include name="**.xq"/>
            </fileset>
        </copy>
        <echo message="Creating exist.jar ..."/>
        <jar basedir="${build.classes}" compress="true" jarfile="exist.jar">
            <exclude name="org/exist/start/**"/>
            <exclude name="org/exist/soap/**"/>
            <exclude name="org/exist/ant/**"/>
            <exclude name="org/exist/http/servlets/**"/>
            <exclude name="org/exist/xquery/functions/request/**"/>
{'fraction_non_alphanumeric': 0.25431915288872375, 'fraction_numerical': 0.0019320081738807356, 'mean_word_length': 2.361978516112915, 'pattern_counts': {'":': 0, '<': 466, '<?xml version=': 2, '>': 466, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 31}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4864374', 'n_tokens_mistral': 7405, 'n_tokens_neox': 7064, 'n_words': 1181}