Merge branch 'fix-signer'
[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="mysqlconnector" value="/usr/share/java/mysql-connector-java.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="${mysqlconnector}" />
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="${mysqlconnector}" />
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                         <src path="util-testing" />
103                         <classpath refid="cacert-gigi.classpath" />
104                 </javac>
105         </target>
106
107         <target name="native">
108                 <exec executable="make" dir="natives"/>
109         </target>
110
111         <target depends="build-project, update-effective-tlds" name="pack">
112                 <jar destfile="gigi.jar" basedir="bin" manifest="Gigi.MF" update="false"/>
113                 <jar destfile="gigi.jar" basedir="binutil" update="on"/>
114         </target>
115
116         <target depends="build-testing,update-effective-tlds" name="pack-testing">
117                 <jar destfile="gigi-testing.jar" basedir="bin" manifest="Gigi.MF" update="false"/>
118                 <jar destfile="gigi-testing.jar" basedir="binutil" update="on"/>
119                 <jar destfile="gigi-testing.jar" basedir="binutil-testing" update="on"/>
120         </target>
121
122         <target depends="test,native" name="bundle">
123                 <zip destfile="gigi-linux_amd64.zip" basedir="."
124                         includes="gigi.jar,native/*.so,src/org/cacert/gigi/database/tableStructure.sql,static/**,templates/**" />
125         </target>
126         <target name="static-bundle">
127                 <mkdir dir="work"/>
128                 <mkdir dir="work/static"/>
129                 <copy todir="work/static">
130                         <fileset dir="static"/>
131                 </copy>
132                 <move file="work/static/static/images/cacert4-test.png" tofile="work/static/static/images/cacert4.png"/>
133                 <delete file="work/static/static/image/cacert4-test.png"/>
134                 <tar destfile="static.tar.gz" compression="gzip" basedir="work"
135                         includes="../src/org/cacert/gigi/database/tableStructure.sql,**,templates/**" />
136         </target>
137
138         <target name="static-bundle-release">
139                 <mkdir dir="work"/>
140                 <mkdir dir="work/static"/>
141                 <copy todir="work/static">
142                         <fileset dir="static"/>
143                 </copy>
144                 <delete file="work/static/static/image/cacert4-test.png"/>
145                 <tar destfile="static.tar.gz" compression="gzip" basedir="work"
146                         includes="../src/org/cacert/gigi/database/tableStructure.sql,**,templates/**" />
147         </target>
148
149         <target name="develop" depends="bundle,static-bundle" />
150
151         <target name="release" depends="bundle,static-bundle-release" />
152
153         <target depends="init,build-testing,update-effective-tlds" name="build-project-test">
154                 <echo message="${ant.project.name}: ${ant.file}" />
155                 <javac encoding="UTF-8" debug="true" debuglevel="${debuglevel}" destdir="bintest"
156                         includeantruntime="false" source="${source}" target="${target}">
157                         <compilerarg value="-XDignore.symbol.file"/>
158                         <src path="tests" />
159                         <classpath refid="cacert-gigi.test.classpath" />
160                 </javac>
161                 <concat destfile="bintest/org/cacert/gigi/util/effective_tld_names.dat">
162                         <path path="bin/org/cacert/gigi/util/effective_tld_names.dat"/>
163                         <footer>${test_nic}</footer>
164                 </concat>
165         </target>
166         <target name="check-locale">
167                 <available file="locale/de.xml" property="locale.present" />
168         </target>
169         <target name="FetchLocales" depends="check-locale" unless="locale.present">
170                 <java classname="org.cacert.gigi.util.FetchLocales" failonerror="true"
171                         fork="yes">
172                         <classpath refid="cacert-gigi.classpath" />
173                 </java>
174         </target>
175         <target name="check-generateKeys">
176                 <available file="config/keystore.pkcs12" property="keystore.present" />
177         </target>
178         <target name="generateKeys" depends="check-generateKeys" unless="keystore.present">
179                 <exec executable="./generateKeys.sh" dir="keys" />
180                 <exec executable="./generateTruststore.sh" dir="keys">
181                         <arg value="-noprompt" />
182                 </exec>
183         </target>
184         <target name="reset-db" depends="build-project">
185                 <copy file="config/test.properties" tofile="config/gigi.properties"/>
186                 <java classname="org.cacert.gigi.util.DatabaseManager">
187                         <arg value="--test"/>
188                         <classpath refid="cacert-gigi.test.classpath" />
189                 </java>
190         </target>
191         <target name="test" depends="build-project-test,FetchLocales,pack-testing,pack,reset-db">
192                 <delete failonerror="false">
193                         <fileset dir=".">
194                                 <include name="jacoco.exec"/>
195                                 <include name="tester.exec"/>
196                         </fileset>
197                 </delete>
198                 <mkdir dir="${junit.output.dir}" />
199                 <junit maxmemory="2g" fork="yes" printsummary="withOutAndErr">
200                         <jvmarg value="-javaagent:/usr/share/java/jacocoagent.jar=destfile=tester.exec"/>
201                         <formatter type="xml" />
202                         <batchtest fork="yes" todir="${junit.output.dir}">
203                                 <fileset dir="tests">
204                                         <include name="**/*.java" />
205                                         <exclude name="**/testUtils/**" />
206                                         <exclude name="**/com/lambdaworks/crypto/test/CryptoTestUtil.java"/>
207                                 </fileset>
208                         </batchtest>
209                         <classpath refid="cacert-gigi.test.classpath" />
210                 </junit>
211         </target>
212         <target name="junitreport">
213                 <junitreport todir="${junit.output.dir}">
214                         <fileset dir="${junit.output.dir}">
215                                 <include name="TEST-*.xml" />
216                         </fileset>
217                         <report format="frames" todir="${junit.output.dir}" />
218                 </junitreport>
219         </target>
220         <target name="generatecoco">
221                 <jacoco:merge destfile="merged.exec">
222                         <fileset dir="." includes="*.exec"/>
223                 </jacoco:merge>
224                 <jacoco:report>
225                         <executiondata>
226                                 <file file="merged.exec" />
227                         </executiondata>
228
229                         <structure name="CAcert gigi">
230                                 <group name="Server">
231                                         <classfiles>
232                                                 <fileset dir="bin">
233                                                         <include name="org/cacert/gigi/**"/>
234                                                 </fileset>
235                                         </classfiles>
236                                         <sourcefiles encoding="UTF-8">
237                                                 <fileset dir="src">
238                                                         <include name="org/cacert/gigi/**"/>
239                                                 </fileset>
240                                         </sourcefiles>
241                                 </group>
242                                 <group name="Testcases">
243                                         <classfiles>
244                                                 <fileset dir="bintest">
245                                                         <include name="org/cacert/gigi/**"/>
246                                                 </fileset>
247                                         </classfiles>
248                                         <sourcefiles encoding="UTF-8">
249                                                 <fileset dir="tests">
250                                                         <include name="org/cacert/gigi/**"/>
251                                                 </fileset>
252                                         </sourcefiles>
253                                 </group>
254                         </structure>
255
256                         <html destdir="cocoReport"/>
257
258                 </jacoco:report>
259         </target>
260         <target name="install-native" depends="native">
261                 <mkdir dir="${env.DESTDIR}/usr/lib/jni"/>
262                 <copy file="natives/libsetuid.so" todir="${env.DESTDIR}/usr/lib/jni"/>
263         </target>
264         <target name="install" depends="install-common">
265                 <mkdir dir="${env.DESTDIR}/usr/share/cacert-gigi/static" />
266                 <copy todir="${env.DESTDIR}/usr/share/cacert-gigi/static">
267                         <fileset dir="static" />
268                 </copy>
269                 <delete file="${env.DESTDIR}/usr/share/cacert-gigi/static/static/images/cacert4-test.png" />
270                 <copy file="gigi.jar" tofile="${env.DESTDIR}/usr/share/java/gigi.jar"/>
271         </target>
272         <target name="install-testing" depends="install-common">
273                 <mkdir dir="${env.DESTDIR}/usr/share/cacert-gigi/static" />
274                 <copy todir="${env.DESTDIR}/usr/share/cacert-gigi/static">
275                         <fileset dir="static" />
276                 </copy>
277                 <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" />
278                 <delete file="${env.DESTDIR}/usr/share/cacert-gigi/static/static/images/cacert4-test.png" />
279                 <copy file="gigi-testing.jar" tofile="${env.DESTDIR}/usr/share/java/gigi.jar"/>
280         </target>
281
282         <target name="install-common" depends="pack">
283                 <mkdir dir="${env.DESTDIR}/usr/share/java" />
284
285                 <mkdir dir="${env.DESTDIR}/usr/bin"/>
286                 <copy file="doc/scripts/gigi" tofile="${env.DESTDIR}/usr/bin/gigi"/>
287
288                 <chmod file="${env.DESTDIR}/usr/bin/gigi" perm="+x"/>
289                 <mkdir dir="${env.DESTDIR}/usr/share/dbconfig-common/data/${PACKAGE}/install/"/>
290                 <copy file="src/org/cacert/gigi/database/tableStructure.sql" tofile="${env.DESTDIR}/usr/share/dbconfig-common/data/${PACKAGE}/install/mysql.sql"/>
291
292                 <mkdir dir="${env.DESTDIR}/var/lib/cacert-gigi/doc"/>
293                 <exec executable="ln">
294                         <arg value="-s"/>
295                         <arg value="/usr/share/dbconfig-common/data/${PACKAGE}/install/mysql.sql"/>
296                         <arg value="${env.DESTDIR}/var/lib/cacert-gigi/doc/tableStructure.sql"/>
297                 </exec>
298                 <mkdir dir="${env.DESTDIR}/var/lib/cacert-gigi/natives"/>
299                 <delete failonerror="false" file="${env.DESTDIR}/var/lib/cacert-gigi/static"/>
300                 <exec executable="ln">
301                         <arg value="-s"/>
302                         <arg value="/usr/share/cacert-gigi/static"/>
303                         <arg value="${env.DESTDIR}/var/lib/cacert-gigi/static"/>
304                 </exec>
305                 <exec executable="ln">
306                         <arg value="-s"/>
307                         <arg value="/usr/lib/jni/libsetuid.so"/>
308                         <arg value="${env.DESTDIR}/var/lib/cacert-gigi/natives/libsetuid.so"/>
309                 </exec>
310
311                 <mkdir dir="${env.DESTDIR}/etc/cacert/gigi"/>
312                 <!--<copy todir="${env.DESTDIR}/DEBIAN">
313                         <fileset dir="debian">
314                         </fileset>
315                 </copy>-->
316         </target>
317         <target name="update-effective-tlds">
318                 <mkdir dir="bin/org/cacert/gigi/util"/>
319                 <exec executable="wget" dir="bin/org/cacert/gigi/util">
320                         <arg value="-N"/>
321                         <arg value="-q"/>
322                         <arg value="https://publicsuffix.org/list/effective_tld_names.dat"/>
323                 </exec>
324         </target>
325 </project>