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