[tor-commits] [exonerator/master] Use metrics-base as build environment.

karsten at torproject.org karsten at torproject.org
Thu Nov 2 13:06:09 UTC 2017


commit c7de454a62a1d1722b39c81ff6a096a6d2875d02
Author: iwakeh <iwakeh at torproject.org>
Date:   Sat Sep 16 15:13:30 2017 +0000

    Use metrics-base as build environment.
    
    The task 'war' creates a war-file for deployment in tomcat (as before),
    the 'run' task is gone, and 'jar' creates an executable jar with main
    class ExoneraTorDatabaseImporter as well as the source and javadoc jars.
    
    Removed obsolete shell script.
    
    Coverage is really low, but increasing it wasn't part of this task.
    
    Implements task-21145.
---
 .gitmodules                                        |   3 +
 build.xml                                          | 209 +++++++--------------
 run-exonerator.sh                                  |   3 -
 src/build                                          |   1 +
 src/main/resources/bootstrap-development.sh        |  10 +
 src/main/{webapp => resources}/context.xml         |   0
 src/main/{webapp => resources}/web.xml             |   2 +-
 .../web}/css/bootstrap.min.css                     |   0
 .../{webapp => resources/web}/css/exonerator.css   |   0
 .../web}/images/exonerator-logo.png                | Bin
 .../web}/images/exonerator-wordmark.png            | Bin
 .../{webapp => resources/web}/images/favicon.ico   | Bin
 .../WEB-INF => resources/web/jsps}/bottom.jsp      |   0
 .../WEB-INF => resources/web/jsps}/index.jsp       |   0
 .../{webapp/WEB-INF => resources/web/jsps}/top.jsp |   0
 15 files changed, 78 insertions(+), 150 deletions(-)

diff --git a/.gitmodules b/.gitmodules
index e69de29..7d3a2ca 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "src/build"]
+	path = src/build
+	url = https://git.torproject.org/metrics-base.git
diff --git a/build.xml b/build.xml
index 4ba9a3d..ee04e1b 100644
--- a/build.xml
+++ b/build.xml
@@ -1,172 +1,89 @@
-<project default="run" name="exonerator" basedir=".">
+<?xml version="1.0"?>
 
-  <!-- Define build paths. -->
-  <property name="sources" value="src/main/java"/>
-  <property name="resources" value="src/main/resources"/>
-  <property name="webapp" value="src/main/webapp"/>
-  <property name="generated" value="generated/"/>
-  <property name="classes" value="${generated}/classes"/>
-  <property name="testclasses" value="${generated}/testclasses/"/>
-  <property name="dist" value="${generated}/dist"/>
-  <property name="testresources" value="src/test/resources/"/>
-  <property name="testsources" value="src/test/java"/>
-  <property name="testresult" value="${generated}/test-results"/>
-  <property name="libs" value="lib"/>
-  <property name="webxmlfile" value="src/main/webapp/web.xml"/>
-  <property name="warfile" value="${dist}/exonerator.war"/>
-  <property name="source-and-target-java-version" value="1.8" />
-  <property name="metricslibversion" value="2.0.0" />
-  <patternset id="runtime" >
-    <include name="metrics-lib-${metricslibversion}.jar"/>
-    <include name="commons-compress-1.13.jar"/>
+<!DOCTYPE project [
+       <!ENTITY base SYSTEM "src/build/java/base.xml">
+]>
+
+<project default="usage" name="exonerator" basedir=".">
+
+  <property name="javadoc-title" value="ExoneraTor API Documentation"/>
+  <property name="implementation-title" value="ExoneraTor" />
+  <property name="release.version" value="1.0.0-dev" />
+  <property name="metricslibversion" value="2.1.1" />
+  <property name="warfile"
+            value="exonerator-${release.version}.war"/>
+
+  <property name="name" value="exonerator"/>
+
+  <property name="project-main-class"
+            value="org.torproject.exonerator.ExoneraTorDatabaseImporter" />
+  <property name="additional2sign" value="${warfile}" />
+  <property name="tardepends" value="war" />
+
+  <!-- The coverage needs to be improved! -->
+  <target name="coverage-check">
+    <cobertura-check totallinerate="9" totalbranchrate="7" >
+      <!-- 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"/>
     <include name="gson-2.4.jar" />
     <include name="postgresql-9.4.1212.jar"/>
+    <include name="slf4j-api-1.7.22.jar"/>
+  </patternset>
+
+  <patternset id="library" >
+    <patternset refid="common" />
+    <include name="metrics-lib-${metricslibversion}.jar"/>
+    <include name="commons-compress-1.13.jar"/>
     <include name="servlet-api-3.0.jar"/>
     <include name="logback-core-1.1.9.jar" />
     <include name="logback-classic-1.1.9.jar" />
