fa99b2ad50e9066cdd48a517c25a23b0e9982c7f
[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="test" depends="build-project-test,generateKeys,FetchLocales,pack">
155                 <delete failonerror="false">
156                         <fileset dir=".">
157                                 <include name="jacoco.exec"/>
158                                 <include name="tester.exec"/>
159                         </fileset>
160                 </delete>
161                 <mkdir dir="${junit.output.dir}" />
162                 <junit fork="yes" printsummary="withOutAndErr">
163                         <jvmarg value="-javaagent:/usr/share/java/jacocoagent.jar=destfile=tester.exec"/>
164                         <formatter type="xml" />
165                         <batchtest fork="yes" todir="${junit.output.dir}">
166                                 <fileset dir="tests">
167                                         <include name="**/*.java" />
168                                         <exclude name="**/testUtils/**" />
169                                 </fileset>
170                         </batchtest>
171                         <classpath refid="cacert-gigi.test.classpath" />
172                 </junit>
173         </target>
174         <target name="junitreport">
175                 <junitreport todir="${junit.output.dir}">
176                         <fileset dir="${junit.output.dir}">
177                                 <include name="TEST-*.xml" />
178                         </fileset>
179                         <report format="frames" todir="${junit.output.dir}" />
180                 </junitreport>
181         </target>
182         <target name="generatecoco">
183                 <jacoco:merge destfile="merged.exec">
184                         <fileset dir="." includes="*.exec"/>
185                 </jacoco:merge>
186                 <jacoco:report>
187                         <executiondata>
188                                 <file file="jacoco.exec" />
189                                 <file file="tester.exec" />
190                         </executiondata>
191
192                         <structure name="CAcert gigi">
193                                 <group name="Server">
194                                         <classfiles>
195                                                 <fileset dir="bin/org/cacert/gigi" />
196                                         </classfiles>
197                                         <sourcefiles encoding="UTF-8">
198                                                 <fileset dir="src/org/cacert/gigi" />
199                                         </sourcefiles>
200                                 </group>
201                                 <group name="Testcases">
202                                         <classfiles>
203                                                 <fileset dir="bintest/org/cacert/gigi" />
204                                         </classfiles>
205                                         <sourcefiles encoding="UTF-8">
206                                                 <fileset dir="tests/org/cacert/gigi" />
207                                         </sourcefiles>
208                                 </group>
209                         </structure>
210
211                         <html destdir="cocoReport"/>
212
213                 </jacoco:report>
214         </target>
215 </project>