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