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