-    <include name="slf4j-api-1.7.22.jar"/>
     <include name="xz-1.6.jar"/>
   </patternset>
-  <path id="classpath">
-    <pathelement path="${classes}"/>
-    <fileset dir="${libs}">
-      <patternset refid="runtime" />
-    </fileset>
-  </path>
-  <path id="test.classpath">
-    <pathelement path="${classes}"/>
-    <pathelement path="${resources}"/>
-    <pathelement path="${testclasses}"/>
-    <pathelement path="${testresources}"/>
-    <fileset dir="${libs}">
-      <patternset refid="runtime" />
-    </fileset>
-    <fileset dir="${libs}">
-      <include name="junit4-4.12.jar"/>
-      <include name="hamcrest-all-1.3.jar"/>
-    </fileset>
-  </path>
-  <path id="checkstyle.classpath" >
-    <fileset dir="${libs}">
-      <include name="checkstyle-6.17-all.jar" />
-    </fileset>
-  </path>
-
-  <target name="clean">
-    <delete includeEmptyDirs="true" quiet="true">
-      <fileset dir="${generated}" defaultexcludes="false" includes="**" />
-    </delete>
-  </target>
-
-  <target name="init">
-    <copy file="${resources}/config" tofile="${basedir}/config"/>
-    <mkdir dir="${classes}"/>
-    <mkdir dir="${testclasses}"/>
-    <mkdir dir="${dist}"/>
-  </target>
-
-  <!-- Compile all servlets and plain Java classes. -->
-  <target name="compile" depends="init">
-    <javac destdir="${classes}"
-           srcdir="${sources}"
-           source="${source-and-target-java-version}"
-           target="${source-and-target-java-version}"
-           debug="true"
-           deprecation="true"
-           optimize="false"
-           failonerror="true"
-           includeantruntime="false">
-      <classpath refid="classpath"/>
-    </javac>
-  </target>
-
-  <target name="testcompile" depends="init">
-    <javac destdir="${testclasses}"
-           srcdir="${testsources}"
-           source="${source-and-target-java-version}"
-           target="${source-and-target-java-version}"
-           debug="true"
-           deprecation="true"
-           optimize="false"
-           failonerror="true"
-           includeantruntime="false">
-      <classpath refid="test.classpath"/>
-    </javac>
-  </target>
-
-  <target name="test" depends="compile,testcompile">
-    <junit fork="true"
-           haltonfailure="true"
-           printsummary="on">
-      <classpath refid="test.classpath"/>
-      <formatter type="plain" usefile="false"/>
-      <batchtest>
-        <fileset dir="${testclasses}"
-                 includes="**/*Test.class"/>
-      </batchtest>
-    </junit>
-  </target>
 
-  <!-- Import descriptors into the ExoneraTor database. -->
-  <target name="run" depends="compile">
-    <java fork="true"
-          maxmemory="2048m"
-          classname="org.torproject.exonerator.ExoneraTorDatabaseImporter">
-      <classpath refid="classpath"/>
-    </java>
-  </target>
+  <patternset id="web" >
+    <patternset refid="common" />
+  </patternset>
 
-  <taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties">
-    <classpath refid="checkstyle.classpath" />
-  </taskdef>
-  <target name="checks" depends="compile">
-    <checkstyle config="${testresources}/metrics_checks.xml">
-      <fileset dir="${sources}"
-               includes="**/*.java" />
-      <fileset dir="${testsources}"
-               includes="**/*.java" />
-      <classpath>
-        <path refid="classpath" />
-        <path refid="checkstyle.classpath" />
-      </classpath>
-      <formatter type="plain"
-                 toFile="${generated}/checkstyle_report.txt"/>
-    </checkstyle>
-    <exec executable="cat" outputproperty="checkstyle.result">
-      <arg value="${generated}/checkstyle_report.txt" />
-    </exec>
-    <fail message="Checkstyle complaints: ${checkstyle.result}" >
-      <condition>
-        <not>
-          <length string="${checkstyle.result}"
-                  length="29" />
-        </not>
-      </condition>
-    </fail>
-  </target>
+  <patternset id="runtime" >
+    <patternset refid="library" />
+  </patternset>
 
   <!-- Create a .war file for deployment. -->
   <target name="war"
           depends="compile">
-    <war destfile="${warfile}"
-         webxml="${webxmlfile}">
-      <fileset dir="${webapp}" includes="css/* images/* WEB-INF/*"/>
+    <war destfile="${dist}/${warfile}"
+         webxml="${resources}/web.xml">
+      <zipfileset dir="${resources}/web"
+                  prefix=""
+                  includes="css/* images/*"/>
+      <zipfileset dir="${resources}/web/jsps"
+                  prefix="WEB-INF"
+                  includes="*.jsp"/>
       <lib dir="${libs}">
