<commit_before><?xml version="1.0" encoding="ISO-8859-1"?>

<!-- $Id$ -->
<project name="jsimpledb" default="build"
  xmlns:dellroad="urn:org.dellroad.ant"
  xmlns:antcontrib="urn:net.sf.antcontrib"
  xmlns:artifact="antlib:org.apache.maven.artifact.ant"
  xmlns:ivy="urn:org.apache.ivy.ant">

    <!-- Configure build & stuff -->
    <property name="maven.group.id" value="org.jsimpledb"/>
    <property name="library.version" value="1.0"/>
    <property name="javac.compiler.flags" value="-Xlint:all"/>

    <!-- Import generic build macros -->
    <import file="${basedir}/src/build/macros.xml"/>

    <!-- Determine SVN revision and full version -->
    <dellroad:svnrevision property="svn.revision"/>
    <property name="full.version" value="${library.version}.${svn.revision}"/>
    <echo message=""/>
    <echo message="Version is ${library.version}.${svn.revision}"/>
    <echo message=""/>

    <!-- Classpath targets -->
    <target name="build.classpath" unless="build.classpath.resolved">
        <dellroad:ivypath pathid="build.classpath" conf="build"/>
        <property name="build.classpath.resolved" value="true"/>
    </target>

    <target name="javac.classpath" unless="javac.classpath.resolved">
        <dellroad:ivypath pathid="javac.classpath" conf="javac"/>
        <property name="javac.classpath.resolved" value="true"/>
    </target>

    <target name="unittest.classpath" depends="jar" unless="unittest.classpath.resolved">
        <dellroad:ivypath pathid="unittest.classpath" conf="test"/>
        <property name="unittest.classpath.resolved" value="true"/>
    </target>

    <!-- Resources -->
    <target name="resources" unless="resources.completed" description="Gather resources">
        <delete dir="build/resources"/>
        <mkdir dir="build/resources"/>
        <copy todir="build/resources">
            <fileset dir="src/java" includes="**/*.xsd"/>
            <fileset dir="src/properties" includes="${ant.project.name}.properties"/>
            <filterset>
                <filter token="VERSION" value="${full.version}"/>
            </filterset>
        </copy>
        <property name="resources.completed" value="true"/>
    </target>

    <!-- Main JAR -->
    <target name="jar" depends="javac, resources, build.classpath" unless="jar.completed"
      description="Build main JAR">
        <dellroad:ivyput pattern="build/[artifact].[ext]" conf="jarjars"/>
        <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpathref="build.classpath"/>
        <mkdir dir="build/dist"/>
        <delete file="build/dist/${ant.project.name}-${full.version}.jar"/>
        <jarjar destfile="build/dist/${ant.project.name}-${full.version}.jar">
            <zipfileset src="build/asm.jar"/>
            <zipfileset src="build/jline.jar"/>
        <!-- for ClassGenerator debug
            <zipfileset src="build/asm-util.jar"/>
        -->
            <zipfileset src="build/dellroad-stuff.jar">
                <include name="**/*.class"/>
            </zipfileset>
            <rule pattern="org.objectweb.asm.**" result="org.jsimpledb.asm.@1"/>
            <rule pattern="org.dellroad.stuff.**" result="org.jsimpledb.drstuff.@1"/>
            <rule pattern="jline.**" result="org.jsimpledb.jline.@1"/>
            <fileset dir="build/classes"/>
            <fileset dir="build/resources"/>
            <manifest>
                <attribute name="Implementation-Version" value="${full.version}"/>
            </manifest>
            <metainf dir="src/spring" includes="spring.*"/>
            <keep pattern="org.jsimpledb.**"/>
        </jarjar>
        <property name="jar.completed" value="true"/>
    </target>

    <!-- All distribution files -->
    <target name="jars" depends="jar, javadoc" unless="jars.completed"
      description="Build JARs">
        <mkdir dir="build/dist"/>
        <delete file="build/dist/${ant.project.name}-sources-${full.version}.zip"/>
        <zip destfile="build/dist/${ant.project.name}-sources-${full.version}.zip">
            <fileset dir="src/java" includes="**/*"/>
        </zip>
        <delete file="build/dist/${ant.project.name}-javadocs-${full.version}.zip"/>
        <zip destfile="build/dist/${ant.project.name}-javadocs-${full.version}.zip">
            <fileset dir="build/reports/javadoc" includes="**/*"/>
        </zip>
        <property name="jars.completed" value="true"/>
    </target>

    <!-- Build Javadocs -->
    <target name="javadoc" depends="javac" unless="javadoc.completed"
      description="Build API JavaDocs">
        <delete dir="build/javadoc"/>
        <mkdir dir="build/javadoc"/>
        <copy todir="build/javadoc">
            <fileset dir="src/java/org/jsimpledb" includes="overview.html"/>
            <filterset>
                <filter token="VERSION" value="${full.version}"/>
            </filterset>
        </copy>
        <dellroad:javadoc overview="build/javadoc/overview.html">
            <additional-classpath>
                <pathelement path="build/classes"/>
            </additional-classpath>
            <links>
                <link href="http://download.oracle.com/javase/7/docs/api/"/>
                <link href="http://download.oracle.com/javaee/7/api/"/>
                <link href="http://docs.guava-libraries.googlecode.com/git-history/v16.0/javadoc/"/>
                <link href="http://dellroad-stuff.googlecode.com/svn/trunk/publish/reports/javadoc/"/>
                <link href="http://docs.spring.io/spring/docs/4.0.x/javadoc-api/"/>
                <link href="https://foundationdb.com/documentation/javadoc/"/>
                <link href="http://www.slf4j.org/api/"/>
            </links>
        </dellroad:javadoc>
        <property name="javadoc.completed" value="true"/>
    </target>

    <!-- Checkstyle the source -->
    <target name="checkstyle" description="Run checkstyle report"
      depends="javac.classpath, unittest.classpath, checkstyle.classpath"
      unless="checkstyle.completed">
        <dellroad:checkstyle maxWarnings="0" maxErrors="0"/>
        <property name="checkstyle.completed" value="true"/>
    </target>

    <!-- Run unit tests -->
    <target name="tests" description="Run unit tests"
      depends="javac, unittest.classpath, testng.classpath, cobertura.classpath"
      unless="tests.completed">
        <copy todir="build/test" overwrite="true">
            <fileset dir="src/test" includes="**/*.xsl"/>
            <fileset dir="src/test" includes="**/*.xml"/>
        </copy>
        <mkdir dir="build/test/META-INF"/>
        <copy todir="build/test/META-INF" overwrite="true">
            <fileset dir="src/spring" includes="spring.*"/>
        </copy>
        <copy file="src/xml/log4j-build.xml" tofile="build/test/log4j.xml"/>
        <dellroad:unit-tests>
            <addclasspath>
                <path refid="javac.classpath"/>
            </addclasspath>
        </dellroad:unit-tests>
        <property name="tests.completed" value="true"/>
    </target>

    <!-- Publish reports -->
    <target name="publish" description="Publish build results" depends="reports">

        <!-- Remove exisiting stuff first -->
        <delete includeemptydirs="false">
            <fileset dir="publish"><commit_msg>Attempt to work around problem with unit tests and Cobertura. https://github.com/cobertura/cobertura/issues/49<commit_after><?xml version="1.0" encoding="ISO-8859-1"?>

