<commit_before><project name="KBaseSearchEngine" default="compile" basedir="."
         xmlns:jacoco="antlib:org.jacoco.ant">

  <description>
      Build JAR and WAR files for KBaseSearchEngine 
  </description>

  <!-- set global properties for this build -->
  <property environment="env"/>
  <property name="src" location="lib/src"/>
  <property name="test.src" location="test/src"/>
  <property name="dist" location="dist"/>
  <property name="classes" location="classes"/>
  <property name="bin" location="bin"/>
  <property name="test.cfg" location="/kb/module/work/test.cfg"/>
  <property name="jar.file" value="KBaseSearchEngine.jar"/>
  <condition property="jars.dir" value="${env.JARS_DIR}" else="/kb/deployment/lib/jars">
    <isset property="env.JARS_DIR" />
  </condition>
  <!-- <property name="jars.dir" value="/kb/deployment/lib/jars"/> -->
  <property name="war.file" value="KBaseSearchEngine.war"/>
  <property name="scripts" location="scripts"/>
  <property name="web.xml" location="${scripts}/web.xml"/>
  <property name="exec.cmd.file" value="run_KBaseSearchEngine_async_job.sh"/>
  <property name="exec.cmd.file2" value="run_KBaseSearchEngine_perform.sh"/>
  <property name="exec.cmd.search_tools" value="search_tools.sh"/>
  <property name="startup.cmd.file" value="start_server.sh"/>
  <property name="test.reports.dir" location="work/test-reports"/>

  <fileset dir="${jars.dir}" id="lib">
    <include name="ini4j/ini4j-0.5.2.jar"/>
    <include name="jackson/jackson-annotations-2.2.3.jar"/>
    <include name="jackson/jackson-core-2.2.3.jar"/>
    <include name="jackson/jackson-databind-2.2.3.jar"/>
    <include name="jetty/jetty-all-7.0.0.jar"/>
    <include name="jna/jna-3.4.0.jar"/>
    <include name="joda/joda-time-2.2.jar"/>
    <include name="junit/junit-4.9.jar"/>
    <include name="kbase/auth/kbase-auth-0.4.4.jar"/>
    <include name="kbase/common/kbase-common-0.0.23.jar"/>
    <include name="kbase/workspace/WorkspaceService-0.8.0.jar"/>
    <include name="logback/logback-core-1.1.2.jar"/>
    <include name="logback/logback-classic-1.1.2.jar"/>
    <include name="servlet/servlet-api-2.5.jar"/>
    <include name="slf4j/slf4j-api-1.7.7.jar"/>
    <include name="syslog4j/syslog4j-0.9.46.jar"/>
    <include name="mustache/compiler-0.9.3.jar"/>
    <include name="kbase/workspace/WorkspaceClient-0.6.0.jar"/>
    <include name="apache_commons/commons-logging-1.1.1.jar"/>
    <include name="apache_commons/commons-io-2.4.jar"/>
    <include name="apache_commons/http/httpasyncclient-4.1.2.jar"/>
    <include name="apache_commons/http/httpclient-4.5.2.jar"/>
    <include name="apache_commons/http/httpcore-4.4.5.jar"/>
    <include name="apache_commons/http/httpcore-nio-4.4.5.jar"/>
    <include name="apache_commons/commons-codec-1.10.jar"/>
    <include name="elasticsearch/rest-5.3.0.jar"/>
    <include name="mongo/mongo-java-driver-3.4.2.jar"/>
    <include name="google/guava-18.0.jar"/>
    <include name="jcommander/jcommander-1.48.jar"/>
    <include name="snakeyaml/snakeyaml-1.18.jar"/>
    <include name="equalsverifier/equalsverifier-2.2.2.jar"/>
    <include name="kbase/auth2/kbase-auth2test-0.2.3.jar"/>
    <!-- mockito and dependencies -->
    <include name="mockito/mockito-core-2.7.10.jar"/>
    <include name="bytebuddy/byte-buddy-1.6.8.jar"/>
    <include name="bytebuddy/byte-buddy-agent-1.6.8.jar"/>
    <include name="objenesis/objenesis-2.5.1.jar"/>
  </fileset>

  <path id="compile.classpath">
    <fileset refid="lib"/>
  </path>
	
  <path id="test.classpath">
    <path refid="compile.classpath"/>
    <fileset file="${dist}/${jar.file}"/>
  </path>

  <path id="src.path">
    <pathelement location="${src}" />
    <pathelement location="${test.src}" />
  </path>

  <target name="compile" description="compile the source">
    <mkdir dir="${classes}"/>
    <mkdir dir="${dist}"/>
    <exec executable="git" outputproperty="git.url"><arg line="config --get remote.origin.url"/></exec>
    <exec executable="git" outputproperty="git.branch"><arg line="rev-parse --abbrev-ref HEAD"/></exec>
    <exec executable="git" outputproperty="git.commit"><arg line="rev-parse HEAD"/></exec>
    <echo file="${src}/git.properties">giturl=${git.url}
