xml2po cleanup.
[docbook-zh.git] / defguide / zh / build.xml
blob4af0af0a9562d8a62cc9a6d6cd8dc6021ffd26c3
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3 Usage:
4     Building 'The Definitive Guide' - html
5         $ ant html
7     Building 'The Definitive Guide' - pdf
8         $ ant pdf
10 Dependency:
11     *) jdk 1.6
12     *) ant 1.7
13     *) bsf 2.4
14     *) beanshell 2.0b4
15     *) saxon 6.5.5
16     *) RELAX NG Support(jing)
17     *) DocBook v5 XSL
18     *) python 2.5
19     *) python-libxml2 2.6.32 (Line number in the pot file is inaccurate if XML
20             file larger than 65535 lines, See:
21             http://bugzilla.gnome.org/show_bug.cgi?id=325533)
22     *) gettext 0.17
23     *) xep 4.1.4 or fop trunk 2008-12-19(r728025), pdf only
24     *) chinese font files, pdf only
25 -->
26 <project name="defguide" default="html">
28     <property file="build.properties"/>
30     <path id="lib.classpath">
31         <fileset dir="${ant.home}/lib">
32             <include name="*.jar"/>
33         </fileset>
34         <fileset dir="${fop.home}">
35             <include name="**/*.jar"/>
36         </fileset>
37         <fileset dir="${usr.share.java}">
38             <include name="**/*.jar"/>
39         </fileset>
40         <pathelement location="${usr.share.java}"/>
41     </path>
43     <path id="xep.classpath">
44         <fileset dir="${xep.home}/lib">
45             <include name="*.jar"/>
46         </fileset>
47     </path>
49     <taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask"/>
51     <target name="usage">
52         <echo message="Use the -projecthelp option instead"/>
53     </target>
55     <target name="clean" description="Clean the build directory">
56         <delete dir="build"/>
57     </target>
59     <target name="init" description="Check runtime configuration">
60         <echo message="java.version: ${java.version}"/>
62         <!--Java SE 1.4 & 1.5: Unfixed java.lang.StackOverflowError !-->
63         <!--
64         <condition property="jdk_ok">
65             <scriptcondition language="beanshell" value="true">
66             <![CDATA[
67                 jvm = System.getProperty("java.specification.version");
68                 if(jvm.compareTo("1.6") < 0)
69                     self.setValue(false);
70             ]]>
71             </scriptcondition>
72         </condition>
73         <fail unless="jdk_ok">
74             Must use Java SE 6+ !
75         </fail>
76         -->
78         <fail>
79             <condition>
80                 <not><available file="build.properties"/></not>
81             </condition>
82             Please create your build.properties from build.properties.tmpl !
83         </fail>
85         <fail>
86             <condition>
87                 <not><available classname="com.thaiopensource.relaxng.util.Driver"/></not>
88             </condition>
89             RELAX NG Support(jing) NOT Present !
90         </fail>
92         <fail>
93             <condition>
94                 <not><available classname="com.icl.saxon.StyleSheet" classpathref="lib.classpath"/></not>
95             </condition>
96             Saxon 6.5 Support NOT Present !
97         </fail>
98     </target>
100     <target name="validate" depends="init" description="Validate document">
101         <jing rngfile="${docbook5.home}/rng/docbook.rng" file="source/defguide.xml"/>
102         <!--Don't uncomment this unless xml2po support namespace !-->
103         <!--jing rngfile="${docbook5.home}/rng/docbook.rng"
104                 file="build/defguide-zh.xml"/-->
105     </target>
107     <target name="all" description="Generate document - pdf,html">
108         <antcall target="defguide"/>
109         <antcall target="pdf"/>
110         <antcall target="html"/>
111     </target>
113     <target name="po.init">
114         <uptodate property="po.isUpToDate" targetfile="po/zh.po">
115             <srcfiles dir="source" includes="defguide.xml"/>
116         </uptodate>
117     </target>
119     <!-- Total time: 29 minutes 30 seconds -->
120     <target name="updatepo" depends="po.init" unless="po.isUpToDate" description="Update PO file">
121         <echo message="Making defguide.pot ..."/>
122         <exec dir="${basedir}/po" executable="python" failonerror="true">
123             <arg value="../xml2po/xml2po.py"/>
124             <arg value="-o"/>
125             <arg value="defguide.pot"/>
126             <arg value="../source/defguide.xml"/>
127         </exec>
129         <echo message="Merging zh.po ..."/>
130         <exec dir="${basedir}" executable="msgmerge">
131             <arg value="--sort-by-file"/>
132             <arg value="--width=80"/>
133             <arg value="-o"/>
134             <arg value="po/zh.po.new"/>
135             <arg value="po/zh.po"/>
136             <arg value="po/defguide.pot"/>
137         </exec>
138         <move file="po/zh.po.new" tofile="po/zh.po"/>
139     </target>
141     <target name="translate.init" depends="updatepo">
142         <uptodate property="translate.isUpToDate" targetfile="build/defguide-zh.xml">
143             <srcfiles dir="source" includes="defguide.xml"/>
144             <srcfiles dir="po" includes="zh.po"/>
145         </uptodate>
146     </target>
148     <!-- Total time: 29 minutes 14 seconds -->
149     <target name="translate" depends="translate.init" unless="translate.isUpToDate" description="Translate document">
150         <mkdir dir="build"/>
151         <echo message="Translating defguide-zh.xml ..."/>
152         <exec dir="${basedir}/xml2po" executable="python" failonerror="true">
153             <arg value="xml2po.py"/>
154             <arg value="-l"/>
155             <arg value="zh-cn"/>
156             <arg value="-p"/>
157             <arg value="../po/zh.po"/>
158             <arg value="-o"/>
159             <arg value="../build/defguide-zh.xml"/>
160             <arg value="../source/defguide.xml"/>
161         </exec>
162         <delete file="xml2po/.xml2po.mo"/>
163     </target>
165     <target name="html.init">
166         <uptodate property="html.isUpToDate" targetfile="build/html/.done">
167             <srcfiles dir="source" includes="defguide.xml"/>
168             <srcfiles dir="po" includes="zh.po"/>
169             <srcfiles dir="stylesheets" includes="html.xsl"/>
170             <srcfiles dir="stylesheets/zh" includes="html.xsl"/>
171         </uptodate>
172     </target>
174     <!-- Total time: 13 minutes 48 seconds -->
175     <target name="html" depends="init,translate,html.init" unless="html.isUpToDate" description="Generate document - html">
176         <mkdir dir="build/schema"/>
177         <copy todir="build/schema">
178             <fileset dir="source/schema"/>
179         </copy>
180         <copy todir="build/html/images">
181             <fileset dir="${docbook.xsl}/images" includes="**/*.png"/>
182         </copy>
183         <copy todir="build/html/figures">
184             <fileset dir="source/figures"/>
185         </copy>
186         <copy todir="build/examples">
187             <fileset dir="../en/examples"/>
188         </copy>
190         <echo message="Making html ..."/>
191         <java classname="com.icl.saxon.StyleSheet" fork="true" maxmemory="1024m"
192                 failonerror="true" dir="${basedir}/build/html">
193             <jvmarg value="-Xss512k"/>
194             <classpath refid="lib.classpath"/>
195             <arg value="-x"/>
196             <arg value="org.apache.xml.resolver.tools.ResolvingXMLReader"/>
197             <arg value="-y"/>
198             <arg value="org.apache.xml.resolver.tools.ResolvingXMLReader"/>
199             <arg value="-r"/>
200             <arg value="org.apache.xml.resolver.tools.CatalogResolver"/>
201             <arg value="../defguide-zh.xml"/>
202             <arg value="../../stylesheets/zh/html.xsl"/>
203         </java>
204         <!--exec dir="${basedir}/build/html" executable="xsltproc" failonerror="true">
205             <arg value="- -nonet"/>
206             <arg value="../../stylesheets/zh/html.xsl"/>
207             <arg value="../defguide-zh.xml"/>
208         </exec-->
209         <touch file="build/html/.done"/>
210     </target>
212     <target name="pdf.init">
213         <uptodate property="pdf.isUpToDate" targetfile="build/defguide-zh.pdf">
214             <srcfiles dir="source" includes="defguide.xml"/>
215             <srcfiles dir="po" includes="zh.po"/>
216             <srcfiles dir="stylesheets" includes="fo.xsl"/>
217             <srcfiles dir="stylesheets/zh" includes="fo.xsl"/>
218         </uptodate>
219     </target>
221     <!-- Total time: 10 minutes 44 seconds -->
222     <target name="pdf" depends="init,translate,pdf.init" unless="pdf.isUpToDate" description="Generate document - pdf">
223         <mkdir dir="build/schema"/>
224         <copy todir="build/schema">
225             <fileset dir="source/schema"/>
226         </copy>
227         <copy todir="build/images">
228             <fileset dir="${docbook.xsl}/images" includes="**/*.png"/>
229         </copy>
230         <copy todir="build/figures">
231             <fileset dir="source/figures" />
232         </copy>
233         <copy todir="build/examples">
234             <fileset dir="../en/examples"/>
235         </copy>
237         <echo message="Making fo ..."/>
238         <java classname="com.icl.saxon.StyleSheet" fork="true" maxmemory="1024m"
239                 failonerror="true" dir="${basedir}/build">
240             <jvmarg value="-Xss512k"/>
241             <classpath refid="lib.classpath"/>
242             <arg value="-x"/>
243             <arg value="org.apache.xml.resolver.tools.ResolvingXMLReader"/>
244             <arg value="-y"/>
245             <arg value="org.apache.xml.resolver.tools.ResolvingXMLReader"/>
246             <arg value="-r"/>
247             <arg value="org.apache.xml.resolver.tools.CatalogResolver"/>
248             <arg value="-o"/>
249             <arg value="defguide-zh.fo"/>
250             <arg value="defguide-zh.xml"/>
251             <arg value="../stylesheets/zh/fo.xsl"/>
252             <arg value="fop1.extensions=1"/>
253             <arg value="title.font.family=${fop.title.font.family}"/>
254             <arg value="body.font.family=${fop.body.font.family}"/>
255             <arg value="sans.font.family=${fop.sans.font.family}"/>
256             <arg value="ingbat.font.family=${fop.ingbat.font.family}"/>
257             <arg value="monospace.font.family=${fop.monospace.font.family}"/>
258         </java>
260         <echo message="Making pdf ..."/>
261         <java classname="${fop.class}" fork="true" maxmemory="1024m"
262                 failonerror="true" dir="${basedir}/build">
263             <classpath refid="lib.classpath"/>
264             <arg value="-c"/>
265             <arg value="${fop.home}/conf/userconfig.xml"/>
266             <arg value="defguide-zh.fo"/>
267             <arg value="defguide-zh.pdf"/>
268         </java>
269     </target>
271     <!-- Total time: ?? minutes ?? seconds -->
272     <target name="pdf-xep" depends="init,translate,pdf.init" unless="pdf.isUpToDate" description="Generate document - pdf - xep">
273         <mkdir dir="build/schema"/>
274         <copy todir="build/schema">
275             <fileset dir="source/schema"/>
276         </copy>
277         <copy todir="build/images">
278             <fileset dir="${docbook.xsl}/images" includes="**/*.png"/>
279         </copy>
280         <copy todir="build/figures">
281             <fileset dir="source/figures" />
282         </copy>
283         <copy todir="build/examples">
284             <fileset dir="../en/examples"/>
285         </copy>
287         <echo message="Making fo ..."/>
288         <java classname="com.icl.saxon.StyleSheet" fork="true" maxmemory="1024m"
289                 failonerror="true" dir="${basedir}/build">
290             <jvmarg value="-Xss1m"/>
291             <classpath refid="lib.classpath"/>
292             <arg value="-x"/>
293             <arg value="org.apache.xml.resolver.tools.ResolvingXMLReader"/>
294             <arg value="-y"/>
295             <arg value="org.apache.xml.resolver.tools.ResolvingXMLReader"/>
296             <arg value="-r"/>
297             <arg value="org.apache.xml.resolver.tools.CatalogResolver"/>
298             <arg value="-o"/>
299             <arg value="defguide-zh.fo"/>
300             <arg value="defguide-zh.xml"/>
301             <arg value="../stylesheets/zh/fo.xsl"/>
302             <arg value="xep.extensions=1"/>
303         </java>
305         <echo message="Making pdf ..."/>
306         <java classname="com.renderx.xep.XSLDriver" fork="true" maxmemory="1536m"
307                 failonerror="true" dir="${basedir}/build">
308             <jvmarg value="-Xss512k"/>
309             <classpath refid="xep.classpath"/>
310             <arg value="-DCONFIG=${xep.home}/xep.xml"/>
311             <arg value="-quiet"/>
312             <arg value="defguide-zh.fo"/>
313             <arg value="defguide-zh.pdf"/>
314         </java>
315     </target>
317     <target name="defguide.init">
318         <uptodate property="defguide.isUpToDate" targetfile="build/defguide.pdf">
319             <srcfiles dir="source" includes="defguide.xml"/>
320         </uptodate>
321     </target>
323     <!-- Total time: 12 minutes 41 seconds -->
324     <target name="defguide" depends="init,defguide.init" unless="defguide.isUpToDate" description="Generate document - defguide(en)">
325         <mkdir dir="build/schema"/>
326         <copy todir="build/schema">
327             <fileset dir="source/schema"/>
328         </copy>
329         <copy todir="build/images">
330             <fileset dir="${docbook.xsl}/images" includes="**/*.png"/>
331         </copy>
332         <copy todir="build/figures">
333             <fileset dir="source/figures" />
334         </copy>
335         <copy todir="build/examples">
336             <fileset dir="../en/examples"/>
337         </copy>
338         <copy file="source/defguide.xml" todir="build"/>
340         <echo message="Making fo ..."/>
341         <java classname="com.icl.saxon.StyleSheet" fork="true" maxmemory="1024m"
342                 failonerror="true" dir="${basedir}/build">
343             <jvmarg value="-Xss512k"/>
344             <classpath refid="lib.classpath"/>
345             <arg value="-x"/>
346             <arg value="org.apache.xml.resolver.tools.ResolvingXMLReader"/>
347             <arg value="-y"/>
348             <arg value="org.apache.xml.resolver.tools.ResolvingXMLReader"/>
349             <arg value="-r"/>
350             <arg value="org.apache.xml.resolver.tools.CatalogResolver"/>
351             <arg value="-o"/>
352             <arg value="defguide.fo"/>
353             <arg value="defguide.xml"/>
354             <arg value="../stylesheets/fo.xsl"/>
355             <arg value="fop1.extensions=1"/>
356             <arg value="title.font.family=${fop.title.font.family}"/>
357             <arg value="body.font.family=${fop.body.font.family}"/>
358             <arg value="sans.font.family=${fop.sans.font.family}"/>
359             <arg value="ingbat.font.family=${fop.ingbat.font.family}"/>
360             <arg value="monospace.font.family=${fop.monospace.font.family}"/>
361         </java>
363         <echo message="Making pdf ..."/>
364         <java classname="${fop.class}" fork="true" maxmemory="1024m"
365                 failonerror="true" dir="${basedir}/build">
366             <classpath refid="lib.classpath"/>
367             <arg value="-c"/>
368             <arg value="${fop.home}/conf/userconfig.xml"/>
369             <arg value="defguide.fo"/>
370             <arg value="defguide.pdf"/>
371         </java>
372     </target>
374     <!-- Total time: ?? minutes ?? seconds -->
375     <target name="defguide-xep" depends="init,defguide.init" unless="defguide.isUpToDate" description="Generate document - defguide(en) - xep">
376         <copy todir="build/schema">
377             <fileset dir="source/schema"/>
378         </copy>
379         <copy todir="build/images">
380             <fileset dir="${docbook.xsl}/images" includes="**/*.png"/>
381         </copy>
382         <copy todir="build/figures">
383             <fileset dir="source/figures" />
384         </copy>
385         <copy todir="build/examples">
386             <fileset dir="../en/examples"/>
387         </copy>
388         <copy file="source/defguide.xml" todir="build"/>
390         <echo message="Making fo ..."/>
391         <java classname="com.icl.saxon.StyleSheet" fork="true" maxmemory="1024m"
392                 failonerror="true" dir="${basedir}/build">
393             <jvmarg value="-Xss512k"/>
394             <classpath refid="lib.classpath"/>
395             <arg value="-x"/>
396             <arg value="org.apache.xml.resolver.tools.ResolvingXMLReader"/>
397             <arg value="-y"/>
398             <arg value="org.apache.xml.resolver.tools.ResolvingXMLReader"/>
399             <arg value="-r"/>
400             <arg value="org.apache.xml.resolver.tools.CatalogResolver"/>
401             <arg value="-o"/>
402             <arg value="defguide.fo"/>
403             <arg value="defguide.xml"/>
404             <arg value="../stylesheets/fo.xsl"/>
405             <arg value="xep.extensions=1"/>
406         </java>
408         <echo message="Making pdf ..."/>
409         <java classname="com.renderx.xep.XSLDriver" fork="true" maxmemory="1536m"
410                 failonerror="true" dir="${basedir}/build">
411             <jvmarg value="-Xss512k"/>
412             <classpath refid="xep.classpath"/>
413             <arg value="-DCONFIG=${xep.home}/xep.xml"/>
414             <arg value="-quiet"/>
415             <arg value="defguide.fo"/>
416             <arg value="defguide.pdf"/>
417         </java>
418     </target>
420 </project>