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"/>
10 <fileset dir="${fop.home}">
11 <include name="**/*.jar"/>
13 <fileset dir="${usr.share.java}">
14 <include name="**/*.jar"/>
19 <echo message="Use the -projecthelp option instead"/>
22 <target name="clean" description="Clean the build directory">
24 <delete file="stylesheets/html-import.xsl"/>
25 <delete file="stylesheets/chm-import.xsl"/>
26 <delete file="stylesheets/fo-import.xsl"/>
29 <target name="clean-svn">
31 <fileset dir="${basedir}" excludes="**/.svn"/>
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">
41 <available classname="com.icl.saxon.StyleSheet" classpathref="lib.classpath"/>
44 <fail message="Saxon 6.5 Support NOT Present !" unless="saxon.present"/>
46 <echo message="java.version: ${java.version}"/>
49 <target name="all" description="Generate document - pdf,html,chm">
50 <antcall target="pdf"/>
51 <antcall target="html"/>
52 <antcall target="chm"/>
55 <target name="pot.init" depends="init">
56 <uptodate property="pot.isUpToDate" targetfile="po/book.pot">
57 <srcfiles dir="source" includes="book.xml"/>
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"/>
67 <arg value="book.pot"/>
68 <arg value="../source/book.xml"/>
71 <echo message="Merging zh_CN.po ..."/>
72 <exec dir="${basedir}/po" executable="msgmerge">
73 <arg value="--no-wrap"/>
75 <arg value="zh_CN-tmp.po"/>
76 <arg value="zh_CN.po"/>
77 <arg value="book.pot"/>
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"/>
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"/>
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"/>
99 <arg value="../po/zh_CN.po"/>
101 <arg value="../build/zh_CN/book-tmp.xml"/>
102 <arg value="../source/book.xml"/>
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"/>
112 <delete file="xml2po/.xml2po.mo"/>
113 <delete file="build/zh_CN/book-tmp.xml"/>
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"/>
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"/>
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"/>
138 <touch file="build/zh_CN/svnbook/.done"/>
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"/>
148 <!--Total time: 53 seconds-->
149 <target name="chm" depends="translate,chm.init" unless="chm.isUpToDate" description="Generate document - chm">
153 <os family="windows"/>
156 This target only work on windows !
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"/>
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"/>
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"/>
181 <exec dir="${basedir}/build/zh_CN" executable="hhc" failonerror="false">
182 <arg value="htmlhelp.hhp"/>
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"/>
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"/>
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"/>
208 <arg value="build/zh_CN/pdf/book-tmp.fo"/>
210 <arg value="build/zh_CN/book.xml"/>
212 <arg value="stylesheets/zh_CN/fo.xsl"/>
214 <java classname="com.icl.saxon.StyleSheet" fork="true" maxmemory="1024m" failonerror="true" dir="${basedir}">
215 <classpath refid="lib.classpath"/>
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"/>
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"/>
229 <delete dir="build/zh_CN/pdf"/>
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"/>
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"/>
246 <copy todir="build/zh_CN/pdf">
247 <fileset dir="${fop.home}/conf">
248 <include name="*.xml"/>
250 <fileset dir="${fonts.dir}">
251 <include name="*.ttf"/>
252 <include name="*.ttc"/>
254 <fileset dir="build/zh_CN">
255 <include name="svnbook.fo"/>
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"/>
263 <arg value="userconfig.xml"/>
264 <arg value="svnbook.fo"/>
265 <arg value="../svnbook.pdf"/>
267 <delete dir="build/zh_CN/pdf"/>