forked from bwagner/dtbook2sbsform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
206 lines (177 loc) · 7.22 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<?xml version="1.0" encoding="UTF-8"?>
<project name="dtbook2sbsform" default="default" basedir=".">
<!-- Copyright (C) 2010 Swiss Library for the Blind, Visually Impaired and Print Disabled -->
<!-- This file is part of dtbook2sbsform. -->
<!-- dtbook2sbsform is free software: you can redistribute it -->
<!-- and/or modify it under the terms of the GNU Lesser General Public -->
<!-- License as published by the Free Software Foundation, either -->
<!-- version 3 of the License, or (at your option) any later version. -->
<!-- This program is distributed in the hope that it will be useful, -->
<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -->
<!-- Lesser General Public License for more details. -->
<!-- You should have received a copy of the GNU Lesser General Public -->
<!-- License along with this program. If not, see -->
<!-- <http://www.gnu.org/licenses/>. -->
<property name="compile.target" value="1.6" />
<property name="compile.source" value="1.6" />
<property name="build.dir" value="build" />
<property name="app.name" value="${ant.project.name}" />
<property name="utility.jar" value="linebreaker.jar" />
<property name="src.dir" value="src" />
<property name="test_src.dir" value="test_src" />
<property name="lib.dir" value="lib" />
<property name="zipfile" value="${app.name}.zip" />
<!-- used for utfx -->
<property name="testrunner" value="utfx.runner.TestRunner" />
<path id="classpath.path">
<pathelement location="${build.dir}" />
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
</path>
<target name="init">
<mkdir dir="${build.dir}" />
</target>
<target name="default" depends="jar" />
<target name="jar" depends="compile, git.revision" description="build jar">
<jar jarfile="${utility.jar}" basedir="${build.dir}" includes="**/*.class" excludes="**/*Test.class">
<manifest>
<attribute name="Built-By" value="${user.name}" />
<attribute name="Implementation-Version" value="${repository.version}" />
</manifest>
</jar>
</target>
<target name="compile" depends="init">
<javac destdir="${build.dir}"
target="${compile.target}"
source="${compile.source}"
deprecation="on" debug="on"
includeAntRuntime="false">
<src path="${src.dir}" />
<src path="${test_src.dir}" />
<classpath>
<path refid="classpath.path" />
</classpath>
</javac>
</target>
<target name="src_test" depends="compile" description="run src test">
<junit printsummary="yes" fork="yes" haltonfailure="no" haltonerror="no">
<formatter type="plain" usefile="false" />
<classpath>
<!-- classes to test -->
<pathelement location="${build.dir}" />
<!-- 3rd party libs -->
<pathelement location="${lib.dir}/jna.jar" />
<pathelement location="${lib.dir}/louis-1.0.jar" />
<pathelement location="${lib.dir}/saxon9he.jar" />
<!-- junit -->
<pathelement location="${lib.dir}/junit-4.8.2.jar" />
</classpath>
<batchtest>
<formatter type="plain" usefile="false" />
<fileset dir="${test_src.dir}">
<include name="**/*Test.java" />
</fileset>
</batchtest>
</junit>
</target>
<path id="runtime.classpath">
<pathelement location="lib/saxon9he.jar"/>
<pathelement location="lib/louis-1.0.jar"/>
<pathelement location="lib/jna.jar"/>
<pathelement location="lib/liblouissaxonx.jar"/>
<pathelement location="lib/utfxFat.jar"/>
<pathelement location="."/>
</path>
<target name="utfx" description="run utfx tests">
<java classname="${testrunner}" fork="yes">
<jvmarg value="-enableassertions" />
<jvmarg value="-Xmx128m" />
<jvmarg value="-Djavax.xml.transform.TransformerFactory=org.liblouis.transformerfactory.LouisExtensionTransformerFactoryImpl" />
<jvmarg value="-Dutfx.test.dir=test_xsl" />
<arg value="utfx.framework.XSLTRegressionTest" />
<classpath refid="runtime.classpath" />
</java>
</target>
<target name="test" depends="src_test, utfx" description="run src_test and utfx_tests"/>
<target name="clean" description="clean">
<delete dir="${build.dir}" />
<delete file="${utility.jar}" />
<delete file="utfx_log.xml" />
<delete file="${zipfile}" />
</target>
<available file=".git" type="dir" property="git.present" />
<target name="git.revision" description="Store git revision in ${repository.version}" if="git.present">
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="/usr/share/java/ant-contrib.jar"/>
</classpath>
</taskdef>
<exec executable="git" outputproperty="git.revision" failifexecutionfails="false" errorproperty="">
<arg value="describe" />
<arg value="--tags" />
<arg value="--always" />
<arg value="--dirty" />
</exec>
<!-- The output of git describe is going to be something along the lines of 'v0.8-77-g88066cd-dirty'
as we name our tags that way. So we need to trim the 'v' in order to get a version number that we can
use for debian packages -->
<propertyregex property="version" input="${git.revision}" regexp="v(.*$)" select="\1"/>
<condition property="repository.version" value="${version}" else="unknown">
<and>
<isset property="git.revision" />
<length string="${git.revision}" trim="yes" length="0" when="greater" />
</and>
</condition>
</target>
<target name="dist" depends="jar"
description="Builds a zipfile containing everything needed to run the shell scripts">
<zip destfile="${zipfile}">
<zipfileset dir="${lib.dir}" prefix="${app.name}/${lib.dir}">
<include name="*.jar"/>
</zipfileset>
<zipfileset dir="." prefix="${app.name}">
<include name="*.jar"/>
<include name="COPYING.LESSER"/>
<include name="README"/>
</zipfileset>
<zipfileset dir="." prefix="${app.name}" filemode="755">
<include name="*.sh"/>
<exclude name="utfx.sh"/>
</zipfileset>
<zipfileset dir="xsl" prefix="${app.name}/xsl">
<include name="*.xsl"/>
</zipfileset>
</zip>
</target>
<target name="package" depends="jar" description="Build a debian package">
<taskdef name="deb" classname="org.vafer.jdeb.ant.DebAntTask"/>
<copy todir="${build.dir}/debian/control">
<fileset dir="src/debian"/>
<filterset begintoken="[[" endtoken="]]">
<filter token="version" value="${repository.version}"/>
<filter token="name" value="${ant.project.name}"/>
</filterset>
</copy>
<deb destfile="${build.dir}/${ant.project.name}-${repository.version}.deb" control="${build.dir}/debian/control">
<data src="." type="directory">
<mapper type="perm" prefix="/opt/dtbook2sbsform"/>
<include name="${utility.jar}"/>
<include name="COPYING.LESSER"/>
</data>
<data src="." type="directory">
<mapper type="perm" filemode="755" prefix="/opt/dtbook2sbsform"/>
<include name="*.sh"/>
<exclude name="utfx.sh"/>
</data>
<data src="lib" type="directory">
<mapper type="perm" prefix="/opt/dtbook2sbsform/lib"/>
</data>
<data src="xsl" type="directory">
<mapper type="perm" prefix="/opt/dtbook2sbsform/xsl"/>
<exclude name="**/*~"/>
</data>
</deb>
</target>
</project>