[subversion] trunk 100% again
[i18n-zh.git] / doc / svnbook / build.xml
blob5193875d8f7d6ec6dd7a4105b7cc7fe55060cae5
1 <?xml version="1.0" encoding="UTF-8"?>
2 <project name="svnbook" default="pdf">
4   <property file="build.properties"/>
6   <path id="lib.classpath">
7     <fileset dir="${ant.home}/lib">
8       <include name="*.jar"/>
9     </fileset>
10     <fileset dir="${fop.home}">
11       <include name="**/*.jar"/>
12     </fileset>
13     <fileset dir="${usr.share.java}">
14       <include name="**/*.jar"/>
15     </fileset>
16   </path>
18   <target name="usage">
19     <echo message="Use the -projecthelp option instead"/>
20   </target>
22   <target name="clean" description="Clean the build directory">
23     <delete dir="build"/>
24     <delete file="stylesheets/html-import.xsl"/>
25     <delete file="stylesheets/chm-import.xsl"/>
26     <delete file="stylesheets/fo-import.xsl"/>
27   </target>
29   <target name="clean-svn">
30     <delete>
31       <fileset dir="${basedir}" excludes="**/.svn"/>
32     </delete>
33   </target>
35   <target name="init" description="Check runtime class">
36     <available file="build.properties" property="properties.present"/>
37     <fail message="Please create your build.properties from build.tmpl.properties !" unless="properties.present"/>
39     <condition property="saxon.present">
40       <and>
41         <available classname="com.icl.saxon.StyleSheet" classpathref="lib.classpath"/>
42       </and>
43     </condition>
44     <fail message="Saxon 6.5 Support NOT Present !" unless="saxon.present"/>
46     <echo message="java.version: ${java.version}"/>
47   </target>
49   <target name="all" description="Generate document - pdf,html,chm">
50     <antcall target="pdf"/>
51     <antcall target="html"/>
52     <antcall target="chm"/>
53   </target>
55   <target name="pot.init" depends="init">
56     <uptodate property="pot.isUpToDate" targetfile="po/book.pot">
57       <srcfiles dir="source" includes="book.xml"/>
58     </uptodate>
59   </target>
61   <!--Total time: 34 seconds-->
62   <target name="pot" depends="pot.init" unless="pot.isUpToDate" description="Generate POTemplate">
63     <echo message="Making pot ..."/>
64     <exec dir="${basedir}/po" executable="python" failonerror="true">
65       <arg value="../xml2po/xml2po.py"/>
66       <arg value="-o"/>
67       <arg value="book.pot"/>
68       <arg value="../source/book.xml"/>
69     </exec>
71     <echo message="Merging zh_CN.po ..."/>
72     <exec dir="${basedir}/po" executable="msgmerge">
73       <arg value="--no-wrap"/>
74       <arg value="-o"/>
75       <arg value="zh_CN-tmp.po"/>
76       <arg value="zh_CN.po"/>
77       <arg value="book.pot"/>
78     </exec>
79     <move file="po/zh_CN-tmp.po" tofile="po/zh_CN.po"/>
80     <fixcrlf srcdir="${basedir}" encoding="UTF-8" includes="source/book.xml,po/book.pot,po/zh_CN.po" eol="lf"/>
81   </target>
83   <target name="translate.init" depends="pot">
84     <uptodate property="translate.isUpToDate" targetfile="build/zh_CN/book.xml">
85       <srcfiles dir="source" includes="book.xml"/>
86       <srcfiles dir="po" includes="zh_CN.po"/>
87     </uptodate>
88   </target>
90   <!--Total time: 36 second-->
91   <target name="translate" depends="translate.init" unless="translate.isUpToDate" description="Translate document">
92     <mkdir dir="build/zh_CN"/>
93     <echo message="Translating to zh_CN ..."/>
94     <exec dir="${basedir}/xml2po" executable="python" failonerror="true">
95       <arg value="xml2po.py"/>
96       <arg value="-l"/>
97       <arg value="zh-cn"/>
98       <arg value="-p"/>
99       <arg value="../po/zh_CN.po"/>
100       <arg value="-o"/>
101       <arg value="../build/zh_CN/book-tmp.xml"/>
102       <arg value="../source/book.xml"/>
103     </exec>
105     <exec dir="${basedir}/build/zh_CN" executable="xmllint">
106       <arg value="--nsclean"/>
107       <arg value="--format"/>
108       <arg value="--output"/>
109       <arg value="book.xml"/>
110       <arg value="book-tmp.xml"/>
111     </exec>
112     <delete file="xml2po/.xml2po.mo"/>
113     <delete file="build/zh_CN/book-tmp.xml"/>
114   </target>
116   <target name="html.init">
117     <uptodate property="html.isUpToDate" targetfile="build/zh_CN/svnbook/.done">
118       <srcfiles dir="source" includes="book.xml"/>
119       <srcfiles dir="po" includes="zh_CN.po"/>
120     </uptodate>
121   </target>
123   <!--Total time: 43 seconds-->
124   <target name="html" depends="translate,html.init" unless="html.isUpToDate" description="Generate document - html">
125     <filter token="docbook5.xsl.url" value="${docbook5.xsl.url}"/>
126     <copy file="stylesheets/html-import.tmpl.xsl" tofile="stylesheets/html-import.xsl" filtering="true" overwrite="true"/>
127     <copy todir="build/zh_CN/svnbook/images">
128       <fileset dir="source/images" includes="*.png"/>
129       <fileset dir="${docbook5.xsl}/images" includes="**/*.png"/>
130     </copy>
132     <echo message="Making html ..."/>
133     <exec dir="${basedir}/build/zh_CN/svnbook" executable="xsltproc" failonerror="true">
134       <arg value="--nonet"/>
135       <arg value="../../../stylesheets/zh_CN/html.xsl"/>
136       <arg value="../book.xml"/>
137     </exec>
138     <touch file="build/zh_CN/svnbook/.done"/>
139   </target>
141   <target name="chm.init">
142     <uptodate property="chm.isUpToDate" targetfile="build/zh_CN/svnbook-zh_CN.chm">
143       <srcfiles dir="source" includes="defguide.xml"/>
144       <srcfiles dir="po" includes="zh_CN.po"/>
145     </uptodate>
146   </target>
148   <!--Total time: 53 seconds-->
149   <target name="chm" depends="translate,chm.init" unless="chm.isUpToDate" description="Generate document - chm">
150     <fail>
151       <condition>
152         <not>
153           <os family="windows"/>
154         </not>
155       </condition>
156       This target only work on windows !
157     </fail>
159     <filter token="docbook5.xsl.url" value="${docbook5.xsl.url}"/>
160     <copy file="stylesheets/chm-import.tmpl.xsl" tofile="stylesheets/chm-import.xsl" filtering="true" overwrite="true"/>
161     <copy todir="build/zh_CN/htmlhelp/images">
162       <fileset dir="source/images" includes="*.png"/>
163       <fileset dir="${docbook5.xsl}/images" includes="**/*.png"/>
164     </copy>
166     <echo message="Making chm ..."/>
167     <exec dir="${basedir}/build/zh_CN" executable="xmllint">
168       <arg value="--encode"/>
169       <arg value="GB18030"/>
170       <arg value="--format"/>
171       <arg value="--output"/>
172       <arg value="book-GB18030.xml"/>
173       <arg value="book.xml"/>
174     </exec>
175     <!--Must use GB18030 encoding and xsltproc for chm format !-->
176     <exec dir="${basedir}/build/zh_CN" executable="xsltproc" failonerror="true">
177       <arg value="../../stylesheets/zh_CN/chm.xsl"/>
178       <arg value="book-GB18030.xml"/>
179     </exec>
181     <exec dir="${basedir}/build/zh_CN" executable="hhc" failonerror="false">
182       <arg value="htmlhelp.hhp"/>
183     </exec>
184     <delete dir="build/zh_CN/htmlhelp"/>
185     <delete file="build/zh_CN/toc.hhc"/>
186     <delete file="build/zh_CN/index.hhk"/>
187     <delete file="build/zh_CN/htmlhelp.hhp"/>
188   </target>
190   <target name="fo.init">
191     <uptodate property="fo.isUpToDate" targetfile="build/zh_CN/svnbook.fo">
192       <srcfiles dir="source" includes="defguide.xml"/>
193       <srcfiles dir="po" includes="zh_CN.po"/>
194     </uptodate>
195   </target>
197   <!--Total time: 17 seconds-->
198   <target name="fo" depends="translate,fo.init" unless="fo.isUpToDate">
199     <filter token="docbook5.xsl.url" value="${docbook5.xsl.url}"/>
200     <copy file="stylesheets/fo-import.tmpl.xsl" tofile="stylesheets/fo-import.xsl" filtering="true" overwrite="true"/>
201     <mkdir dir="build/zh_CN/pdf"/>
203     <echo message="Making fo ..."/>
204     <!--java classname="org.apache.xalan.xslt.Process" fork="true" maxmemory="1024m"
205                 failonerror="true" dir="${basedir}">
206             <classpath refid="lib.classpath"/>
207             <arg value="-out"/>
208             <arg value="build/zh_CN/pdf/book-tmp.fo"/>
209             <arg value="-in"/>
210             <arg value="build/zh_CN/book.xml"/>
211             <arg value="-xsl"/>
212             <arg value="stylesheets/zh_CN/fo.xsl"/>
213         </java-->
214     <java classname="com.icl.saxon.StyleSheet" fork="true" maxmemory="1024m" failonerror="true" dir="${basedir}">
215       <classpath refid="lib.classpath"/>
216       <arg value="-o"/>
217       <arg value="build/zh_CN/pdf/book-tmp.fo"/>
218       <arg value="build/zh_CN/book.xml"/>
219       <arg value="stylesheets/zh_CN/fo.xsl"/>
220     </java>
222     <exec dir="${basedir}/build/zh_CN/pdf" executable="xmllint">
223       <arg value="--nsclean"/>
224       <arg value="--format"/>
225       <arg value="--output"/>
226       <arg value="../svnbook.fo"/>
227       <arg value="book-tmp.fo"/>
228     </exec>
229     <delete dir="build/zh_CN/pdf"/>
230   </target>
232   <target name="pdf.init">
233     <uptodate property="pdf.isUpToDate" targetfile="build/zh_CN/svnbook.pdf">
234       <srcfiles dir="source" includes="defguide.xml"/>
235       <srcfiles dir="po" includes="zh_CN.po"/>
236       <srcfiles dir="build/zh_CN" includes="svnbook.fo"/>
237     </uptodate>
238   </target>
240   <!--Total time: 23 seconds-->
241   <target name="pdf" depends="fo,pdf.init" unless="pdf.isUpToDate" description="Generate document - pdf">
242     <copy todir="build/zh_CN/pdf/images">
243       <fileset dir="source/images" includes="*.png"/>
244       <fileset dir="${docbook5.xsl}/images" includes="**/*.png"/>
245     </copy>
246     <copy todir="build/zh_CN/pdf">
247       <fileset dir="${fop.home}/conf">
248         <include name="*.xml"/>
249       </fileset>
250       <fileset dir="${fonts.dir}">
251         <include name="*.ttf"/>
252         <include name="*.ttc"/>
253       </fileset>
254       <fileset dir="build/zh_CN">
255         <include name="svnbook.fo"/>
256       </fileset>
257     </copy>
259     <echo message="Making pdf ..."/>
260     <java classname="${fop.class}" fork="true" maxmemory="512m" failonerror="true" dir="${basedir}/build/zh_CN/pdf">
261       <classpath refid="lib.classpath"/>
262       <arg value="-c"/>
263       <arg value="userconfig.xml"/>
264       <arg value="svnbook.fo"/>
265       <arg value="../svnbook.pdf"/>
266     </java>
267     <delete dir="build/zh_CN/pdf"/>
268   </target>
269 </project>