branch=${git.branch}
commit=${git.commit}</echo>
    <!-- Compile class files-->
    <javac destdir="${classes}"
        includeantruntime="false"
        target="1.8"
        source="1.8"
        debug="true"
        classpathref="compile.classpath"
        compiler="modern">
      <src refid="src.path"/>
    </javac>
    <!-- Copy resource files-->
    <copy todir="${classes}">
      <fileset dir="${src}"/>
    </copy>
    <copy todir="${classes}">
      <fileset dir="${test.src}"/>
    </copy>
    <jar destfile="${dist}/${jar.file}" basedir="${classes}"/>
  </target>

  <target name="war" depends="compile" description="build the WAR file. Assumes compile has been run">
    <!-- make the war file for the server-->
    <mkdir dir="${dist}/lib"/>
    <copy todir="${dist}/lib/" flatten="true">
      <fileset refid="lib"/>
      <resources>
        <file file="${dist}/${jar.file}"/>
      </resources>
    </copy>
    <war destfile="${dist}/${war.file}" webxml="${web.xml}">
      <lib dir="${dist}/lib/"/>
    </war>
    <delete dir="${dist}/lib"/>
    <mkdir dir="${scripts}/webapps"/>
    <copy file="${dist}/${war.file}" tofile="${scripts}/webapps/root.war"/>
  </target>

  <target name="build-executable-script"
      depends="compile"
      description="create command-line script">
    <mkdir dir="${bin}"/>
    <property name="jar.absolute.path" location="${dist}/${jar.file}"/>
    <pathconvert targetos="unix" property="lib.classpath" refid="compile.classpath"/>
    <echo file="${bin}/${exec.cmd.file}">#!/bin/bash
java -cp ${jar.absolute.path}:${lib.classpath} kbasesearchengine.KBaseSearchEngineServer $1 $2 $3
    </echo>
    <chmod file="${bin}/${exec.cmd.file}" perm="a+x"/>
    <echo file="${bin}/${exec.cmd.file2}">#!/bin/bash
java -Xmx2g -cp ${jar.absolute.path}:${lib.classpath} kbasesearchengine.main.test.PerformanceTester
    </echo>
    <chmod file="${bin}/${exec.cmd.file2}" perm="a+x"/>
    <echo file="${bin}/${exec.cmd.search_tools}">#!/bin/sh
