UPD: splittof util-testing
[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="bin" />
27                 <pathelement location="binutil" />
28                 <pathelement location="binutil-testing" />
29                 <pathelement location="bintest" />
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                 </copy>
45                 <copy includeemptydirs="false" todir="bin">
46                         <fileset dir="lib/jetty">
47                                 <exclude name="**/*.launch" />
48                                 <exclude name="**/*.java" />
49                         </fileset>
50                 </copy>
51                 <copy includeemptydirs="false" todir="bin">
52                         <fileset dir="src">
53                                 <exclude name="**/*.launch" />
54                                 <exclude name="**/*.java" />
55                         </fileset>
56                 </copy>
57                 <copy includeemptydirs="false" todir="bin">
58                         <fileset dir="util">
59                                 <exclude name="**/*.launch" />
60                                 <exclude name="**/*.java" />
61                         </fileset>
62                 </copy>
63                 <copy includeemptydirs="false" todir="binutil-testing">
64                         <fileset dir="util-testing">
65                                 <exclude name="**/*.launch" />
66                                 <exclude name="**/*.java" />
67                         </fileset>
68                 </copy>
69                 <copy includeemptydirs="false" todir="bintest">
70                         <fileset dir="tests">
71                                 <exclude name="**/*.launch" />
72                                 <exclude name="**/*.java" />
73                         </fileset>
74                 </copy>
75         </target>
76         <target name="clean">
77                 <delete dir="bin" />
78         </target>
79         <target name="clean-test">
80                 <delete dir="bintest" />
81                 <delete dir="cocoReport" failonerror="false"/>
82
83         </target>
84         <target depends="clean,clean-test" name="cleanall" />
85         <target depends="build-project, build-testing, native" name="build" />
86         <target depends="init" name="build-project">
87                 <echo message="${ant.project.name}: ${ant.file}" />
88                 <javac debug="true" debuglevel="${debuglevel}" destdir="bin"
89                         includeantruntime="false" source="${source}" target="${target}">
90                         <compilerarg value="-XDignore.symbol.file"/>
91                         <src path="lib/servlet-api" />
92                         <src path="lib/jetty" />
93                         <src path="lib/jtar" />
94                         <src path="src" />
95                         <classpath refid="cacert-gigi.classpath" />
96                 </javac>
97                 <javac debug="true" debuglevel="${debuglevel}" destdir="binutil"
98                         includeantruntime="false" source="${source}" target="${target}">
99                         <compilerarg value="-XDignore.symbol.file"/>
100                         <src path="util" />
101                         <classpath refid="cacert-gigi.classpath" />
102                 </javac>
103         </target>
104         <target depends="init, build-project" name="build-testing">
105                 <javac debug="true" debuglevel="${debuglevel}" destdir="binutil-testing"
106                         includeantruntime="false" source="${source}" target="${target}">
107                         <src path="util-testing" />
108                         <classpath refid="cacert-gigi.classpath" />
109                 </javac>
110         </target>
111
112         <target name="native">
113                 <exec executable="make" dir="natives"/>
114         </target>
115
116         <target depends="build-project" name="pack">
117                 <jar destfile="gigi.jar" basedir="bin" manifest="Gigi.MF" update="false"/>
118                 <jar destfile="gigi.jar" basedir="binutil" update="on"/>
119         </target>
120
121         <target depends="build-testing" name="pack-testing">
122                 <jar destfile="gigi-testing.jar" basedir="bin" manifest="Gigi.MF" update="false"/>
123                 <jar destfile="gigi-testing.jar" basedir="binutil" update="on"/>
124                 <jar destfile="gigi-testing.jar" basedir="binutil-testing" update="on"/>
125         </target>
126
127         <target depends="test,native" name="bundle">
128                 <zip destfile="gigi-linux_amd64.zip" basedir="."
129                         includes="gigi.jar,native/*.so,doc/tableStructure.sql,static/**,templates/**" />
130         </target>
131         <target name="static-bundle">
132                 <mkdir dir="work"/>
133                 <mkdir dir="work/static"/>
134                 <copy todir="work/static">
135                         <fileset dir="static"/>
136                 </copy>
137                 <move file="work/static/static/images/cacert4-test.png" tofile="work/static/static/images/cacert4.png"/>
138                 <delete file="work/static/static/image/cacert4-test.png"/>
139                 <tar destfile="static.tar.gz" compression="gzip" basedir="work"
140                         includes="../doc/tableStructure.sql,**,templates/**" />
141         </target>
142
143         <target name="static-bundle-release">
144                 <mkdir dir="work"/>
145                 <mkdir dir="work/static"/>
146                 <copy todir="work/static">
147                         <fileset dir="static"/>
148                 </copy>
149                 <delete file="work/static/static/image/cacert4-test.png"/>
150                 <tar destfile="static.tar.gz" compression="gzip" basedir="work"
151                         includes="../doc/tableStructure.sql,**,templates/**" />
152         </target>
153
154         <target name="develop" depends="bundle,static-bundle" />
155
156         <target name="release" depends="bundle,static-bundle-release" />
157
158         <target depends="init,build-testing" name="build-project-test">
159                 <echo message="${ant.project.name}: ${ant.file}" />
160                 <javac debug="true" debuglevel="${debuglevel}" destdir="bintest"
161                         includeantruntime="false" source="${source}" target="${target}">
162                         <compilerarg value="-XDignore.symbol.file"/>
163                         <src path="tests" />
164                         <classpath refid="cacert-gigi.test.classpath" />
165                 </javac>
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,generateKeys,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 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                                 </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="doc/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 </project>