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