java -cp ${jar.absolute.path}:${lib.classpath} kbasesearchengine.tools.SearchTools $@
    </echo>
    <chmod file="${bin}/${exec.cmd.search_tools}" perm="a+x"/>
  </target>
	
  <target name="test" description="run all tests">
    <delete dir="${test.reports.dir}"/>
    <mkdir dir="${test.reports.dir}"/>
    <jacoco:coverage destfile="${test.reports.dir}/jacoco.exec"
                     excludes="org/*:junit/*">
      <junit printsummary="yes" haltonfailure="yes" fork="true">
        <classpath refid="test.classpath"/>
        <formatter type="plain" usefile="false" />
        <sysproperty key="test.cfg" value="${test.cfg}"/>
        <test name="kbasesearchengine.test.authorization.AccessGroupCacheTest"/>
        <test name="kbasesearchengine.test.common.FileUtilTest"/>
        <test name="kbasesearchengine.test.events.AccessGroupEventQueueTest"/>
        <test name="kbasesearchengine.test.events.ChildStatusEventTest"/>
        <test name="kbasesearchengine.test.events.EventQueueTest"/>
        <test name="kbasesearchengine.test.events.ObjectEventQueueTest"/>
        <test name="kbasesearchengine.test.events.StatusEventIDTest"/>
        <test name="kbasesearchengine.test.events.StatusEventTest"/>
        <test name="kbasesearchengine.test.events.StoredChildStatusEventTest"/><commit_msg>added guid tests to build.xml<commit_after><project name="KBaseSearchEngine" default="compile" basedir="."
         xmlns:jacoco="antlib:org.jacoco.ant">

  <description>
      Build JAR and WAR files for KBaseSearchEngine 
  </description>

  <!-- set global properties for this build -->
  <property environment="env"/>
  <property name="src" location="lib/src"/>
  <property name="test.src" location="test/src"/>
  <property name="dist" location="dist"/>
  <property name="classes" location="classes"/>
  <property name="bin" location="bin"/>
  <property name="test.cfg" location="/kb/module/work/test.cfg"/>
  <property name="jar.file" value="KBaseSearchEngine.jar"/>
  <condition property="jars.dir" value="${env.JARS_DIR}" else="/kb/deployment/lib/jars">
    <isset property="env.JARS_DIR" />
  </condition>
  <!-- <property name="jars.dir" value="/kb/deployment/lib/jars"/> -->
  <property name="war.file" value="KBaseSearchEngine.war"/>
  <property name="scripts" location="scripts"/>
  <property name="web.xml" location="${scripts}/web.xml"/>
  <property name="exec.cmd.file" value="run_KBaseSearchEngine_async_job.sh"/>
  <property name="exec.cmd.file2" value="run_KBaseSearchEngine_perform.sh"/>
  <property name="exec.cmd.search_tools" value="search_tools.sh"/>
  <property name="startup.cmd.file" value="start_server.sh"/>
  <property name="test.reports.dir" location="work/test-reports"/>

  <fileset dir="${jars.dir}" id="lib">
    <include name="ini4j/ini4j-0.5.2.jar"/>
    <include name="jackson/jackson-annotations-2.2.3.jar"/>
    <include name="jackson/jackson-core-2.2.3.jar"/>
    <include name="jackson/jackson-databind-2.2.3.jar"/>
    <include name="jetty/jetty-all-7.0.0.jar"/>
    <include name="jna/jna-3.4.0.jar"/>
    <include name="joda/joda-time-2.2.jar"/>
    <include name="junit/junit-4.9.jar"/>
    <include name="kbase/auth/kbase-auth-0.4.4.jar"/>
    <include name="kbase/common/kbase-common-0.0.23.jar"/>
    <include name="kbase/workspace/WorkspaceService-0.8.0.jar"/>
    <include name="logback/logback-core-1.1.2.jar"/>
    <include name="logback/logback-classic-1.1.2.jar"/>
    <include name="servlet/servlet-api-2.5.jar"/>
    <include name="slf4j/slf4j-api-1.7.7.jar"/>
    <include name="syslog4j/syslog4j-0.9.46.jar"/>
    <include name="mustache/compiler-0.9.3.jar"/>
    <include name="kbase/workspace/WorkspaceClient-0.6.0.jar"/>
    <include name="apache_commons/commons-logging-1.1.1.jar"/>
    <include name="apache_commons/commons-io-2.4.jar"/>
    <include name="apache_commons/http/httpasyncclient-4.1.2.jar"/>
    <include name="apache_commons/http/httpclient-4.5.2.jar"/>
    <include name="apache_commons/http/httpcore-4.4.5.jar"/>
    <include name="apache_commons/http/httpcore-nio-4.4.5.jar"/>
    <include name="apache_commons/commons-codec-1.10.jar"/>
    <include name="elasticsearch/rest-5.3.0.jar"/>
    <include name="mongo/mongo-java-driver-3.4.2.jar"/>
    <include name="google/guava-18.0.jar"/>
    <include name="jcommander/jcommander-1.48.jar"/>
    <include name="snakeyaml/snakeyaml-1.18.jar"/>
    <include name="equalsverifier/equalsverifier-2.2.2.jar"/>
    <include name="kbase/auth2/kbase-auth2test-0.2.3.jar"/>
    <!-- mockito and dependencies -->
    <include name="mockito/mockito-core-2.7.10.jar"/>
    <include name="bytebuddy/byte-buddy-1.6.8.jar"/>
    <include name="bytebuddy/byte-buddy-agent-1.6.8.jar"/>
    <include name="objenesis/objenesis-2.5.1.jar"/>
  </fileset>

  <path id="compile.classpath">
    <fileset refid="lib"/>
  </path>
	
  <path id="test.classpath">
    <path refid="compile.classpath"/>
    <fileset file="${dist}/${jar.file}"/>
  </path>

  <path id="src.path">
    <pathelement location="${src}" />
    <pathelement location="${test.src}" />
  </path>

  <target name="compile" description="compile the source">
    <mkdir dir="${classes}"/>
    <mkdir dir="${dist}"/>
    <exec executable="git" outputproperty="git.url"><arg line="config --get remote.origin.url"/></exec>
    <exec executable="git" outputproperty="git.branch"><arg line="rev-parse --abbrev-ref HEAD"/></exec>
    <exec executable="git" outputproperty="git.commit"><arg line="rev-parse HEAD"/></exec>
    <echo file="${src}/git.properties">giturl=${git.url}
