OSDN Git Service

b3d722f6ee4731948a0444dde89985140da76016
[neighbornote/NeighborNote.git] / build.xml
1 <?xml version='1.0' encoding='utf-8'?>
2 <project default="jar" basedir=".">
3   <!-- program name -->
4   <property name="project.name" value="nevernote"/>
5   <property name="application.name" value="sandbox"/>
6
7   <!-- targeted QtJambi library version  -->
8   <property name="qtjambi.ver" value="4.6.3"/>
9
10   <!-- project directory hierarchy -->
11   <property name="src.dir" value="src"/>
12   <property name="classes.dir" value="build"/>
13   <property name="dist.dir" value="dist"/>
14   <property name="lib.dir" value="lib"/>
15   <property name="bin.dir" value="bin"/>
16   <property name="doc.dir" value="doc"/>
17   <property name="tr.dir" value="translations"/>
18
19   <!-- needed for running -->
20   <property name="db.dir" value="db"/>
21   <property name="logs.dir" value="logs"/>
22
23   <!-- debug -->
24   <property name="javac.debug" value="true"/>
25
26   <!-- run parameter -->
27   <!-- heap -->
28   <property name="jvm.xms" value="256M"/><!-- initial memory size -->
29   <property name="jvm.xmm" value="512M"/><!-- maximum memory size -->
30   <property name="jvm.newratio" value="2"/>
31   <property name="jvm.gcs" value="incgc"/><!-- GC strategy -->
32
33   <!-- product jar file -->
34   <property name="jar.name" value="nevernote.jar"/>
35
36   <!-- product exec command -->
37   <property name="shell.command" value="nevernote.sh"/>
38   <property name="bat.command" value="nevernote.bat"/>
39
40   <!-- qt utils -->
41   <property name="linguist.update" value="lupdate"/>
42   <property name="linguist.release" value="lrelease"/>
43
44   <!-- translations -->
45   <property name="linguist.project" value="nevernote.pro"/>
46
47   <!-- documents -->
48   <property name="doc.changelog" value="changelog.txt"/>
49   <property name="doc.release" value="release.txt"/>
50   <property name="doc.readme" value="README.txt"/>
51
52   <!-- check os -->
53   <condition property="isWindows">
54       <os family="windows" />
55   </condition>
56   <condition property="isLinux">
57       <os name="Linux" arch="i386" />
58   </condition>
59   <condition property="isLinux64">
60       <os name="Linux" arch="amd64" />
61   </condition>
62   <condition property="isMacOSX">
63       <os name="Mac OS X" />
64   </condition>
65
66   <!-- flexible looking for qtjambi library path -->
67   <target name="set-jambi-path32" depends="set-jambi-path" unless="qtlib.dir">
68       <available file="../qtjambi-linux32-lgpl-${qtjambi.ver}"
69                  property="qtlib.dir" value="../qtjambi-linux32-lgpl-${qtjambi.ver}"/>
70       <available file="../qtjambi-linux32-community-${qtjambi.ver}"
71                  property="qtlib.dir" value="../qtjambi-linux32-community-${qtjambi.ver}"/>
72   </target>
73   <target name="set-jambi-path64" depends="set-jambi-path" unless="qtlib.dir">
74       <available file="../qtjambi-linux64-lgpl-${qtjambi.ver}"
75                  property="qtlib.dir" value="../qtjambi-linux64-lgpl-${qtjambi.ver}"/>
76       <available file="../qtjambi-linux64-community-${qtjambi.ver}"
77                  property="qtlib.dir" value="../qtjambi-linux64-community-${qtjambi.ver}"/>
78   </target>
79   <target name="set-jambi-pathmac" depends="set-jambi-path" unless="qtlib.dir">
80       <available file="../qtjambi-macosx-lgpl-${qtjambi.ver}"
81                  property="qtlib.dir" value="../qtjambi-macosx-lgpl-${qtjambi.ver}"/>
82       <available file="../qtjambi-macosx-community-${qtjambi.ver}"
83                  property="qtlib.dir" value="../qtjambi-macosx-community-${qtjambi.ver}"/>
84   </target>
85   <target name="set-jambi-path" unless="qtlib.dir">
86       <available file="${user.home}/lib/qtjambi/qtjambi-${qtjambi.ver}.jar" 
87                  property="qtlib.dir" value="${user.home}/lib/qtjambi"/>
88       <available file="${user.home}/lib/qtjambi-${qtjambi.ver}.jar" 
89                  property="qtlib.dir" value="${user.home}/lib"/>
90       <available file="lib/qtjambi-${qtjambi.ver}.jar"
91                  property="qtlib.dir" value="lib"/>
92   </target>
93
94   <!-- os dependent library path and lib file -->
95   <target name="check_syslib_path" depends="lib-if_windows, lib-if_linux, lib-if_linux64"/>
96
97   <target name="lib-if_windows" if="isWindows">
98       <property name="system.lib.dir" value="D:/NeverNote/lib"/>
99       <property name="qtlib.dir" value="D:/qtjambi-${qtjambi.ver}"/>
100       <property name="qtjambi-platform" value="win32-msvc2005"/>
101   </target>
102
103   <target name="lib-if_linux" depends="set-jambi-path32" if="isLinux">
104       <property name="system.lib.dir" value="/usr/share/java"/>
105       <property name="qtjambi.platform" value="linux32-gcc"/>
106       <echo message="use qtjambi library at ${qtlib.dir}"/>
107   </target>
108   <target name="lib-if_linux64" depends="set-jambi-path64" if="isLinux64">
109       <property name="system.lib.dir" value="/usr/share/java"/>
110       <property name="qtjambi.platform" value="linux64-gcc"/>
111       <echo message="use qtjambi library at ${qtlib.dir}"/>
112   </target>
113   <target name="lib-if_macosx" depends="set-jambi-pathmac" if="isMacOSX">
114       <property name="system.lib.dir" value="/Library/Java/Extensions"/>
115       <property name="qtjambi.platform" value="macosx-gcc"/>
116       <echo message="use qtjambi library at ${qtlib.dir}"/>
117   </target>
118
119   <!-- compiler classpath -->
120   <target name="set_classpath" depends="check_syslib_path">
121     <path id="java.classpath">
122       <!-- bundled library -->
123       <pathelement location="${lib.dir}/evernote.jar"/>
124       <pathelement location="${lib.dir}/libthrift.jar"/>
125       <pathelement location="${lib.dir}/PDFRenderer.jar"/>
126       <pathelement location="${lib.dir}/log4j-1.2.14.jar"/>
127       <pathelement location="${lib.dir}/h2-1.2.136.jar"/>
128       <pathelement location="${lib.dir}/commons-lang-2.4.jar"/>
129       <!-- dependent library -->
130       <pathelement location="${qtlib.dir}/qtjambi-${qtjambi.ver}.jar"/>
131       <pathelement location="${qtlib.dir}/qtjambi-${qtjambi.platform}-${qtjambi.ver}.jar"/>
132       <pathelement location="${qtlib.dir}/qtjambi-util-${qtjambi.ver}.jar"/>
133     </path>
134   </target>
135
136   <target name="init" depends="set_classpath">
137     <tstamp/>
138     <mkdir dir="${classes.dir}"/>
139   </target>
140
141   <!-- translate -->
142   <target name="update-tr" depends="update-tr-if_linux, update-tr-if_linux64, update-tr-if_windows"/>
143   <target name="update-tr-if_windows" depends="init" if="isWindows">
144     <exec dir="." executable="cmd" os="Windows NT">
145         <arg line="/c ${bin.dir}\${linguist.update} ${linguist.project}"/>
146     </exec>
147   </target>
148   <target name="update-tr-if_linux" depends="init" if="isLinux">
149     <exec executable="${linguist.update}">
150         <arg line="${linguist.project}"/>
151     </exec>
152   </target>
153   <target name="update-tr-if_linux64" depends="init" if="isLinux64">
154     <exec executable="${linguist.update}">
155         <arg line="${linguist.project}"/>
156     </exec>
157   </target>
158
159   <target name="release-tr" depends="release-tr-if_linux, release-tr-if_linux64, release-tr-if_windows"/>
160   <target name="release-tr-if_windows" depends="init" if="isWindows">
161     <exec dir="." executable="cmd" os="Windows NT">
162         <arg line="/c ${bin.dir}\${linguist.release} ${linguist.project}"/>
163     </exec>
164   </target>
165   <target name="release-tr-if_linux" depends="init" if="isLinux">
166     <exec executable="${linguist.release}">
167         <arg line="${linguist.project}"/>
168     </exec>
169   </target>
170   <target name="release-tr-if_linux64" depends="init" if="isLinux64">
171     <exec executable="${linguist.release}">
172         <arg line="${linguist.project}"/>
173     </exec>
174   </target>
175
176   <!-- build -->
177   <target name="compile" depends="init">
178     <javac srcdir="${src.dir}"
179        destdir="${classes.dir}"
180        debug="${javac.debug}">
181        <classpath refid="java.classpath"/>
182     </javac>
183   </target>
184
185   <target name="resources" depends="init,release-tr">
186       <mkdir dir="${classes.dir}/cx/fbn/nevernote/icons"/>
187       <copy todir="${classes.dir}/cx/fbn/nevernote/icons">
188           <fileset dir="${src.dir}/cx/fbn/nevernote/icons"/>
189       </copy>
190       <copy file="${src.dir}/com/swabunga/spell/engine/configuration.properties"
191             todir="${classes.dir}/com/swabunga/spell/engine/"/>
192       <mkdir dir="${classes.dir}/translations"/>
193       <copy todir="${classes.dir}/translations">
194           <fileset file="translations/*.qm"/>
195       </copy>
196   </target>
197
198   <target name="jar" depends="compile,resources,release-tr">
199     <jar destfile="${jar.name}" basedir="${classes.dir}"/>
200   </target>
201
202   <!-- make distribution -->
203   <target name="dist-init" depends="init">
204     <mkdir dir="${dist.dir}"/>
205     <mkdir dir="${dist.dir}/lib"/>
206     <mkdir dir="${dist.dir}/bin"/>
207     <mkdir dir="${dist.dir}/doc"/>
208     <mkdir dir="${dist.dir}/db"/>
209     <mkdir dir="${dist.dir}/logs"/>
210   </target>
211
212   <target name="dist" depends="jar, dist-init">
213      <copy file="${bin.dir}/${shell.command}" todir="${dist.dir}/bin"/>
214      <copy file="${bin.dir}/${bat.command}" todir="${dist.dir}/bin"/>
215      <copy todir="${dist.dir}/lib">
216        <fileset file="${jar.name}"/>
217        <fileset dir="${lib.dir}"/>
218      </copy>
219      <copy todir="${dist.dir}/doc">
220        <fileset file="${doc.changelog}"/>
221        <fileset file="${doc.release}"/>
222        <fileset file="${doc.readme}"/>
223        <fileset dir="${doc.dir}"/>
224      </copy>
225      <exec dir="dist" executable="tar">
226          <arg line="czf ../../nevernote-bin.tar.gz ."/>
227      </exec>
228   </target>
229
230   <!-- test run -->
231   <target name="run-init" depends="init, resources, jar">
232     <tstamp/>
233     <mkdir dir="${logs.dir}"/>
234     <mkdir dir="${db.dir}"/>
235     <mkdir dir="res"/>
236   </target>
237
238   <target name="run" depends="run-init">
239     <java classname="cx.fbn.nevernote.NeverNote"
240       fork="yes" maxmemory="${jvm.xmm}"
241       classpathref="java.classpath" classpath="${jar.name}">
242       <jvmarg value="-XX:NewRatio=${jvm.newratio}"/>
243       <jvmarg value="-X${jvm.gcs}"/>
244       <arg value="--name=${application.name}"/>
245     </java>
246   </target>
247
248   <!-- script test run -->
249   <target name="run-script" depends="run-if_windows, run-if_linux, run-if_linux64"
250    description="run starter script">
251   </target>
252
253   <target name="run-if_windows" depends="run-init" if="isWindows">
254     <exec dir="." executable="cmd" os="Windows NT">
255         <arg line="/c ${bin.dir}\${batch.command}"/>
256     </exec>
257   </target>
258   <target name="run-if_linux" depends="run-init" if="isLinux">
259     <exec executable="${bin.dir}/${shell.command}"/>
260   </target>
261   <target name="run-if_linux64" depends="run-init" if="isLinux64">
262     <exec executable="${bin.dir}/${shell.command}"/>
263   </target>
264
265   <!-- clean up -->
266   <target name="clean"
267    description="clean up without classes and run env" >
268     <delete dir="${dist.dir}" />
269     <delete file="${jar.name}"/>
270   </target>
271
272   <target name="all-clean" depends="clean"
273    description="clean up all" >
274     <delete dir="${classes.dir}" />
275     <delete dir="${logs.dir}" />
276     <delete dir="${db.dir}" />
277     <delete file="secure.txt"/>
278     <delete>
279           <fileset file="${tr.dir}/*.qm"/>
280           <fileset file="${tr.dir}/*.po"/>
281     </delete>
282     <delete dir="res"/>
283   </target>
284
285 </project>