<commit_before><project name="reviki" default="war" basedir=".">
  <description>
    reviki build - see http://reviki.org for more information
  </description>

  <presetdef name="rjavac">
    <!-- http://stackoverflow.com/a/8114557 -->
    <javac includeantruntime="false">
      <compilerarg value="-Xlint:unchecked" />
      <compilerarg value="-Xlint:deprecation" />
    </javac>
  </presetdef>

  <property name="buildNumber" value="dev" />   
  <property name="version" value="0.4.0" /> 
  <property name="build-details" value="${version} r${buildNumber}" />
  <property name="source" value="src" />   
  <property name="web" value="WebContent" />   
  <property name="build-classes" value="ant-build/classes" />   
  <property name="build-web" value="ant-build/web" />   
  <property name="reports" value="reports" />   
  <property name="release" value="release" />   
  <property name="jar" value="${build-web}/WEB-INF/lib/reviki.jar"/>
  <property name="testJar" value="ant-build/reviki-test.jar"/>
  <property name="war" value="${release}/${ant.project.name}.war" />   
  <property name="prepopulated-pages" value="net/hillsdon/reviki/web/vcintegration/prepopulated/**"/>

  <property name="source-webtests" value="webtests" />   
  <property name="build-webtests" value="ant-build/webtests" />   
  <property name="tomcat" value="tomcat"/>
  <property name="tomcat.version" value="6.0.39"/>
  <property name="tomcat-url" value="http://mirror.ox.ac.uk/sites/rsync.apache.org/tomcat/tomcat-6/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.zip"/>

  <!-- The VNU jar at this URL is repackaged with jarjar to avoid contributing conflicting versions of embedded libraries to other parts of the build. -->
  <property name="vnu-url" value="https://github.com/paulcadman/build/releases/download/20140424/vnu-20140424-jarjar.jar"/>

  <!-- For now, to run the functional tests you need to set up SVN and reviki.properties manually.
       The wiki should be called 'test' (with no base URL set).
       
       Note the wiki data will be stored in ./reviki-test-data, not the usual ~/reviki-data
       directory.

       An external properties file is used to retrieve the username and password to use.
       See the file "build.properties.example".
  -->
  <property file="build.properties" />

  <path id="classpath">
     <fileset dir="lib">
        <include name="*.jar" />
     </fileset>
     <fileset dir="${web}/WEB-INF/lib">
        <include name="*.jar" />
     </fileset>
  </path>    

  <target name="init">
     <get src="${vnu-url}" dest="lib/vnu.jar" usetimestamp="true" />

     <mkdir dir="${build-classes}" />
     <mkdir dir="${build-web}" />
     <mkdir dir="${build-webtests}" />
     <mkdir dir="${reports}" />
     <mkdir dir="${release}" />
  </target>

  <target name="clean" description="Clean-up build artifacts">
    <delete dir="${build-classes}" />
    <delete dir="${build-web}" />
    <delete dir="${build-webtests}" />
    <delete dir="${reports}" />
    <delete dir="${release}" />
    <delete file="${war}"/>
    <delete dir="${tomcat}" />
    <!-- We leave the tomcat zip as it is a large download. -->
  </target>

  <target name="compile" depends="init">
    <rjavac srcdir="${source}" destdir="${build-classes}" fork="yes" target="1.6" source="1.6" debug="true">
      <classpath refid="classpath" />
    </rjavac>
    <copy todir="${build-web}">
      <fileset dir="${web}">
        <include name="*/**"/>
      </fileset>
    </copy>
    <replace file="${build-web}/WEB-INF/templates/SiteTemplate.jsp" token="$Version$" value="${build-details}"/>
    <copy todir="${build-classes}">
      <fileset dir="${source}">
        <include name="**/*.json"/>
        <include name="**/*.jar"/>
        <include name="**/*.xml"/>
        <include name="${prepopulated-pages}"/>
        <include name="net/hillsdon/reviki/web/taglib/reviki.tld"/>
      </fileset>
    </copy>
  </target>

  <target name="jar" depends="compile">
    <jar destfile="${jar}">
      <fileset dir="${build-classes}">
         <include name="**/*.class"/>
         <include name="${prepopulated-pages}"/>
      </fileset>
    </jar>
  </target>

  <target name="test-jar" depends="functional-tests-compile">
    <jar destfile="${testJar}">
      <fileset dir="${build-webtests}">
        <include name="**/*.class"/>
      </fileset>
    </jar>
  </target>

  <target name="functional-tests-compile" depends="compile">
    <rjavac srcdir="${source-webtests}" destdir="${build-webtests}" target="1.5" debug="true">
      <classpath>
        <path refid="classpath" />
        <pathelement location="${build-classes}"/>
      </classpath>
    </rjavac>
  </target>

  <target name="taglib-jar" depends="compile" description="Rebuild the JSP taglib JAR file">
    <mkdir dir="${build-classes}/META-INF"/>
    <move file="${build-classes}/net/hillsdon/reviki/web/taglib/reviki.tld" tofile="${build-classes}/META-INF/reviki.tld"/>
    <jar destfile="WebContent/WEB-INF/lib/reviki-tlds.jar" >
      <fileset dir="${build-classes}">
        <include name="net/hillsdon/reviki/web/taglib/**/*.class"/>
      </fileset>
      <metainf dir="${build-classes}/META-INF">
        <include name="**/*"/>
      </metainf>
    </jar>
  </target>

  <target name="unit-tests" depends="compile" description="Run the unit tests">
    <junit printsummary="yes" fork="true" forkmode="once" haltonfailure="yes">
      <formatter type="plain" usefile="false"/>
      <classpath>
        <path refid="classpath"/>
        <pathelement location="${build-classes}"/>
      </classpath>
      <formatter type="xml"/>
      <batchtest todir="${reports}">
        <fileset dir="${source}">
          <include name="**/Test*.java"/>
        </fileset>
      </batchtest>
    </junit>
  </target>

  <target name="war" depends="jar" description="Build the WAR file">
    <war warfile="${war}"
         webxml="${build-web}/WEB-INF/web.xml">
       <fileset dir="${build-web}">
         <include name="**/*"/>
         <exclude name="WEB-INF/**/*"/>
       </fileset>
       <webinf dir="${build-web}/WEB-INF" includes="**" excludes="web.xml" />
    </war>
  	<!-- Output version information file for the build system. -->
  	<echo message="${version}" file="${release}/product.version"/>
  </target>

  <target name="prepare-tomcat">
    <mkdir dir="${tomcat}"/>
    <get src="${tomcat-url}" dest="tomcat.zip" usetimestamp="true" />

    <!-- Use regexpmapper directly with unzip when we can depend on Ant 1.7. -->    
    <mkdir dir="${tomcat}-unziphelper"/>
    <unzip src="tomcat.zip" dest="${tomcat}-unziphelper"/>
    <copy todir="${tomcat}">
      <fileset dir="${tomcat}-unziphelper" includes="**/*"/>
      <regexpmapper handledirsep="true" from="apache-tomcat-.*?/(.*)" to="\1"/>
    </copy>
    <delete dir="${tomcat}-unziphelper"/>
    <!-- Full of JSPs that the Eclipse validation objects to. -->
    <delete dir="${tomcat}/webapps"/>
    <mkdir dir="${tomcat}/webapps"/>

    <!-- Would be really useful to munge the port numbers to something unusual here,
         8080 will often conflict with something else.  Perhaps some XSLT? -->
    <chmod dir="${tomcat}/bin" includes="**/*.sh" perm="u+x" />
  </target>

  <target name="deploy" depends="war, prepare-tomcat" description="Build and deploy the WAR to tomcat, ready to be started">
    <property name="deploy-dir" value="${tomcat}/conf/Catalina/localhost"/>
    <mkdir dir="${deploy-dir}"/>
    <copy file="context.xml" tofile="${deploy-dir}/reviki.xml"/>
  </target>

  <target name="start-tomcat" description="Start tomcat at localhost:8080">
    <!-- XXX: Is there a platform independent way to start/stop tomcat? -->
    <exec executable="${tomcat}/bin/startup.sh"/>
    <waitfor maxwait="15" maxwaitunit="second" checkevery="500" timeoutproperty="start-tomcat-failed">
      <http url="http://localhost:8080/reviki/"/>
    </waitfor>
    <fail if="start-tomcat-failed" />
  </target>

  <target name="stop-tomcat" description="Stop tomcat launched by start-tomcat">
    <exec executable="${tomcat}/bin/shutdown.sh"/>
  </target>

  <target name="functional-tests-junit" depends="functional-tests-compile">
    <junit printsummary="yes" fork="yes" forkmode="once" failureproperty="functional-tests-failed">
      <jvmarg value="-Dwiki.url=${wiki.url}" />
      <jvmarg value="-Dwiki.username=${wiki.username}" />
      <jvmarg value="-Dwiki.password=${wiki.password}" />
      <jvmarg value="-Dwiki.altusername=${wiki.altusername}" />
      <jvmarg value="-Dwiki.altpassword=${wiki.altpassword}" />
      <jvmarg value="-Dwiki.svn=${wiki.svn}" />
      <formatter type="plain" usefile="false"/>
      <classpath>
        <path refid="classpath"/>
        <pathelement location="${build-classes}"/>
        <pathelement location="${build-webtests}"/>
      </classpath>
      <formatter type="xml"/>
      <batchtest todir="${reports}">
        <fileset dir="${source-webtests}">
          <include name="**/Test*.java"/>
        </fileset>
      </batchtest>
    </junit>
  </target>

  <target name="functional-tests" depends="deploy" description="Run the functional tests against a tomcat started/stopped by ant">
    <antcall>
      <target name="start-tomcat" />
      <target name="functional-tests-junit"/>
      <target name="stop-tomcat" />
      <target name="fail-iff-functional-tests-failed"/>
    </antcall>
  </target>

  <target name="functional-tests-external" description="Run the functional tests against a tomcat outside of ant's control">
    <antcall>
      <target name="functional-tests-junit"/>
      <target name="fail-iff-functional-tests-failed"/>
    </antcall>
  </target>

  <target name="fail-iff-functional-tests-failed">
    <fail if="functional-tests-failed" />
  </target>

  <target name="all-tests" depends="unit-tests, functional-tests" description="Run all the tests (starts/stops tomcat)"/>

  <target name="release" depends="war, test-jar">
    <property name="release-dirname" value="reviki-${version}-${buildNumber}"/>
    <zip file="${release}/${release-dirname}.zip">
      <zipfileset prefix="${release-dirname}" dir=".">
        <include name="${war}"/>
      </zipfileset>
      <zipfileset prefix="${release-dirname}" dir="docs">
        <include name="*.TXT"/>
      </zipfileset>
    </zip>
    <!-- Take a copy of the reviki JARs for building plugins against. -->
    <copy file="${jar}" todir="${release}"/>
    <copy file="${testJar}" todir="${release}"/>
  </target>