branch=${git.branch}
commit=${git.commit}</echo>
    <!-- Compile class files-->
    <javac destdir="${classes}"
        includeantruntime="false"
        target="1.8"
        source="1.8"
        debug="true"
        classpathref="compile.classpath"
        compiler="modern">
      <src refid="src.path"/>
    </javac>
    <!-- Copy resource files-->
    <copy todir="${classes}">
      <fileset dir="${src}"/>
    </copy>
    <copy todir="${classes}">
      <fileset dir="${test.src}"/>
    </copy>
    <jar destfile="${dist}/${jar.file}" basedir="${classes}"/>
  </target>

  <target name="war" depends="compile" description="build the WAR file. Assumes compile has been run">
    <!-- make the war file for the server-->
    <mkdir dir="${dist}/lib"/>
    <copy todir="${dist}/lib/" flatten="true">
      <fileset refid="lib"/>
      <resources>
        <file file="${dist}/${jar.file}"/>
      </resources>
    </copy>
    <war destfile="${dist}/${war.file}" webxml="${web.xml}">
      <lib dir="${dist}/lib/"/>
    </war>
    <delete dir="${dist}/lib"/>
    <mkdir dir="${scripts}/webapps"/>
    <copy file="${dist}/${war.file}" tofile="${scripts}/webapps/root.war"/>
  </target>

  <target name="build-executable-script"
      depends="compile"
      description="create command-line script">
    <mkdir dir="${bin}"/>
    <property name="jar.absolute.path" location="${dist}/${jar.file}"/>
    <pathconvert targetos="unix" property="lib.classpath" refid="compile.classpath"/>
    <echo file="${bin}/${exec.cmd.file}">#!/bin/bash
java -cp ${jar.absolute.path}:${lib.classpath} kbasesearchengine.KBaseSearchEngineServer $1 $2 $3
    </echo>
    <chmod file="${bin}/${exec.cmd.file}" perm="a+x"/>
    <echo file="${bin}/${exec.cmd.file2}">#!/bin/bash
java -Xmx2g -cp ${jar.absolute.path}:${lib.classpath} kbasesearchengine.main.test.PerformanceTester
    </echo>
    <chmod file="${bin}/${exec.cmd.file2}" perm="a+x"/>
    <echo file="${bin}/${exec.cmd.search_tools}">#!/bin/sh
java -cp ${jar.absolute.path}:${lib.classpath} kbasesearchengine.tools.SearchTools $@
    </echo>
    <chmod file="${bin}/${exec.cmd.search_tools}" perm="a+x"/>
  </target>
	
  <target name="test" description="run all tests">
    <delete dir="${test.reports.dir}"/>
    <mkdir dir="${test.reports.dir}"/>
    <jacoco:coverage destfile="${test.reports.dir}/jacoco.exec"
                     excludes="org/*:junit/*">
      <junit printsummary="yes" haltonfailure="yes" fork="true">
        <classpath refid="test.classpath"/>
        <formatter type="plain" usefile="false" />
        <sysproperty key="test.cfg" value="${test.cfg}"/>
        <test name="kbasesearchengine.test.authorization.AccessGroupCacheTest"/>
        <test name="kbasesearchengine.test.common.FileUtilTest"/>
        <test name="kbasesearchengine.test.common.GUIDTest"/>
        <test name="kbasesearchengine.test.events.AccessGroupEventQueueTest"/>
        <test name="kbasesearchengine.test.events.ChildStatusEventTest"/>
        <test name="kbasesearchengine.test.events.EventQueueTest"/>
        <test name="kbasesearchengine.test.events.ObjectEventQueueTest"/>
        <test name="kbasesearchengine.test.events.StatusEventIDTest"/>
        <test name="kbasesearchengine.test.events.StatusEventTest"/>
        <test name="kbasesearchengine.test.events.StoredChildStatusEventTest"/>
{'fraction_non_alphanumeric': 0.20689198144466533, 'fraction_numerical': 0.016699801192842943, 'mean_word_length': 3.7396356783919598, 'pattern_counts': {'":': 0, '<': 302, '<?xml version=': 0, '>': 302, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 11}, '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': '6553244', 'n_tokens_mistral': 5239, 'n_tokens_neox': 5121, 'n_words': 751}