fix: remove old coverage data. only use current.
[gigi.git] / build.xml
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <project basedir="." default="develop" name="cacert-gigi" xmlns:jacoco="antlib:org.jacoco.ant">
3
4         <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
5                 <classpath path="/usr/share/java/jacocoant.jar" />
6         </taskdef>
7
8         <property environment="env" />
9         <property name="PACKAGE" value="cacert-gigi" />
10         <property name="junit.output.dir" value="junit" />
11         <property name="debuglevel" value="source,lines,vars" />
12         <property name="target" value="1.8" />
13         <property name="source" value="1.8" />
14         <property name="sqlconnector" value="/usr/share/java/postgresql-jdbc4.jar" />
15         <property name="juintexec" value="/usr/share/java" />
16         <path id="JUnit 4.libraryclasspath">
17                 <pathelement location="${juintexec}/junit4.jar" />
18                 <pathelement location="${juintexec}/hamcrest-core.jar" />
19         </path>
20         <path id="cacert-gigi.classpath">
21                 <pathelement location="bin" />
22                 <pathelement location="binutil" />
23                 <pathelement location="${sqlconnector}" />
24         </path>
25         <path id="cacert-gigi.test.classpath">
26                 <pathelement location="bintest" />
27                 <pathelement location="bin" />
28                 <pathelement location="binutil" />
29                 <pathelement location="binutil-testing" />
30                 <path refid="JUnit 4.libraryclasspath" />
31                 <pathelement location="${sqlconnector}" />
32         </path>
33         <target name="init">
34                 <mkdir dir="bin" />
35                 <mkdir dir="binutil" />
36                 <mkdir dir="binutil-testing" />
37                 <mkdir dir="bintest" />
38
39                 <copy includeemptydirs="false" todir="bin">
40                         <fileset dir="lib/servlet-api">
41                                 <exclude name="**/*.launch" />
42                                 <exclude name="**/*.java" />
43                         </fileset>
44                         <fileset dir="lib/jetty">
45                                 <exclude name="**/*.launch" />
46                                 <exclude name="**/*.java" />
47                         </fileset>
48                         <fileset dir="src">
49                                 <exclude name="**/*.launch" />
50                                 <exclude name="**/*.java" />
51                         </fileset>
52                         <fileset dir="util">
53                                 <exclude name="**/*.launch" />
54                                 <exclude name="**/*.java" />
55                         </fileset>
56                 </copy>
57                 <copy includeemptydirs="false" todir="binutil-testing">
58                         <fileset dir="util-testing">
59                                 <exclude name="**/*.launch" />
60                                 <exclude name="**/*.java" />
61                         </fileset>
62                 </copy>
63                 <copy includeemptydirs="false" todir="bintest">
64                         <fileset dir="tests">
65                                 <exclude name="**/*.launch" />
66                                 <exclude name="**/*.java" />
67                         </fileset>
68                 </copy>
69         </target>
70         <target name="clean">
71                 <delete dir="bin" />
72         </target>
73         <target name="clean-test">
74                 <delete dir="bintest" />
75                 <delete dir="cocoReport" failonerror="false"/>
76
77         </target>
78         <target depends="clean,clean-test" name="cleanall" />
79         <target depends="build-project, build-testing, native" name="build" />
80         <target depends="init" name="build-project">
81                 <echo message="${ant.project.name}: ${ant.file}" />
82                 <javac encoding="UTF-8" debug="true" debuglevel="${debuglevel}" destdir="bin"
83                         includeantruntime="false" source="${source}" target="${target}">
84                         <compilerarg value="-XDignore.symbol.file"/>
85                         <src path="lib/servlet-api" />
86                         <src path="lib/jetty" />
87                         <src path="lib/jtar" />
88                         <src path="lib/scrypt" />
89                         <src path="src" />
90                         <classpath refid="cacert-gigi.classpath" />
91                 </javac>
92                 <javac encoding="UTF-8" debug="true" debuglevel="${debuglevel}" destdir="binutil"
93                         includeantruntime="false" source="${source}" target="${target}">
94                         <compilerarg value="-XDignore.symbol.file"/>
95                         <src path="util" />
96                         <classpath refid="cacert-gigi.classpath" />
97                 </javac>
98         </target>
99         <target depends="init, build-project" name="build-testing">
100                 <javac encoding="UTF-8" debug="true" debuglevel="${debuglevel}" destdir="binutil-testing"
101                         includeantruntime="false" source="${source}" target="${target}">
102                         <compilerarg value="-XDignore.symbol.file"/>
103                         <src path="util-testing" />
104                         <classpath refid="cacert-gigi.classpath" />
105                 </javac>
106         </target>
107
108         <target name="native">
109                 <exec executable="make" dir="natives"/>
110         </target>
111
112         <target depends="build-project, update-effective-tlds" name="pack">
113                 <jar destfile="gigi.jar" basedir="bin" manifest="Gigi.MF" update="false"/>
114                 <jar destfile="gigi.jar" basedir="binutil" update="on"/>
115         </target>
116
117         <target depends="build-testing,update-effective-tlds" name="pack-testing">
118                 <jar destfile="gigi-testing.jar" basedir="bin" manifest="Gigi.MF" update="false"/>
119                 <jar destfile="gigi-testing.jar" basedir="binutil" update="on"/>
120                 <jar destfile="gigi-testing.jar" basedir="binutil-testing" update="on"/>
121         </target>
122
123         <target depends="test,native" name="bundle">
124                 <zip destfile="gigi-linux_amd64.zip" basedir="."
125                         includes="gigi.jar,native/*.so,src/org/cacert/gigi/database/tableStructure.sql,static/**,templates/**" />
126         </target>
127         <target name="static-bundle">
128                 <mkdir dir="work"/>
129                 <mkdir dir="work/static"/>
130                 <copy todir="work/static">
131                         <fileset dir="static"/>
132                 </copy>
133                 <move file="work/static/static/images/cacert4-test.png" tofile="work/static/static/images/cacert4.png"/>
134                 <delete file="work/static/static/image/cacert4-test.png"/>
135                 <tar destfile="static.tar.gz" compression="gzip" basedir="work"
136                         includes="../src/org/cacert/gigi/database/tableStructure.sql,**,templates/**" />
137         </target>
138
139         <target name="static-bundle-release">
140                 <mkdir dir="work"/>
141                 <mkdir dir="work/static"/>
142                 <copy todir="work/static">
143                         <fileset dir="static"/>
144                 </copy>
145                 <delete file="work/static/static/image/cacert4-test.png"/>
146                 <tar destfile="static.tar.gz" compression="gzip" basedir="work"
147                         includes="../src/org/cacert/gigi/database/tableStructure.sql,**,templates/**" />
148         </target>
149
150         <target name="develop" depends="bundle,static-bundle" />
151
152         <target name="release" depends="bundle,static-bundle-release" />
153
154         <target depends="init,build-testing,update-effective-tlds" name="build-project-test">
155                 <echo message="${ant.project.name}: ${ant.file}" />
156                 <javac encoding="UTF-8" debug="true" debuglevel="${debuglevel}" destdir="bintest"
157                         includeantruntime="false" source="${source}" target="${target}">
158                         <compilerarg value="-XDignore.symbol.file"/>
159                         <src path="tests" />
160                         <classpath refid="cacert-gigi.test.classpath" />
161                 </javac>
162                 <concat destfile="bintest/org/cacert/gigi/util/effective_tld_names.dat">
163                         <path path="bin/org/cacert/gigi/util/effective_tld_names.dat"/>
164                         <footer>${test_nic}</footer>
165                 </concat>
166         </target>
167         <target name="check-locale">
168                 <available file="locale/de.xml" property="locale.present" />
169         </target>
170         <target name="FetchLocales" depends="check-locale" unless="locale.present">
171                 <java classname="org.cacert.gigi.util.FetchLocales" failonerror="true"
172                         fork="yes">
173                         <classpath refid="cacert-gigi.classpath" />
174                 </java>
175         </target>
176         <target name="check-generateKeys">
177                 <available file="config/keystore.pkcs12" property="keystore.present" />
178         </target>
179         <target name="generateKeys" depends="check-generateKeys" unless="keystore.present">
180                 <exec executable="./generateKeys.sh" dir="keys" />
181                 <exec executable="./generateTruststore.sh" dir="keys">
182                         <arg value="-noprompt" />
183                 </exec>
184         </target>
185         <target name="reset-db" depends="build-project">
186                 <copy file="config/test.properties" tofile="config/gigi.properties"/>
187                 <java classname="org.cacert.gigi.util.DatabaseManager">
188                         <arg value="--test"/>
189                         <classpath refid="cacert-gigi.test.classpath" />
190                 </java>
191         </target>
192         <target name="test" depends="build-project-test,FetchLocales,pack-testing,pack,reset-db">
193                 <delete failonerror="false">
194                         <fileset dir=".">
195                                 <include name="jacoco.exec"/>
196                                 <include name="tester.exec"/>
197                         </fileset>
198                 </delete>
199                 <mkdir dir="${junit.output.dir}" />
200                 <junit maxmemory="2g" fork="yes" printsummary="withOutAndErr">
201                         <jvmarg value="-javaagent:/usr/share/java/jacocoagent.jar=destfile=tester.exec"/>
202                         <formatter type="xml" />
203                         <batchtest fork="yes" todir="${junit.output.dir}">
204                                 <fileset dir="tests">
205                                         <include name="**/*.java" />
206                                         <exclude name="**/testUtils/**" />
207                                         <exclude name="**/com/lambdaworks/crypto/test/CryptoTestUtil.java"/>
208                                 </fileset>
209                         </batchtest>
210                         <classpath refid="cacert-gigi.test.classpath" />
211                 </junit>
212         </target>
213         <target name="junitreport">
214                 <junitreport todir="${junit.output.dir}">
215                         <fileset dir="${junit.output.dir}">
216                                 <include name="TEST-*.xml" />
217                         </fileset>
218                         <report format="frames" todir="${junit.output.dir}" />
219                 </junitreport>
220         </target>
221         <target name="generatecoco">
222                 <delete file="merged.exec"/>
223
224                 <jacoco:merge destfile="merged.exec">
225                         <fileset dir="." includes="*.exec"/>
226                 </jacoco:merge>
227                 <jacoco:report>
228                         <executiondata>
229                                 <file file="merged.exec" />
230                         </executiondata>
231
232                         <structure name="CAcert gigi">
233                                 <group name="Server">
234                                         <classfiles>
235                                                 <fileset dir="bin">
236                                                         <include name="org/cacert/gigi/**"/>
237                                                 </fileset>
238                                         </classfiles>
239                                         <sourcefiles encoding="UTF-8">
240                                                 <fileset dir="src">
241                                                         <include name="org/cacert/gigi/**"/>
242                                                 </fileset>
243                                         </sourcefiles>
244                                 </group>
245                                 <group name="Testcases">
246                                         <classfiles>
247                                                 <fileset dir="bintest">
248                                                         <include name="org/cacert/gigi/**"/>
249                                                 </fileset>
250                                         </classfiles>
251                                         <sourcefiles encoding="UTF-8">
252                                                 <fileset dir="tests">
253                                                         <include name="org/cacert/gigi/**"/>
254                                                 </fileset>
255                                         </sourcefiles>
256                                 </group>
257                         </structure>
258
259                         <html destdir="cocoReport"/>
260
261                 </jacoco:report>
262         </target>
263         <target name="install-native" depends="native">
264                 <mkdir dir="${env.DESTDIR}/usr/lib/jni"/>
265                 <copy file="natives/libsetuid.so" todir="${env.DESTDIR}/usr/lib/jni"/>
266         </target>
267         <target name="install" depends="install-common">
268                 <mkdir dir="${env.DESTDIR}/usr/share/cacert-gigi/static" />
269                 <copy todir="${env.DESTDIR}/usr/share/cacert-gigi/static">
270                         <fileset dir="static" />
271                 </copy>
272                 <delete file="${env.DESTDIR}/usr/share/cacert-gigi/static/static/images/cacert4-test.png" />
273                 <copy file="gigi.jar" tofile="${env.DESTDIR}/usr/share/java/gigi.jar"/>
274         </target>
275         <target name="install-testing" depends="install-common">
276                 <mkdir dir="${env.DESTDIR}/usr/share/cacert-gigi/static" />
277                 <copy todir="${env.DESTDIR}/usr/share/cacert-gigi/static">
278                         <fileset dir="static" />
279                 </copy>
280                 <move file="${env.DESTDIR}/usr/share/cacert-gigi/static/static/images/cacert4-test.png" tofile="${env.DESTDIR}/usr/share/cacert-gigi/static/static/images/cacert4.png" />
281                 <delete file="${env.DESTDIR}/usr/share/cacert-gigi/static/static/images/cacert4-test.png" />
282                 <copy file="gigi-testing.jar" tofile="${env.DESTDIR}/usr/share/java/gigi.jar"/>
283         </target>
284
285         <target name="install-common" depends="pack">
286                 <mkdir dir="${env.DESTDIR}/usr/share/java" />
287
288                 <mkdir dir="${env.DESTDIR}/usr/bin"/>
289                 <copy file="doc/scripts/gigi" tofile="${env.DESTDIR}/usr/bin/gigi"/>
290
291                 <chmod file="${env.DESTDIR}/usr/bin/gigi" perm="+x"/>
292                 <mkdir dir="${env.DESTDIR}/usr/share/dbconfig-common/data/${PACKAGE}/install/"/>
293                 <copy file="src/org/cacert/gigi/database/tableStructure.sql" tofile="${env.DESTDIR}/usr/share/dbconfig-common/data/${PACKAGE}/install/mysql.sql"/>
294
295                 <mkdir dir="${env.DESTDIR}/var/lib/cacert-gigi/doc"/>
296                 <exec executable="ln">
297                         <arg value="-s"/>
298                         <arg value="/usr/share/dbconfig-common/data/${PACKAGE}/install/mysql.sql"/>
299                         <arg value="${env.DESTDIR}/var/lib/cacert-gigi/doc/tableStructure.sql"/>
300                 </exec>
301                 <mkdir dir="${env.DESTDIR}/var/lib/cacert-gigi/natives"/>
302                 <delete failonerror="false" file="${env.DESTDIR}/var/lib/cacert-gigi/static"/>
303                 <exec executable="ln">
304                         <arg value="-s"/>
305                         <arg value="/usr/share/cacert-gigi/static"/>
306                         <arg value="${env.DESTDIR}/var/lib/cacert-gigi/static"/>
307                 </exec>
308                 <exec executable="ln">
309                         <arg value="-s"/>
310                         <arg value="/usr/lib/jni/libsetuid.so"/>
311                         <arg value="${env.DESTDIR}/var/lib/cacert-gigi/natives/libsetuid.so"/>
312                 </exec>
313
314                 <mkdir dir="${env.DESTDIR}/etc/cacert/gigi"/>
315                 <!--<copy todir="${env.DESTDIR}/DEBIAN">
316                         <fileset dir="debian">
317                         </fileset>
318                 </copy>-->
319         </target>
320         <target name="update-effective-tlds">
321                 <mkdir dir="bin/org/cacert/gigi/util"/>
322                 <exec executable="wget" dir="bin/org/cacert/gigi/util">
323                         <arg value="-N"/>
324                         <arg value="-q"/>
325                         <arg value="https://publicsuffix.org/list/effective_tld_names.dat"/>
326                 </exec>
327         </target>
328 </project>