2017-12-04 11:14:13 +00:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
|
|
|
|
<!DOCTYPE project [
|
|
|
|
<!ENTITY base SYSTEM "src/build/java/base.xml">
|
|
|
|
]>
|
|
|
|
|
2019-08-06 15:32:51 +00:00
|
|
|
<project default="usage" name="metrics-web" basedir="."
|
|
|
|
xmlns:ivy="antlib:org.apache.ivy.ant">
|
2017-12-04 11:14:13 +00:00
|
|
|
|
|
|
|
<property name="javadoc-title" value="MetricsWeb API Documentation"/>
|
|
|
|
<property name="implementation-title" value="metrics-web" />
|
2019-11-09 21:46:28 +00:00
|
|
|
<property name="release.version" value="1.3.0-dev" />
|
2020-04-18 16:21:03 +00:00
|
|
|
<property name="metricslibversion" value="2.11.0" />
|
|
|
|
<property name="exoneratorversion" value="4.4.0" />
|
2017-12-04 11:14:13 +00:00
|
|
|
<property name="jetty.version" value="-9.2.21.v20170120" />
|
|
|
|
<property name="warfile"
|
|
|
|
value="metrics-web-${release.version}.war"/>
|
|
|
|
|
|
|
|
<property name="name" value="metrics-web"/>
|
|
|
|
|
|
|
|
<property name="project-main-class"
|
2019-01-24 09:08:02 +00:00
|
|
|
value="org.torproject.metrics.stats.main.Main" />
|
|
|
|
<property name="jarincludes" value="logback.xml" />
|
2017-12-04 11:14:13 +00:00
|
|
|
<property name="additional2sign" value="${warfile}" />
|
|
|
|
<property name="tardepends" value="war" />
|
|
|
|
|
|
|
|
<property name="Rsources" value="${basedir}/src/main/R" />
|
|
|
|
|
2018-01-31 19:29:57 +00:00
|
|
|
<property name="specdir" value="${basedir}/generated/spec" />
|
|
|
|
|
2017-12-04 11:14:13 +00:00
|
|
|
<!-- The coverage needs to be improved! -->
|
|
|
|
<target name="coverage-check">
|
|
|
|
<cobertura-check totallinerate="0" totalbranchrate="0" >
|
|
|
|
<!-- example regexes
|
|
|
|
<regex pattern="org.torproject.abc.xyz.*"
|
|
|
|
branchrate="87" linerate="73"/>
|
|
|
|
-->
|
|
|
|
</cobertura-check>
|
|
|
|
</target>
|
|
|
|
|
|
|
|
<patternset id="common" >
|
|
|
|
<include name="commons-codec-1.10.jar"/>
|
|
|
|
<include name="commons-lang3-3.5.jar"/>
|
2018-10-10 13:48:12 +00:00
|
|
|
<include name="commons-math3-3.6.1.jar"/>
|
2018-05-22 19:41:18 +00:00
|
|
|
<include name="jackson-annotations-2.8.6.jar"/>
|
|
|
|
<include name="jackson-core-2.8.6.jar"/>
|
|
|
|
<include name="jackson-databind-2.8.6.jar"/>
|
2017-12-04 11:14:13 +00:00
|
|
|
<include name="logback-core-1.1.9.jar" />
|
|
|
|
<include name="logback-classic-1.1.9.jar" />
|
2019-08-06 15:32:51 +00:00
|
|
|
<include name="REngine-2.1.0.jar"/>
|
|
|
|
<include name="Rserve-1.8.1.jar"/>
|
2017-12-04 11:14:13 +00:00
|
|
|
<include name="slf4j-api-1.7.22.jar"/>
|
|
|
|
</patternset>
|
|
|
|
|
|
|
|
<patternset id="library" >
|
|
|
|
<patternset refid="common" />
|
2019-08-06 15:32:51 +00:00
|
|
|
<include name="metrics-lib-${metricslibversion}-thin.jar"/>
|
2017-12-04 11:14:13 +00:00
|
|
|
<include name="commons-compress-1.13.jar"/>
|
2018-05-19 19:08:42 +00:00
|
|
|
<include name="commons-math3-3.6.1.jar"/>
|
2019-09-17 08:05:27 +00:00
|
|
|
<include name="postgresql-42.2.5.jar"/>
|
2019-08-06 15:32:51 +00:00
|
|
|
<include name="javax.servlet-api-3.1.0.jar"/>
|
2017-12-04 11:14:13 +00:00
|
|
|
<include name="xz-1.6.jar"/>
|
|
|
|
</patternset>
|
|
|
|
|
2017-12-04 11:14:35 +00:00
|
|
|
<patternset id="web" >
|
2018-08-10 07:35:50 +00:00
|
|
|
<include name="exonerator-${exoneratorversion}-thin.jar" />
|
2019-08-06 15:32:51 +00:00
|
|
|
<include name="jetty-annotations${jetty.version}.jar"/>
|
|
|
|
<include name="jetty-server${jetty.version}.jar"/>
|
|
|
|
<include name="jetty-servlet${jetty.version}.jar"/>
|
|
|
|
<include name="jetty-util${jetty.version}.jar"/>
|
|
|
|
<include name="jetty-http${jetty.version}.jar"/>
|
|
|
|
<include name="jetty-io${jetty.version}.jar"/>
|
|
|
|
<include name="jetty-xml${jetty.version}.jar"/>
|
|
|
|
<include name="jetty-webapp${jetty.version}.jar"/>
|
|
|
|
<include name="jetty-continuation${jetty.version}.jar"/>
|
|
|
|
<include name="jetty-security${jetty.version}.jar"/>
|
2017-12-04 11:14:35 +00:00
|
|
|
</patternset>
|
|
|
|
|
|
|
|
<patternset id="webruntime" >
|
2019-08-06 15:32:51 +00:00
|
|
|
<include name="asm-5.0.1.jar" />
|
|
|
|
<include name="asm-commons-5.0.1.jar" />
|
2018-01-08 09:52:33 +00:00
|
|
|
<include name="commons-compress-1.13.jar"/>
|
2019-08-06 15:32:51 +00:00
|
|
|
<include name="jetty-plus${jetty.version}.jar"/>
|
|
|
|
<include name="jetty-jndi${jetty.version}.jar"/>
|
|
|
|
<include name="apache-jsp${jetty.version}.jar" />
|
2019-08-21 06:33:05 +00:00
|
|
|
<include name="metrics-lib-${metricslibversion}-thin.jar"/>
|
2017-12-04 11:14:35 +00:00
|
|
|
<include name="taglibs-standard-spec-1.2.5.jar"/>
|
2019-08-06 15:32:51 +00:00
|
|
|
<include name="tomcat-embed-jasper-8.5.14.jar" />
|
|
|
|
<include name="tomcat-embed-el-8.5.14.jar" />
|
|
|
|
<include name="tomcat-embed-core-8.5.14.jar" />
|
|
|
|
<include name="ecj-4.6.1.jar" />
|
2017-12-04 11:14:35 +00:00
|
|
|
</patternset>
|
|
|
|
|
2017-12-04 11:14:13 +00:00
|
|
|
<patternset id="runtime" >
|
|
|
|
<patternset refid="library" />
|
2017-12-04 11:14:35 +00:00
|
|
|
<patternset refid="web" />
|
2017-12-04 11:14:13 +00:00
|
|
|
</patternset>
|
|
|
|
|
2017-12-20 13:06:59 +00:00
|
|
|
<!-- Tasks for database testing. -->
|
|
|
|
<target name="test-all-dbs"
|
|
|
|
depends="init"
|
|
|
|
description="Run all available database pgTAP tests." >
|
|
|
|
<antcall target="test-db">
|
2018-11-14 09:48:56 +00:00
|
|
|
<param name="db2test" value="servers" />
|
2017-12-20 13:06:59 +00:00
|
|
|
</antcall>
|
|
|
|
<antcall target="test-db">
|
|
|
|
<param name="db2test" value="userstats" />
|
|
|
|
</antcall>
|
|
|
|
</target>
|
|
|
|
|
|
|
|
<target name="test-db" description="A helper task for task test-all-dbs." >
|
|
|
|
<property name="dbtestlog" value="${basedir}/${generated}/${db2test}-sql-test.txt" />
|
|
|
|
<exec executable="psql"
|
|
|
|
dir="${generated}"
|
|
|
|
failonerror="false" >
|
|
|
|
<arg value="--output=${dbtestlog}" />
|
|
|
|
<arg value="--log-file=${basedir}/${generated}/all-dbs-test.log" />
|
|
|
|
<arg value="--quiet" />
|
|
|
|
<arg value="--file=${basedir}/src/test/sql/${db2test}/test-${db2test}.sql" />
|
|
|
|
<arg value="--dbname=${db2test}"/>
|
|
|
|
</exec>
|
|
|
|
<exec executable="grep" outputproperty="dbtestresult"
|
|
|
|
dir="${generated}"
|
|
|
|
failonerror="false" >
|
|
|
|
<arg value="failed" />
|
|
|
|
<arg value="${dbtestlog}" />
|
|
|
|
</exec>
|
|
|
|
<fail message="${dbtestresult} see ${dbtestlog} for details." >
|
|
|
|
<condition>
|
|
|
|
<not>
|
|
|
|
<length string="${dbtestresult}"
|
|
|
|
length="0" />
|
|
|
|
</not>
|
|
|
|
</condition>
|
|
|
|
</fail>
|
|
|
|
<echo message="Tests for ${db2test} passed." />
|
|
|
|
</target>
|
|
|
|
|
2017-12-04 11:14:36 +00:00
|
|
|
<!-- Create a .war file for deployment. -->
|
|
|
|
<target name="war"
|
2018-04-06 09:02:03 +00:00
|
|
|
depends="submoduleupdate,jar">
|
2017-12-04 11:14:36 +00:00
|
|
|
|
|
|
|
<antcall target="generate-ml-javadoc" />
|
|
|
|
|
|
|
|
<war destfile="${dist}/${warfile}"
|
|
|
|
webxml="${resources}/web.xml"
|
|
|
|
basedir="${classes}">
|
|
|
|
<restrict>
|
|
|
|
<not>
|
|
|
|
<and>
|
|
|
|
<name name="META-INF/*" />
|
|
|
|
<not>
|
|
|
|
<name name="META-INF/services/*" />
|
|
|
|
</not>
|
|
|
|
</and>
|
|
|
|
</not>
|
|
|
|
<archives>
|
|
|
|
<zips>
|
|
|
|
<fileset dir="${libs}">
|
|
|
|
<patternset refid="common" />
|
|
|
|
<patternset refid="web" />
|
|
|
|
<patternset refid="webruntime" />
|
|
|
|
</fileset>
|
|
|
|
</zips>
|
|
|
|
</archives>
|
|
|
|
</restrict>
|
|
|
|
<exclude name="**/Test*.class" />
|
2020-04-02 10:50:58 +00:00
|
|
|
<zipfileset dir="${buildresources}"
|
2017-12-04 11:14:36 +00:00
|
|
|
prefix=""
|
|
|
|
includes="logback.xml" />
|
|
|
|
<zipfileset dir="${resources}/web"
|
|
|
|
prefix=""
|
2018-08-07 13:57:01 +00:00
|
|
|
includes="css/* images/** js/** fonts/** templates/** json/countries.topo.json" />
|
2017-12-04 11:14:36 +00:00
|
|
|
<zipfileset dir="${resources}/web/jsps"
|
|
|
|
prefix="WEB-INF"
|
|
|
|
includes="*.jsp"/>
|
|
|
|
<zipfileset dir="${resources}"
|
|
|
|
includes="*.properties" />
|
|
|
|
<fileset dir="${resources}" includes="jetty.xml" />
|
|
|
|
|
|
|
|
<zipfileset dir="${resources}/web/json"
|
|
|
|
prefix="WEB-INF/json"
|
|
|
|
includes="metrics.json categories.json news.json"/>
|
|
|
|
|
2018-08-10 07:35:50 +00:00
|
|
|
<zipfileset dir="${resources}/web/properties"
|
|
|
|
includes="*.properties"/>
|
|
|
|
|
2017-12-04 11:14:36 +00:00
|
|
|
<zipfileset dir="${basedir}/src/submods/metrics-lib/generated/javadoc"
|
|
|
|
prefix="metrics-lib" />
|
|
|
|
<zipfileset dir="${libs}" prefix="WEB-INF/lib" >
|
|
|
|
<include name="taglibs-standard-impl-1.2.5.jar"/>
|
|
|
|
</zipfileset>
|
|
|
|
|
|
|
|
<metainf dir="${resources}"
|
|
|
|
includes="context.xml"/>
|
|
|
|
<manifest>
|
|
|
|
<attribute name="Implemented-By" value="The Tor Project" />
|
|
|
|
<attribute name="Implementation-Title" value="TorMetricsWeb Server"/>
|
|
|
|
<attribute name="Implementation-Version"
|
|
|
|
value="${release.version}-${git.revision}"/>
|
|
|
|
<attribute name="Main-Class"
|
|
|
|
value="org.torproject.metrics.web.ServerMain" />
|
|
|
|
</manifest>
|
|
|
|
</war>
|
|
|
|
</target>
|
|
|
|
|
2017-12-04 11:14:14 +00:00
|
|
|
<target name="generate-ml-javadoc" depends="submoduleupdate" >
|
|
|
|
<mkdir dir="${basedir}/src/submods/metrics-lib/lib" />
|
|
|
|
<exec executable="ant"
|
|
|
|
dir="${basedir}/src/submods/metrics-lib"
|
|
|
|
failonerror="true" >
|
|
|
|
<arg value="clean" />
|
2019-08-07 19:33:34 +00:00
|
|
|
<arg value="resolve" />
|
2017-12-04 11:14:14 +00:00
|
|
|
<arg value="docs" />
|
|
|
|
</exec>
|
|
|
|
</target>
|
|
|
|
|
2018-03-03 06:35:34 +00:00
|
|
|
<target name="generate-graphviz-pngs" >
|
|
|
|
<apply executable="dot"
|
|
|
|
dest="${basedir}/src/main/resources/web/images"
|
|
|
|
verbose="true" >
|
|
|
|
<arg value="-Tpng" />
|
|
|
|
<arg value="-o" />
|
|
|
|
<targetfile />
|
|
|
|
<srcfile />
|
|
|
|
<fileset dir="${basedir}/src/main/resources/graphviz" >
|
|
|
|
<include name="*.gv" />
|
|
|
|
</fileset>
|
|
|
|
<mapper type="glob" from="*.gv" to="*.png" />
|
|
|
|
</apply>
|
|
|
|
</target>
|
|
|
|
|
2018-03-20 14:23:01 +00:00
|
|
|
<target name="generate-news-json" >
|
|
|
|
<echo message="Running java module UpdateNews ... " />
|
|
|
|
<available file="${dist}/${jarfile}" property="have.jar"/>
|
|
|
|
<fail unless="have.jar" message="Please run 'ant jar' first."/>
|
|
|
|
<java classname="org.torproject.metrics.web.UpdateNews">
|
|
|
|
<arg value="${basedir}/src/main/resources/web/json/news.json" />
|
|
|
|
<classpath>
|
|
|
|
<pathelement location="${dist}/${jarfile}" />
|
|
|
|
<pathelement location="${resources}" />
|
|
|
|
</classpath>
|
|
|
|
</java>
|
|
|
|
<echo message="Java module UpdateNews finished. " />
|
|
|
|
</target>
|
|
|
|
|
2018-01-31 19:29:57 +00:00
|
|
|
<target name="generate-specs" depends="init" >
|
|
|
|
<mkdir dir="${specdir}" />
|
|
|
|
<antcall target="xml2jsp">
|
|
|
|
<param name="specfile" value="bridge-descriptors"/>
|
|
|
|
</antcall>
|
|
|
|
<antcall target="xml2jsp">
|
|
|
|
<param name="specfile" value="web-server-logs"/>
|
|
|
|
</antcall>
|
|
|
|
</target>
|
|
|
|
|
|
|
|
<target name="xml2jsp" >
|
|
|
|
<echo message="Generating ${specfile} specification jsp ... " />
|
|
|
|
<exec executable="saxon-xslt"
|
|
|
|
dir="${specdir}"
|
|
|
|
logError="true"
|
|
|
|
output="${specdir}/${specfile}.tmp"
|
|
|
|
failonerror="true" >
|
|
|
|
<arg value="${basedir}/${resources}/spec/${specfile}.xml" />
|
|
|
|
<arg value="${basedir}/${resources}/spec/rfc2629.xslt" />
|
|
|
|
<arg value="xml2rfc-topblock=no" />
|
|
|
|
</exec>
|
|
|
|
<exec executable="tidy"
|
|
|
|
dir="${specdir}"
|
|
|
|
logError="true"
|
|
|
|
output="${specdir}/${specfile}.tmp2"
|
|
|
|
failonerror="true" >
|
|
|
|
<arg value="-quiet" />
|
|
|
|
<arg value="${specdir}/${specfile}.tmp" />
|
|
|
|
</exec>
|
|
|
|
<exec executable="awk"
|
|
|
|
dir="${specdir}"
|
|
|
|
logError="true"
|
2018-03-28 14:41:19 +00:00
|
|
|
output="${resources}/web/jsps/${specfile}.jsp"
|
2018-01-31 19:29:57 +00:00
|
|
|
failonerror="true" >
|
|
|
|
<arg value="-f" />
|
|
|
|
<arg value="${basedir}/${resources}/spec/convert.awk" />
|
|
|
|
<arg value="${specdir}/${specfile}.tmp2" />
|
|
|
|
</exec>
|
|
|
|
<echo message="Done." />
|
|
|
|
<delete file="${specdir}/${specfile}.tmp" quiet="true" />
|
|
|
|
<delete file="${specdir}/${specfile}.tmp2" quiet="true" />
|
|
|
|
</target>
|
|
|
|
|
2017-12-20 15:40:29 +00:00
|
|
|
<!--
|
|
|
|
The run-rserver target documents a working option of
|
|
|
|
configuring an R server for running metrics-web.
|
|
|
|
It is not necessary for development to use this task
|
|
|
|
and it is not used for metrics.torproject.org in this way.
|
|
|
|
Eventually, this task will become obsolete when R is also
|
|
|
|
controlled from Java code.
|
|
|
|
-->
|
2017-12-04 11:14:17 +00:00
|
|
|
<target name="run-rserver">
|
|
|
|
<exec executable="R"
|
|
|
|
dir="${Rsources}/rserver"
|
|
|
|
failonerror="true" >
|
|
|
|
<arg value="CMD"/>
|
|
|
|
<arg value="Rserve" />
|
|
|
|
<arg value="--no-save" />
|
|
|
|
<arg value="--quiet" />
|
|
|
|
<arg value="--RS-conf" />
|
2017-12-04 11:14:53 +00:00
|
|
|
<arg value="${Rsources}/Rserv.conf" />
|
2017-12-04 11:14:17 +00:00
|
|
|
</exec>
|
|
|
|
</target>
|
|
|
|
|
2019-09-23 13:28:41 +00:00
|
|
|
<target name="fetch-exonerator" depends="init"
|
|
|
|
description="Fetch ExoneraTor from dist.torproject.org">
|
|
|
|
<mkdir dir="${downloadedlibs}"/>
|
|
|
|
<get src="https://dist.torproject.org/exonerator/${exoneratorversion}/exonerator-${exoneratorversion}.tar.gz"
|
|
|
|
dest="${downloadedlibs}"/>
|
|
|
|
<untar src="${downloadedlibs}/exonerator-${exoneratorversion}.tar.gz"
|
|
|
|
dest="${libs}" compression="gzip">
|
|
|
|
<patternset>
|
|
|
|
<include name="**/exonerator-${exoneratorversion}-thin.jar"/>
|
|
|
|
</patternset>
|
|
|
|
<mapper type="flatten"/>
|
|
|
|
</untar>
|
|
|
|
</target>
|
|
|
|
|
2020-02-27 11:27:11 +00:00
|
|
|
<target name="update-fallback-dir-list"
|
|
|
|
description="Update the fallback directory list used by Relay Search">
|
|
|
|
<exec executable="bash">
|
|
|
|
<arg value="-c"/>
|
|
|
|
<arg value="python3 src/main/python/fallback_dir.py | tee src/main/resources/web/js/rs/fallback_dir.js"/>
|
|
|
|
</exec>
|
|
|
|
</target>
|
|
|
|
|
2017-12-04 11:14:13 +00:00
|
|
|
<!-- The following line adds the common targets and properties
|
|
|
|
for Metrics' Java Projects.
|
|
|
|
-->
|
|
|
|
&base;
|
|
|
|
|
|
|
|
</project>
|
|
|
|
|