-        <include name="commons-codec-1.10.jar"/>
-        <include name="commons-lang3-3.5.jar"/>
-        <include name="gson-2.4.jar" />
-        <include name="postgresql-9.4.1212.jar"/>
-        <include name="slf4j-api-1.7.22.jar"/>
+        <patternset refid="web" />
       </lib>
       <classes dir="${classes}"/>
       <zipfileset dir="${resources}"
                   prefix="WEB-INF/classes"
-                  excludes="config **/db/* db" />
-      <metainf dir="${webapp}"
+                  includes="*.properties" />
+      <metainf dir="${resources}"
                includes="context.xml"/>
     </war>
   </target>
+
+
+  <!-- The following line adds the common targets and properties
+       for Metrics' Java Projects.
+  -->
+  &base;
+
 </project>
 
diff --git a/run-exonerator.sh b/run-exonerator.sh
deleted file mode 100755
index d090ec9..0000000
--- a/run-exonerator.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-ant run | grep "\[java\]"
-
diff --git a/src/build b/src/build
new file mode 160000
index 0000000..23c6e0b
--- /dev/null
+++ b/src/build
@@ -0,0 +1 @@
+Subproject commit 23c6e0be5fab9463f137615053ef412e4da2315e
diff --git a/src/main/resources/bootstrap-development.sh b/src/main/resources/bootstrap-development.sh
new file mode 100755
index 0000000..28fb975
--- /dev/null
+++ b/src/main/resources/bootstrap-development.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+#
+# Copyright 2016--2017 The Tor Project
+# See LICENSE for licensing information
+#
+# Use for submodule initialization and checkout.
+# Only necessary after very first checkout without recursion.
+#
+git submodule update --init --remote
+
diff --git a/src/main/webapp/context.xml b/src/main/resources/context.xml
similarity index 100%
rename from src/main/webapp/context.xml
rename to src/main/resources/context.xml
diff --git a/src/main/webapp/web.xml b/src/main/resources/web.xml
similarity index 95%
rename from src/main/webapp/web.xml
rename to src/main/resources/web.xml
index d838059..881a613 100644
--- a/src/main/webapp/web.xml
+++ b/src/main/resources/web.xml
@@ -3,7 +3,7 @@
 <web-app version="2.4"
   xmlns="http://java.sun.com/xml/ns/j2ee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
+  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
 
   <servlet>
diff --git a/src/main/webapp/css/bootstrap.min.css b/src/main/resources/web/css/bootstrap.min.css
similarity index 100%
rename from src/main/webapp/css/bootstrap.min.css
rename to src/main/resources/web/css/bootstrap.min.css
diff --git a/src/main/webapp/css/exonerator.css b/src/main/resources/web/css/exonerator.css
similarity index 100%
rename from src/main/webapp/css/exonerator.css
rename to src/main/resources/web/css/exonerator.css
diff --git a/src/main/webapp/images/exonerator-logo.png b/src/main/resources/web/images/exonerator-logo.png
similarity index 100%
rename from src/main/webapp/images/exonerator-logo.png
rename to src/main/resources/web/images/exonerator-logo.png
diff --git a/src/main/webapp/images/exonerator-wordmark.png b/src/main/resources/web/images/exonerator-wordmark.png
similarity index 100%
rename from src/main/webapp/images/exonerator-wordmark.png
rename to src/main/resources/web/images/exonerator-wordmark.png
diff --git a/src/main/webapp/images/favicon.ico b/src/main/resources/web/images/favicon.ico
similarity index 100%
rename from src/main/webapp/images/favicon.ico
rename to src/main/resources/web/images/favicon.ico
diff --git a/src/main/webapp/WEB-INF/bottom.jsp b/src/main/resources/web/jsps/bottom.jsp
similarity index 100%
rename from src/main/webapp/WEB-INF/bottom.jsp
rename to src/main/resources/web/jsps/bottom.jsp
diff --git a/src/main/webapp/WEB-INF/index.jsp b/src/main/resources/web/jsps/index.jsp
similarity index 100%
rename from src/main/webapp/WEB-INF/index.jsp
rename to src/main/resources/web/jsps/index.jsp
diff --git a/src/main/webapp/WEB-INF/top.jsp b/src/main/resources/web/jsps/top.jsp
similarity index 100%
rename from src/main/webapp/WEB-INF/top.jsp
rename to src/main/resources/web/jsps/top.jsp



More information about the tor-commits mailing list