]> WPIA git - gigi.git/blob - build.xml
FIX: correct paths help the jacoco report generator.
[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="junit.output.dir" value="junit" />
10         <property name="debuglevel" value="source,lines,vars" />
11         <property name="target" value="1.8" />
12         <property name="source" value="1.8" />
13         <property name="mysqlconnector" value="/usr/share/java/mysql-connector-java.jar" />
14         <property name="juintexec" value="/usr/share/java" />
15         <path id="JUnit 4.libraryclasspath">
16                 <pathelement location="${juintexec}/junit4.jar" />
17                 <pathelement location="${juintexec}/hamcrest-core.jar" />
18         </path>
19         <path id="cacert-gigi.classpath">
20                 <pathelement location="bin" />
21                 <pathelement location="binutil" />
22                 <pathelement location="${mysqlconnector}" />
23         </path>
24         <path id="cacert-gigi.test.classpath">
25                 <pathelement location="bin" />
26                 <pathelement location="binutil" />
27                 <pathelement location="bintest" />
28                 <path refid="JUnit 4.libraryclasspath" />
29                 <pathelement location="${mysqlconnector}" />
30         </path>
31         <target name="init">
32                 <mkdir dir="bin" />
33                 <mkdir dir="binutil" />
34                 <mkdir dir="bintest" />
35
36                 <copy includeemptydirs="false" todir="bin">
37                         <fileset dir="lib/servlet-api">
38                                 <exclude name="**/*.launch" />
39                                 <exclude name="**/*.java" />
40                         </fileset>
41                 </copy>
42                 <copy includeemptydirs="false" todir="bin">
43                         <fileset dir="lib/jetty">
44                                 <exclude name="**/*.launch" />
45                                 <exclude name="**/*.java" />
46                         </fileset>
47                 </copy>
48                 <copy includeemptydirs="false" todir="bin">
49                         <fileset dir="src">
50                                 <exclude name="**/*.launch" />
51                                 <exclude name="**/*.java" />
52                         </fileset>
53                 </copy>
54                 <copy includeemptydirs="false" todir="bin">
55                         <fileset dir="util">
56                                 <exclude name="**/*.launch" />
57                                 <exclude name="**/*.java" />
58                         </fileset>
59                 </copy>
60                 <copy includeemptydirs="false" todir="bintest">
61                         <fileset dir="tests">
62                                 <exclude name="**/*.launch" />
63                                 <exclude name="**/*.java" />
64                         </fileset>
65                 </copy>
66         </target>
67         <target name="clean">
68                 <delete dir="bin" />
69         </target>
70         <target name="clean-test">
71                 <delete dir="bintest" />
72                 <delete dir="cocoReport" failonerror="false"/>
73
74         </target>
75         <target depends="clean,clean-test" name="cleanall" />
76         <target depends="build-project, native" name="build" />
77         <target depends="init" name="build-project">
78                 <echo message="${ant.project.name}: ${ant.file}" />
79                 <javac debug="true" debuglevel="${debuglevel}" destdir="bin"
80                         includeantruntime="false" source="${source}" target="${target}">
81                         <compilerarg value="-XDignore.symbol.file"/>
82                         <src path="lib/servlet-api" />
83                         <src path="lib/jetty" />
84                         <src path="lib/jtar" />
85                         <src path="src" />
86                         <classpath refid="cacert-gigi.classpath" />
87                 </javac>
88                 <javac debug="true" debuglevel="${debuglevel}" destdir="binutil"
89                         includeantruntime="false" source="${source}" target="${target}">
90                         <compilerarg value="-XDignore.symbol.file"/>
91                         <src path="util" />
92                         <classpath refid="cacert-gigi.classpath" />
93                 </javac>
94         </target>
95
96         <target name="native">
97                 <exec executable="make" dir="natives"/>
98         </target>
99
100         <target depends="build" name="pack">
101                 <jar destfile="gigi.jar" basedir="bin" manifest="Gigi.MF" update="false"/>
102                 <jar destfile="gigi.jar" basedir="binutil" update="on"/>
103         </target>
104
105         <target depends="test,native" name="bundle">
106                 <zip destfile="gigi-linux_amd64.zip" basedir="."
107                         includes="gigi.jar,native/*.so,doc/tableStructure.sql,static/**,templates/**" />
108         </target>
109         <target name="static-bundle">
110                 <mkdir dir="work"/>
111                 <mkdir dir="work/static"/>
112                 <copy todir="work/static">
113                         <fileset dir="static"/>
114                 </copy>
115                 <move file="work/static/static/images/cacert4-test.png" tofile="work/static/static/images/cacert4.png"/>
116                 <delete file="work/static/static/image/cacert4-test.png"/>
117                 <tar destfile="static.tar.gz" compression="gzip" basedir="work"
118                         includes="../doc/tableStructure.sql,**,templates/**" />
119         </target>
120
121         <target name="static-bundle-release">
122                 <mkdir dir="work"/>
123                 <mkdir dir="work/static"/>
124                 <copy todir="work/static">
125                         <fileset dir="static"/>
126                 </copy>
127                 <delete file="work/static/static/image/cacert4-test.png"/>
128                 <tar destfile="static.tar.gz" compression="gzip" basedir="work"
129                         includes="../doc/tableStructure.sql,**,templates/**" />
130         </target>
131
132         <target name="develop" depends="bundle,static-bundle" />
133
134         <target name="release" depends="bundle,static-bundle-release" />
135
136         <target depends="init,build-project" name="build-project-test">
137                 <echo message="${ant.project.name}: ${ant.file}" />
138                 <javac debug="true" debuglevel="${debuglevel}" destdir="bintest"
139                         includeantruntime="false" source="${source}" target="${target}">
140                         <compilerarg value="-XDignore.symbol.file"/>
141                         <src path="tests" />
142                         <classpath refid="cacert-gigi.test.classpath" />
143                 </javac>
144         </target>
145         <target name="check-locale">
146                 <available file="locale/de.xml" property="locale.present" />
147         </target>
148         <target name="FetchLocales" depends="check-locale" unless="locale.present">
149                 <java classname="org.cacert.gigi.util.FetchLocales" failonerror="true"
150                         fork="yes">
151                         <classpath refid="cacert-gigi.classpath" />
152                 </java>
153         </target>
154         <target name="check-generateKeys">
155                 <available file="config/keystore.pkcs12" property="keystore.present" />
156         </target>
157         <target name="generateKeys" depends="check-generateKeys" unless="keystore.present">
158                 <exec executable="./generateKeys.sh" dir="keys" />
159                 <exec executable="./generateTruststore.sh" dir="keys">
160                         <arg value="-noprompt" />
161                 </exec>
162         </target>
163         <target name="reset-db">
164                 <copy file="config/test.properties" tofile="config/gigi.properties"/>
165                 <java classname="org.cacert.gigi.util.DatabaseManager">
166                         <arg value="--test"/>
167                         <classpath refid="cacert-gigi.classpath" />
168                 </java>
169         </target>
170         <target name="test" depends="build-project-test,generateKeys,FetchLocales,pack,reset-db">
171                 <delete failonerror="false">
172                         <fileset dir=".">
173                                 <include name="jacoco.exec"/>
174                                 <include name="tester.exec"/>
175                         </fileset>
176                 </delete>
177                 <mkdir dir="${junit.output.dir}" />
178                 <junit fork="yes" printsummary="withOutAndErr">
179                         <jvmarg value="-javaagent:/usr/share/java/jacocoagent.jar=destfile=tester.exec"/>
180                         <formatter type="xml" />
181                         <batchtest fork="yes" todir="${junit.output.dir}">
182                                 <fileset dir="tests">
183                                         <include name="**/*.java" />
184                                         <exclude name="**/testUtils/**" />
185                                 </fileset>
186                         </batchtest>
187                         <classpath refid="cacert-gigi.test.classpath" />
188                 </junit>
189         </target>
190         <target name="junitreport">
191                 <junitreport todir="${junit.output.dir}">
192                         <fileset dir="${junit.output.dir}">
193                                 <include name="TEST-*.xml" />
194                         </fileset>
195                         <report format="frames" todir="${junit.output.dir}" />
196                 </junitreport>
197         </target>
198         <target name="generatecoco">
199                 <jacoco:merge destfile="merged.exec">
200                         <fileset dir="." includes="*.exec"/>
201                 </jacoco:merge>
202                 <jacoco:report>
203                         <executiondata>
204                                 <file file="merged.exec" />
205                         </executiondata>
206
207                         <structure name="CAcert gigi">
208                                 <group name="Server">
209                                         <classfiles>
210                                                 <fileset dir="bin">
211                                                         <include name="org/cacert/gigi/**"/>
212                                                 </fileset>
213                                         </classfiles>
214                                         <sourcefiles encoding="UTF-8">
215                                                 <fileset dir="src">
216                                                         <include name="org/cacert/gigi/**"/>
217                                                 </fileset>
218                                         </sourcefiles>
219                                 </group>
220                                 <group name="Testcases">
221                                         <classfiles>
222                                                 <fileset dir="bintest">
223                                                         <include name="org/cacert/gigi/**"/>
224                                                 </fileset>
225                                         </classfiles>
226                                         <sourcefiles encoding="UTF-8">
227                                                 <fileset dir="tests">
228                                                         <include name="org/cacert/gigi/**"/>
229                                                 </fileset>
230                                         </sourcefiles>
231                                 </group>
232                         </structure>
233
234                         <html destdir="cocoReport"/>
235
236                 </jacoco:report>
237         </target>
238 </project>