Merge changes I86c1045b,I9fc533ac
[gigi.git] / build.xml
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <project basedir="." default="develop" name="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="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="sqlconnector" value="/usr/share/java/postgresql-jdbc4.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="gigi.classpath">
21                 <pathelement location="bin" />
22                 <pathelement location="binutil" />
23                 <pathelement location="${sqlconnector}" />
24         </path>
25         <path id="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="${sqlconnector}" />
32         </path>
33         <path id="gigi.test.classpath.jdt">
34                 <pathelement location="${jdt}" />
35         </path>
36         <target name="init">
37                 <mkdir dir="bin" />
38                 <mkdir dir="binutil" />
39                 <mkdir dir="binutil-testing" />
40                 <mkdir dir="bintest" />
41
42                 <copy includeemptydirs="false" todir="bin">
43                         <fileset dir="lib/servlet-api">
44                                 <exclude name="**/*.launch" />
45                                 <exclude name="**/*.java" />
46                         </fileset>
47                         <fileset dir="lib/jetty">
48                                 <exclude name="**/*.launch" />
49                                 <exclude name="**/*.java" />
50                         </fileset>
51                         <fileset dir="src">
52                                 <exclude name="**/*.launch" />
53                                 <exclude name="**/*.java" />
54                         </fileset>
55                         <fileset dir="util">
56                                 <exclude name="**/*.launch" />
57                                 <exclude name="**/*.java" />
58                         </fileset>
59                 </copy>
60                 <copy includeemptydirs="false" todir="binutil-testing">
61                         <fileset dir="util-testing">
62                                 <exclude name="**/*.launch" />
63                                 <exclude name="**/*.java" />
64                         </fileset>
65                 </copy>
66                 <copy includeemptydirs="false" todir="bintest">
67                         <fileset dir="tests">
68                                 <exclude name="**/*.launch" />
69                                 <exclude name="**/*.java" />
70                         </fileset>
71                 </copy>
72         </target>
73         <target name="clean">
74                 <delete dir="bin" />
75         </target>
76         <target name="clean-test">
77                 <delete dir="bintest" />
78                 <delete dir="cocoReport" failonerror="false"/>
79
80         </target>
81         <target depends="clean,clean-test" name="cleanall" />
82         <target depends="build-project, build-testing, native" name="build" />
83         <target depends="init" name="build-project">
84                 <exec outputproperty="git-version" executable="git">
85                         <arg line="rev-parse"/>
86                         <arg line="HEAD"/>
87                 </exec>
88                 <manifest file="Gigi.MF">
89                         <attribute name="Main-Class" value="club.wpia.gigi.Launcher" />
90                         <attribute name="Implementation-Version" value="${git-version}" />
91                 </manifest>
92                 <echo message="${ant.project.name}: ${ant.file}" />
93                 <javac encoding="UTF-8" debug="true" debuglevel="${debuglevel}" destdir="bin"
94                         includeantruntime="false" source="${source}" target="${target}">
95                         <compilerarg value="-XDignore.symbol.file"/>
96                         <src path="lib/servlet-api" />
97                         <src path="lib/jetty" />
98                         <src path="lib/jtar" />
99                         <src path="lib/scrypt" />
100                         <src path="lib/json" />
101                         <src path="src" />
102                         <classpath refid="gigi.classpath" />
103                 </javac>
104                 <javac encoding="UTF-8" debug="true" debuglevel="${debuglevel}" destdir="binutil"
105                         includeantruntime="false" source="${source}" target="${target}">
106                         <compilerarg value="-XDignore.symbol.file"/>
107                         <src path="util" />
108                         <classpath refid="gigi.classpath" />
109                 </javac>
110         </target>
111         <target depends="init, build-project" name="build-testing">
112                 <javac encoding="UTF-8" debug="true" debuglevel="${debuglevel}" destdir="binutil-testing"
113                         includeantruntime="false" source="${source}" target="${target}">
114                         <compilerarg value="-XDignore.symbol.file"/>
115                         <src path="util-testing" />
116                         <exclude name="club/wpia/gigi/localisation/**"/>
117                         <classpath refid="gigi.classpath" />
118                 </javac>
119         </target>
120         <target depends="init, build-project, reset-db" name="build-testing-l10n">
121                 <javac encoding="UTF-8" debug="true" debuglevel="${debuglevel}" destdir="binutil-testing"
122                         includeantruntime="false" source="${source}" target="${target}">
123                         <compilerarg value="-XDignore.symbol.file"/>
124                         <src path="util-testing" />
125                         <include name="club/wpia/gigi/localisation/**"/>
126                         <classpath refid="gigi.classpath" />
127                         <classpath refid="gigi.test.classpath.jdt" />
128                 </javac>
129                 <java classname="club.wpia.gigi.localisation.TranslationCollector" failonerror="true">
130                         <arg value="util-testing/club/wpia/gigi/localisation/conf.txt"/>
131                         <arg value="."/>
132                         <arg value="messages.po"/>
133                         <classpath refid="gigi.test.classpath" />
134                         <classpath refid="gigi.test.classpath.jdt" />
135                 </java>
136                 <java classname="club.wpia.gigi.localisation.TranslationCollector" failonerror="true">
137                         <arg value="util-testing/club/wpia/gigi/localisation/conf.txt"/>
138                         <arg value="."/>
139                         <arg value="SQLValidation"/>
140                         <classpath refid="gigi.test.classpath" />
141                         <classpath refid="gigi.test.classpath.jdt" />
142                 </java>
143         </target>
144
145         <target name="native">
146                 <exec executable="make" dir="natives"/>
147         </target>
148
149         <target depends="build-project, update-effective-tlds" name="pack">
150                 <jar destfile="gigi.jar" basedir="bin" manifest="Gigi.MF" update="false"/>
151                 <jar destfile="gigi.jar" basedir="binutil" update="on"/>
152         </target>
153
154         <target depends="build-testing,update-effective-tlds" name="pack-testing">
155                 <jar destfile="gigi-testing.jar" basedir="bin" manifest="Gigi.MF" update="false"/>
156                 <jar destfile="gigi-testing.jar" basedir="binutil" update="on"/>
157                 <jar destfile="gigi-testing.jar" basedir="binutil-testing" update="on"/>
158         </target>
159
160         <target depends="test,native" name="bundle">
161                 <zip destfile="gigi-linux_amd64.zip" basedir="."
162                         includes="gigi.jar,native/*.so,src/club/wpia/gigi/database/tableStructure.sql,static/**,templates/**" />
163         </target>
164         <target name="static-bundle">
165                 <mkdir dir="work"/>
166                 <mkdir dir="work/static"/>
167                 <copy todir="work/static">
168                         <fileset dir="static"/>
169                 </copy>
170                 <tar destfile="static.tar.gz" compression="gzip" basedir="work"
171                         includes="../src/club/wpia/gigi/database/tableStructure.sql,**,templates/**" />
172         </target>
173
174         <target name="static-bundle-release">
175                 <mkdir dir="work"/>
176                 <mkdir dir="work/static"/>
177                 <copy todir="work/static">
178                         <fileset dir="static"/>
179                 </copy>
180                 <tar destfile="static.tar.gz" compression="gzip" basedir="work"
181                         includes="../src/club/wpia/gigi/database/tableStructure.sql,**,templates/**" />
182         </target>
183
184         <target name="develop" depends="bundle,static-bundle" />
185
186         <target name="release" depends="bundle,static-bundle-release" />
187
188         <target depends="init,build-testing,update-effective-tlds" name="build-project-test">
189                 <echo message="${ant.project.name}: ${ant.file}" />
190                 <javac encoding="UTF-8" debug="true" debuglevel="${debuglevel}" destdir="bintest"
191                         includeantruntime="false" source="${source}" target="${target}">
192                         <compilerarg value="-XDignore.symbol.file"/>
193                         <src path="tests" />
194                         <classpath refid="gigi.test.classpath" />
195                 </javac>
196                 <concat destfile="bintest/club/wpia/gigi/util/effective_tld_names.dat">
197                         <path path="bin/club/wpia/gigi/util/effective_tld_names.dat"/>
198                         <path path="publicSuffixFooter.dat"/>
199                 </concat>
200         </target>
201         <target name="check-locale">
202                 <available file="locale/de.xml" property="locale.present" />
203         </target>
204         <target name="FetchLocales" depends="check-locale" unless="locale.present">
205                 <java classname="club.wpia.gigi.util.FetchLocales" failonerror="true"
206                         fork="yes">
207                         <classpath refid="gigi.classpath" />
208                         <arg value="${localePath}"/>
209                 </java>
210         </target>
211         <target name="check-generateKeys">
212                 <available file="config/keystore.pkcs12" property="keystore.present" />
213         </target>
214         <target name="generateKeys" depends="check-generateKeys" unless="keystore.present">
215                 <exec executable="./generateKeys.sh" dir="keys" />
216                 <exec executable="./generateTruststore.sh" dir="keys">
217                         <arg value="-noprompt" />
218                 </exec>
219         </target>
220         <target name="reset-db" depends="build-project">
221                 <copy file="config/test.properties" tofile="config/gigi.properties"/>
222                 <java classname="club.wpia.gigi.util.DatabaseManager">
223                         <arg value="--test"/>
224                         <classpath refid="gigi.test.classpath" />
225                 </java>
226         </target>
227         <target name="test" depends="build-project-test,FetchLocales,pack-testing,pack,reset-db">
228                 <delete failonerror="false">
229                         <fileset dir=".">
230                                 <include name="jacoco.exec"/>
231                                 <include name="tester.exec"/>
232                         </fileset>
233                 </delete>
234                 <mkdir dir="${junit.output.dir}" />
235                 <junit maxmemory="2g" fork="yes" printsummary="withOutAndErr">
236                         <jvmarg value="-javaagent:/usr/share/java/jacocoagent.jar=destfile=tester.exec"/>
237                         <jvmarg value="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:50001"/>
238                         <formatter type="xml" />
239                         <batchtest fork="yes" todir="${junit.output.dir}">
240                                 <fileset dir="tests">
241                                         <include name="**/*.java" />
242                                         <exclude name="**/testUtils/**" />
243                                         <exclude name="**/com/lambdaworks/crypto/test/CryptoTestUtil.java"/>
244                                 </fileset>
245                         </batchtest>
246                         <classpath refid="gigi.test.classpath" />
247                 </junit>
248         </target>
249         <target name="junitreport">
250                 <junitreport todir="${junit.output.dir}">
251                         <fileset dir="${junit.output.dir}">
252                                 <include name="TEST-*.xml" />
253                         </fileset>
254                         <report format="frames" todir="${junit.output.dir}" />
255                 </junitreport>
256         </target>
257         <target name="generatecoco">
258                 <delete file="merged.exec"/>
259
260                 <jacoco:merge destfile="merged.exec">
261                         <fileset dir="." includes="*.exec"/>
262                 </jacoco:merge>
263                 <jacoco:report>
264                         <executiondata>
265                                 <file file="merged.exec" />
266                         </executiondata>
267
268                         <structure name="Gigi">
269                                 <group name="Server">
270                                         <classfiles>
271                                                 <fileset dir="bin">
272                                                         <include name="club/wpia/gigi/**"/>
273                                                 </fileset>
274                                         </classfiles>
275                                         <sourcefiles encoding="UTF-8">
276                                                 <fileset dir="src">
277                                                         <include name="club/wpia/gigi/**"/>
278                                                 </fileset>
279                                         </sourcefiles>
280                                 </group>
281                                 <group name="Testcases">
282                                         <classfiles>
283                                                 <fileset dir="bintest">
284                                                         <include name="club/wpia/gigi/**"/>
285                                                 </fileset>
286                                         </classfiles>
287                                         <sourcefiles encoding="UTF-8">
288                                                 <fileset dir="tests">
289                                                         <include name="club/wpia/gigi/**"/>
290                                                 </fileset>
291                                         </sourcefiles>
292                                 </group>
293                         </structure>
294
295                         <html destdir="cocoReport"/>
296
297                 </jacoco:report>
298         </target>
299         <target name="install-native" depends="native">
300                 <mkdir dir="${env.DESTDIR}/usr/lib/jni"/>
301                 <copy file="natives/libsetuid.so" todir="${env.DESTDIR}/usr/lib/jni"/>
302         </target>
303         <target name="install" depends="install-common">
304                 <mkdir dir="${env.DESTDIR}/usr/share/wpia-gigi/static" />
305                 <copy todir="${env.DESTDIR}/usr/share/wpia-gigi/static">
306                         <fileset dir="static" />
307                 </copy>
308                 <copy file="gigi.jar" tofile="${env.DESTDIR}/usr/share/java/gigi.jar"/>
309         </target>
310         <target name="install-testing" depends="install-common">
311                 <mkdir dir="${env.DESTDIR}/usr/share/wpia-gigi/static" />
312                 <copy todir="${env.DESTDIR}/usr/share/wpia-gigi/static">
313                         <fileset dir="static" />
314                 </copy>
315                 <copy file="gigi-testing.jar" tofile="${env.DESTDIR}/usr/share/java/gigi.jar"/>
316         </target>
317
318         <target name="install-common" depends="pack">
319                 <mkdir dir="${env.DESTDIR}/usr/share/java" />
320
321                 <mkdir dir="${env.DESTDIR}/usr/bin"/>
322                 <copy file="doc/scripts/gigi" tofile="${env.DESTDIR}/usr/bin/gigi"/>
323
324                 <chmod file="${env.DESTDIR}/usr/bin/gigi" perm="+x"/>
325                 <mkdir dir="${env.DESTDIR}/usr/share/dbconfig-common/data/${PACKAGE}/install/"/>
326                 <copy file="src/club/wpia/gigi/database/tableStructure.sql" tofile="${env.DESTDIR}/usr/share/dbconfig-common/data/${PACKAGE}/install/mysql.sql"/>
327
328                 <mkdir dir="${env.DESTDIR}/var/lib/wpia-gigi/doc"/>
329                 <exec executable="ln">
330                         <arg value="-s"/>
331                         <arg value="/usr/share/dbconfig-common/data/${PACKAGE}/install/mysql.sql"/>
332                         <arg value="${env.DESTDIR}/var/lib/wpia-gigi/doc/tableStructure.sql"/>
333                 </exec>
334                 <mkdir dir="${env.DESTDIR}/var/lib/wpia-gigi/natives"/>
335                 <delete failonerror="false" file="${env.DESTDIR}/var/gigigigi/static"/>
336                 <exec executable="ln">
337                         <arg value="-s"/>
338                         <arg value="/usr/share/wpia-gigi/static"/>
339                         <arg value="${env.DESTDIR}/var/lib/wpia-gigi/static"/>
340                 </exec>
341                 <exec executable="ln">
342                         <arg value="-s"/>
343                         <arg value="/usr/lib/jni/libsetuid.so"/>
344                         <arg value="${env.DESTDIR}/var/lib/wpia-gigi/natives/libsetuid.so"/>
345                 </exec>
346
347                 <mkdir dir="${env.DESTDIR}/etc/wpia/gigi"/>
348                 <!--<copy todir="${env.DESTDIR}/DEBIAN">
349                         <fileset dir="debian">
350                         </fileset>
351                 </copy>-->
352         </target>
353         <target name="update-effective-tlds">
354                 <mkdir dir="bin/club/wpia/gigi/util"/>
355                 <exec executable="wget" dir="bin/club/wpia/gigi/util">
356                         <arg value="-N"/>
357                         <arg value="-q"/>
358                         <arg value="https://publicsuffix.org/list/effective_tld_names.dat"/>
359                 </exec>
360         </target>
361 </project>