</project>

<commit_msg>Build ANTLR classes<commit_after><project name="reviki" default="war" basedir=".">
  <description>
    reviki build - see http://reviki.org for more information
  </description>

  <presetdef name="rjavac">
    <!-- http://stackoverflow.com/a/8114557 -->
    <javac includeantruntime="false">
      <compilerarg value="-Xlint:unchecked" />
      <compilerarg value="-Xlint:deprecation" />
    </javac>
  </presetdef>

  <property name="buildNumber" value="dev" />   
  <property name="version" value="0.4.0" /> 
  <property name="build-details" value="${version} r${buildNumber}" />
  <property name="source" value="src" />   
  <property name="web" value="WebContent" />   
  <property name="build-classes" value="ant-build/classes" />   
  <property name="build-web" value="ant-build/web" />   
  <property name="reports" value="reports" />   
  <property name="release" value="release" />   
  <property name="jar" value="${build-web}/WEB-INF/lib/reviki.jar"/>
  <property name="testJar" value="ant-build/reviki-test.jar"/>
  <property name="war" value="${release}/${ant.project.name}.war" />   
  <property name="prepopulated-pages" value="net/hillsdon/reviki/web/vcintegration/prepopulated/**"/>

  <property name="source-webtests" value="webtests" />   
  <property name="build-webtests" value="ant-build/webtests" />   
  <property name="tomcat" value="tomcat"/>
  <property name="tomcat.version" value="6.0.39"/>
  <property name="tomcat-url" value="http://mirror.ox.ac.uk/sites/rsync.apache.org/tomcat/tomcat-6/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.zip"/>

  <!-- The VNU jar at this URL is repackaged with jarjar to avoid contributing conflicting versions of embedded libraries to other parts of the build. -->
  <property name="vnu-url" value="https://github.com/paulcadman/build/releases/download/20140424/vnu-20140424-jarjar.jar"/>

  <!-- For now, to run the functional tests you need to set up SVN and reviki.properties manually.
       The wiki should be called 'test' (with no base URL set).
       
       Note the wiki data will be stored in ./reviki-test-data, not the usual ~/reviki-data
       directory.

       An external properties file is used to retrieve the username and password to use.
       See the file "build.properties.example".
  -->
  <property file="build.properties" />

  <path id="classpath">
     <fileset dir="lib">
        <include name="*.jar" />
     </fileset>
     <fileset dir="${web}/WEB-INF/lib">
        <include name="*.jar" />
     </fileset>
  </path>    

  <target name="init">
     <get src="${vnu-url}" dest="lib/vnu.jar" usetimestamp="true" />

     <mkdir dir="${build-classes}" />
     <mkdir dir="${build-web}" />
     <mkdir dir="${build-webtests}" />
     <mkdir dir="${reports}" />
     <mkdir dir="${release}" />
  </target>

  <target name="clean" description="Clean-up build artifacts">
    <delete dir="${build-classes}" />
    <delete dir="${build-web}" />
    <delete dir="${build-webtests}" />
    <delete dir="${reports}" />
    <delete dir="${release}" />
    <delete file="${war}"/>
    <delete dir="${tomcat}" />
    <!-- We leave the tomcat zip as it is a large download. -->
  </target>

  <target name="compile" depends="init">
    <java jar="lib/antlr4.jar" dir="src/net/hillsdon/reviki/wiki/renderer/creole" fork="true">
      <arg value="-package"/>
      <arg value="net.hillsdon.reviki.wiki.renderer.creole"/>
      <arg value="-visitor"/>
      <arg value="Creole.g4"/>
      <arg value="CreoleTokens.g4"/>
    </java>

    <rjavac srcdir="${source}" destdir="${build-classes}" fork="yes" target="1.6" source="1.6" debug="true">
      <classpath refid="classpath" />
    </rjavac>
    <copy todir="${build-web}">
      <fileset dir="${web}">
        <include name="*/**"/>
      </fileset>
    </copy>
    <replace file="${build-web}/WEB-INF/templates/SiteTemplate.jsp" token="$Version$" value="${build-details}"/>
    <copy todir="${build-classes}">
      <fileset dir="${source}">
        <include name="**/*.json"/>
        <include name="**/*.jar"/>
        <include name="**/*.xml"/>
        <include name="${prepopulated-pages}"/>
        <include name="net/hillsdon/reviki/web/taglib/reviki.tld"/>
      </fileset>
    </copy>
  </target>

  <target name="jar" depends="compile">
    <jar destfile="${jar}">
      <fileset dir="${build-classes}">
         <include name="**/*.class"/>
         <include name="${prepopulated-pages}"/>
      </fileset>
    </jar>
  </target>

  <target name="test-jar" depends="functional-tests-compile">
    <jar destfile="${testJar}">
      <fileset dir="${build-webtests}">
        <include name="**/*.class"/>
      </fileset>
    </jar>
  </target>

  <target name="functional-tests-compile" depends="compile">
    <rjavac srcdir="${source-webtests}" destdir="${build-webtests}" target="1.5" debug="true">
      <classpath>
        <path refid="classpath" />
        <pathelement location="${build-classes}"/>
      </classpath>
    </rjavac>
  </target>

  <target name="taglib-jar" depends="compile" description="Rebuild the JSP taglib JAR file">
    <mkdir dir="${build-classes}/META-INF"/>
    <move file="${build-classes}/net/hillsdon/reviki/web/taglib/reviki.tld" tofile="${build-classes}/META-INF/reviki.tld"/>
    <jar destfile="WebContent/WEB-INF/lib/reviki-tlds.jar" >
      <fileset dir="${build-classes}">
        <include name="net/hillsdon/reviki/web/taglib/**/*.class"/>
      </fileset>
      <metainf dir="${build-classes}/META-INF">
        <include name="**/*"/>
      </metainf>
    </jar>
  </target>

  <target name="unit-tests" depends="compile" description="Run the unit tests">
    <junit printsummary="yes" fork="true" forkmode="once" haltonfailure="yes">
      <formatter type="plain" usefile="false"/>
      <classpath>
        <path refid="classpath"/>
        <pathelement location="${build-classes}"/>
      </classpath>
      <formatter type="xml"/>
      <batchtest todir="${reports}">
        <fileset dir="${source}">
          <include name="**/Test*.java"/>
        </fileset>
      </batchtest>
    </junit>
  </target>

  <target name="war" depends="jar" description="Build the WAR file">
    <war warfile="${war}"
         webxml="${build-web}/WEB-INF/web.xml">
       <fileset dir="${build-web}">
         <include name="**/*"/>
         <exclude name="WEB-INF/**/*"/>
       </fileset>
       <webinf dir="${build-web}/WEB-INF" includes="**" excludes="web.xml" />
    </war>
  	<!-- Output version information file for the build system. -->
  	<echo message="${version}" file="${release}/product.version"/>
  </target>

  <target name="prepare-tomcat">
    <mkdir dir="${tomcat}"/>
    <get src="${tomcat-url}" dest="tomcat.zip" usetimestamp="true" />

    <!-- Use regexpmapper directly with unzip when we can depend on Ant 1.7. -->    
    <mkdir dir="${tomcat}-unziphelper"/>
    <unzip src="tomcat.zip" dest="${tomcat}-unziphelper"/>
    <copy todir="${tomcat}">
      <fileset dir="${tomcat}-unziphelper" includes="**/*"/>
      <regexpmapper handledirsep="true" from="apache-tomcat-.*?/(.*)" to="\1"/>
    </copy>
    <delete dir="${tomcat}-unziphelper"/>
    <!-- Full of JSPs that the Eclipse validation objects to. -->
    <delete dir="${tomcat}/webapps"/>
    <mkdir dir="${tomcat}/webapps"/>

    <!-- Would be really useful to munge the port numbers to something unusual here,
         8080 will often conflict with something else.  Perhaps some XSLT? -->
    <chmod dir="${tomcat}/bin" includes="**/*.sh" perm="u+x" />
  </target>

  <target name="deploy" depends="war, prepare-tomcat" description="Build and deploy the WAR to tomcat, ready to be started">
    <property name="deploy-dir" value="${tomcat}/conf/Catalina/localhost"/>
    <mkdir dir="${deploy-dir}"/>
    <copy file="context.xml" tofile="${deploy-dir}/reviki.xml"/>
  </target>

  <target name="start-tomcat" description="Start tomcat at localhost:8080">
    <!-- XXX: Is there a platform independent way to start/stop tomcat? -->
    <exec executable="${tomcat}/bin/startup.sh"/>
    <waitfor maxwait="15" maxwaitunit="second" checkevery="500" timeoutproperty="start-tomcat-failed">
      <http url="http://localhost:8080/reviki/"/>
    </waitfor>
    <fail if="start-tomcat-failed" />
  </target>

  <target name="stop-tomcat" description="Stop tomcat launched by start-tomcat">
    <exec executable="${tomcat}/bin/shutdown.sh"/>
  </target>

  <target name="functional-tests-junit" depends="functional-tests-compile">
    <junit printsummary="yes" fork="yes" forkmode="once" failureproperty="functional-tests-failed">
      <jvmarg value="-Dwiki.url=${wiki.url}" />
      <jvmarg value="-Dwiki.username=${wiki.username}" />
      <jvmarg value="-Dwiki.password=${<PASSWORD>}" />
      <jvmarg value="-Dwiki.altusername=${wiki.altusername}" />
      <jvmarg value="-Dwiki.altpassword=${wiki.altpassword}" />
      <jvmarg value="-Dwiki.svn=${wiki.svn}" />
      <formatter type="plain" usefile="false"/>
      <classpath>
        <path refid="classpath"/>
        <pathelement location="${build-classes}"/>
        <pathelement location="${build-webtests}"/>
      </classpath>
      <formatter type="xml"/>
      <batchtest todir="${reports}">
        <fileset dir="${source-webtests}">
          <include name="**/Test*.java"/>
        </fileset>
      </batchtest>
    </junit>
  </target>

  <target name="functional-tests" depends="deploy" description="Run the functional tests against a tomcat started/stopped by ant">
    <antcall>
      <target name="start-tomcat" />
      <target name="functional-tests-junit"/>
      <target name="stop-tomcat" />
      <target name="fail-iff-functional-tests-failed"/>
    </antcall>
  </target>

  <target name="functional-tests-external" description="Run the functional tests against a tomcat outside of ant's control">
    <antcall>
      <target name="functional-tests-junit"/>
      <target name="fail-iff-functional-tests-failed"/>
    </antcall>
  </target>

  <target name="fail-iff-functional-tests-failed">
    <fail if="functional-tests-failed" />
  </target>

  <target name="all-tests" depends="unit-tests, functional-tests" description="Run all the tests (starts/stops tomcat)"/>

  <target name="release" depends="war, test-jar">
    <property name="release-dirname" value="reviki-${version}-${buildNumber}"/>
    <zip file="${release}/${release-dirname}.zip">
      <zipfileset prefix="${release-dirname}" dir=".">
        <include name="${war}"/>
      </zipfileset>
      <zipfileset prefix="${release-dirname}" dir="docs">
        <include name="*.TXT"/>
      </zipfileset>
    </zip>
    <!-- Take a copy of the reviki JARs for building plugins against. -->
    <copy file="${jar}" todir="${release}"/>
    <copy file="${testJar}" todir="${release}"/>
  </target>

</project>


{'fraction_non_alphanumeric': 0.1980773739742087, 'fraction_numerical': 0.005486518171160609, 'mean_word_length': 3.2987300947389637, 'pattern_counts': {'":': 0, '<': 465, '<?xml version=': 0, '>': 465, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 16}, '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': '5024267', 'n_tokens_mistral': 6908, 'n_tokens_neox': 6676, 'n_words': 1399}