<!-- $Id$ -->
<project name="jsimpledb" default="build"
  xmlns:dellroad="urn:org.dellroad.ant"
  xmlns:antcontrib="urn:net.sf.antcontrib"
  xmlns:artifact="antlib:org.apache.maven.artifact.ant"
  xmlns:ivy="urn:org.apache.ivy.ant">

    <!-- Configure build & stuff -->
    <property name="maven.group.id" value="org.jsimpledb"/>
    <property name="library.version" value="1.0"/>
    <property name="javac.compiler.flags" value="-Xlint:all"/>

    <!-- Import generic build macros -->
    <import file="${basedir}/src/build/macros.xml"/>

    <!-- Determine SVN revision and full version -->
    <dellroad:svnrevision property="svn.revision"/>
    <property name="full.version" value="${library.version}.${svn.revision}"/>
    <echo message=""/>
    <echo message="Version is ${library.version}.${svn.revision}"/>
    <echo message=""/>

    <!-- Classpath targets -->
    <target name="build.classpath" unless="build.classpath.resolved">
        <dellroad:ivypath pathid="build.classpath" conf="build"/>
        <property name="build.classpath.resolved" value="true"/>
    </target>

    <target name="javac.classpath" unless="javac.classpath.resolved">
        <dellroad:ivypath pathid="javac.classpath" conf="javac"/>
        <property name="javac.classpath.resolved" value="true"/>
    </target>

    <target name="unittest.classpath" depends="jar" unless="unittest.classpath.resolved">
        <dellroad:ivypath pathid="unittest.classpath" conf="test"/>
        <property name="unittest.classpath.resolved" value="true"/>
    </target>

    <!-- Resources -->
    <target name="resources" unless="resources.completed" description="Gather resources">
        <delete dir="build/resources"/>
        <mkdir dir="build/resources"/>
        <copy todir="build/resources">
            <fileset dir="src/java" includes="**/*.xsd"/>
            <fileset dir="src/properties" includes="${ant.project.name}.properties"/>
            <filterset>
                <filter token="VERSION" value="${full.version}"/>
            </filterset>
        </copy>
        <property name="resources.completed" value="true"/>
    </target>

    <!-- Main JAR -->
    <target name="jar" depends="javac, resources, build.classpath" unless="jar.completed"
      description="Build main JAR">
        <dellroad:ivyput pattern="build/[artifact].[ext]" conf="jarjars"/>
        <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpathref="build.classpath"/>
        <mkdir dir="build/dist"/>
        <delete file="build/dist/${ant.project.name}-${full.version}.jar"/>
        <jarjar destfile="build/dist/${ant.project.name}-${full.version}.jar">
            <zipfileset src="build/asm.jar"/>
            <zipfileset src="build/jline.jar"/>
        <!-- for ClassGenerator debug
            <zipfileset src="build/asm-util.jar"/>
        -->
            <zipfileset src="build/dellroad-stuff.jar">
                <include name="**/*.class"/>
            </zipfileset>
            <rule pattern="org.objectweb.asm.**" result="org.jsimpledb.asm.@1"/>
            <rule pattern="org.dellroad.stuff.**" result="org.jsimpledb.drstuff.@1"/>
            <rule pattern="jline.**" result="org.jsimpledb.jline.@1"/>
            <fileset dir="build/classes"/>
            <fileset dir="build/resources"/>
            <manifest>
                <attribute name="Implementation-Version" value="${full.version}"/>
            </manifest>
            <metainf dir="src/spring" includes="spring.*"/>
            <keep pattern="org.jsimpledb.**"/>
        </jarjar>
        <property name="jar.completed" value="true"/>
    </target>

    <!-- All distribution files -->
    <target name="jars" depends="jar, javadoc" unless="jars.completed"
      description="Build JARs">
        <mkdir dir="build/dist"/>
        <delete file="build/dist/${ant.project.name}-sources-${full.version}.zip"/>
        <zip destfile="build/dist/${ant.project.name}-sources-${full.version}.zip">
            <fileset dir="src/java" includes="**/*"/>
        </zip>
        <delete file="build/dist/${ant.project.name}-javadocs-${full.version}.zip"/>
        <zip destfile="build/dist/${ant.project.name}-javadocs-${full.version}.zip">
            <fileset dir="build/reports/javadoc" includes="**/*"/>
        </zip>
        <property name="jars.completed" value="true"/>
    </target>

    <!-- Build Javadocs -->
    <target name="javadoc" depends="javac" unless="javadoc.completed"
      description="Build API JavaDocs">
        <delete dir="build/javadoc"/>
        <mkdir dir="build/javadoc"/>
        <copy todir="build/javadoc">
            <fileset dir="src/java/org/jsimpledb" includes="overview.html"/>
            <filterset>
                <filter token="VERSION" value="${full.version}"/>
            </filterset>
        </copy>
        <dellroad:javadoc overview="build/javadoc/overview.html">
            <additional-classpath>
                <pathelement path="build/classes"/>
            </additional-classpath>
            <links>
                <link href="http://download.oracle.com/javase/7/docs/api/"/>
                <link href="http://download.oracle.com/javaee/7/api/"/>
                <link href="http://docs.guava-libraries.googlecode.com/git-history/v16.0/javadoc/"/>
                <link href="http://dellroad-stuff.googlecode.com/svn/trunk/publish/reports/javadoc/"/>
                <link href="http://docs.spring.io/spring/docs/4.0.x/javadoc-api/"/>
                <link href="https://foundationdb.com/documentation/javadoc/"/>
                <link href="http://www.slf4j.org/api/"/>
            </links>
        </dellroad:javadoc>
        <property name="javadoc.completed" value="true"/>
    </target>

    <!-- Checkstyle the source -->
    <target name="checkstyle" description="Run checkstyle report"
      depends="javac.classpath, unittest.classpath, checkstyle.classpath"
      unless="checkstyle.completed">
        <dellroad:checkstyle maxWarnings="0" maxErrors="0"/>
        <property name="checkstyle.completed" value="true"/>
    </target>

    <!-- Run unit tests -->
    <target name="tests" description="Run unit tests"
      depends="javac, unittest.classpath, testng.classpath, cobertura.classpath"
      unless="tests.completed">
        <copy todir="build/test" overwrite="true">
            <fileset dir="src/test" includes="**/*.xsl"/>
            <fileset dir="src/test" includes="**/*.xml"/>
        </copy>
        <mkdir dir="build/test/META-INF"/>
        <copy todir="build/test/META-INF" overwrite="true">
            <fileset dir="src/spring" includes="spring.*"/>
        </copy>
        <copy file="src/xml/log4j-build.xml" tofile="build/test/log4j.xml"/>
        <dellroad:unit-tests>
            <addclasspath>
                <path refid="build.classpath"/>
                <path refid="javac.classpath"/>
            </addclasspath>
        </dellroad:unit-tests>
        <property name="tests.completed" value="true"/>
    </target>

    <!-- Publish reports -->
    <target name="publish" description="Publish build results" depends="reports">

        <!-- Remove exisiting stuff first -->
        <delete includeemptydirs="false">
            <fileset dir="publish">
{'fraction_non_alphanumeric': 0.18149490528619297, 'fraction_numerical': 0.0034192710114203653, 'mean_word_length': 2.617116002968093, 'pattern_counts': {'":': 0, '<': 274, '<?xml version=': 2, '>': 274, 'https://': 3, 'lorem ipsum': 0, 'www.': 2, 'xml': 20}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1934646', 'n_tokens_mistral': 4517, 'n_tokens_neox': 4330, 'n_words': 687}