initial import
[iDMC.git] / build.xml
blob870aacec7617cc78154d6ccd3914e2796aef94e6
1 <?xml version="1.0"?>
3 <!-- -->
4 <!--  Ant file for dmcDue -->
5 <!--  Written by Daniele Pizzoni <auouo@tin.it> - 2003 -->
6 <!--  Modified by Antonio, Fabio Di Narzo <antonio.fabio@gmail.com> - 2006 -->
7 <!-- -->
9 <project name="dmcDue" default="jar" basedir=".">
11 <!--            -->
12 <!-- properties -->
13 <!--            -->
15     <property name="name"    value="iDmc"/>
16     <property name="version" value="2.0.0"/>
17     <property name="libVersion" value="${version}"/>
19     <!-- directories -->
20     <property name="src.java"  value="src/java"/>
21     <property name="build"     value="build"/>
22     <property name="dist"      value="dist"/>
23     <property name="dist-win"  value="dist-win"/>
24     <property name="javadoc"   value="javadoc"/>
25     <property name="doc"                value="doc"/>
26     <property name="models"    value="models"/>
28     <!-- external sources -->
29     <property name="idmclib.src"    location="../idmclib/jidmc"/>
30     <property name="jcommon.src"    location="../jcommon-0.9.3/src"/>
31     <property name="jfreechart.src" location="../jfreechart-0.9.18/src"/>
32     <property name="forms.src"      location="../forms-1.0.3/src/jforms"/>
33     <property name="log4j.src"      location="../logging-log4j-1.2.14/src/java"/>
35                 <!-- files -->
36                 <property name="idmclib.lib.unix" value="${idmclib.src}/idmc.so"/>
37                 <property name="idmclib.lib.win" value="${idmclib.src}/idmc.dll"/>
38                 <property name="jar_file"      value="${basedir}/iDmc-${version}.jar"/>
41 <!--              -->
42 <!-- work targets -->
43 <!--              -->
45     <!--      -->
46     <!-- init -->
47     <!--      -->
48     <target name="init" depends="version">
49             <tstamp/>
50         <mkdir dir="${build}"/>
51     </target>
53         
54     <!--     -->
55     <!-- all -->
56     <!--     -->
57     <target name="all"
58                 description="compiles and creates all the archives (source and binary)"
59                 depends="all-linux, all-win"/>
61     <!--           -->
62     <!-- all-linux -->
63     <!--           -->
64     <target name="all-linux"
65                 description="compiles and creates all the bonary archives"
66                 depends="tar-dist, zip-dist-linux, tar-src, zip-src"/>
69     <!--         -->
70     <!-- all-win -->
71     <!--         -->
72     <target name="all-win"
73                 description="compiles and creates all the bonary archives"
74                 depends="zip-dist-win, zip-src"/>
76     <!--         -->
77     <!-- run     -->
78     <!--         -->
79     <target name="run-linux" description="run the application" depends="jar">
80         <java jar="${jar_file}" fork="true" dir="${dist}" classpath="${dist}" spawn="true"/>
81     </target>
82     <target name="run-windows" description="run the application" depends="dist-win">
83         <java jar="${jar_file}" fork="true" dir="${dist-win}" spawn="true"/>
84     </target>
86     <!--         -->
87     <!-- compile -->
88     <!--         -->
89     <target name="compile"
90                 depends="init"
91                 description="compile the java sources in the 'build' directory">
93         <!-- they say fork resolves some problems on Windows -->
94         <javac
95             srcdir="${src.java}"
96             destdir="${build}"
97             deprecation="yes"
98             failonerror="no"
99             fork="true"
100             target="1.4"
101             source="1.4"
102                 debug="yes"
103         >
104             <exclude name="**/junit/*"/>
105             <exclude name="**/*Test*"/>
106             
107             <sourcepath>
108                                                                 <dirset dir="${idmclib.src}"/>
109                 <dirset dir="${jcommon.src}"/>
110                 <dirset dir="${jfreechart.src}"/>
111                 <dirset dir="${forms.src}"/>
112                                                                 <dirset dir="${log4j.src}"/>
113             </sourcepath>
114         </javac>
116                 <!-- files used by reflection -->
117             <javac
118                 srcdir="${jcommon.src}"
119             destdir="${build}"
120             deprecation="yes"
121             failonerror="no"
122             fork="true" 
123             target="1.4"
124             source="1.4"
125         >
126                         <include name="org/jfree/resources/JCommonResources.java"/>
127                         <include name="org/jfree/ui/about/resources/AboutResources.java"/>
128         </javac>
130         <javac
131                 srcdir="${jfreechart.src}"
132             destdir="${build}"
133             deprecation="yes"
134             failonerror="no"
135             fork="true" 
136             target="1.4"
137             source="1.4"
138         >
139                     <include name="org/jfree/chart/resources/JFreeChartResources.java"/>
140                     <include name="org/jfree/resources/JCommonResources.java"/>
141         </javac>
143                 <!-- copy the localization bundles -->
144                 <copy todir="${build}">
145                         <fileset dir="${jcommon.src}">
146                                 <include name="**/LocalizationBundle.properties"/>
148                         </fileset>
149                         <fileset dir="${jfreechart.src}">
150                                 <include name="**/LocalizationBundle.properties"/>
151                         </fileset>
152                 </copy>
154     </target>
156         <target name="version">
157                 <copy file="${basedir}/Version.template"
158  tofile="${basedir}/${src.java}/org/tsho/dmc2/Version.java">
159                   <filterchain>
160                                 <replacetokens begintoken=" " endtoken=" ">
161                                 <token key="versionAnchor" value="&quot;${version}&quot;" />
162                                 </replacetokens>        
163                   </filterchain>
164                 </copy>         
165         </target>
168     <!--     -->
169     <!-- jar -->
170     <!--     -->
171     <target name="jar"
172             depends="compile"
173             description="create the jarfile in the base directory">
174         <jar jarfile="${jar_file}"
175              basedir="${build}"
176              index="yes"
177              manifest="${src.java}/org/tsho/dmc2/dmc2.manifest">
178         </jar>
179     </target>
182     <!--            -->
183     <!-- dist-linux -->
184     <!--            -->
185     <target name="dist-linux"
186             depends="jar"
187             description="populate the linux distribuition directory">
188                         
189                         <copy failonerror="true"
190                                                 file="${idmclib.lib.unix}/"
191                                                 todir="${dist}"
192                       overwrite="yes"/>
194                 <copy failonerror="true"
195                       file="${jar_file}/"
196                       todir="${dist}"
197                       overwrite="yes"/>
199                 <copy failonerror="true"
200                       file="${basedir}/README"
201                       todir="${dist}"
202                       overwrite="yes"/>
204                 <copy failonerror="true"
205                       file="${basedir}/COPYING"
206                       todir="${dist}"
207                       overwrite="yes"/>
209                 <copy failonerror="true"
210                       file="${basedir}/logo_new.jpg"
211                       todir="${dist}"
212                       overwrite="yes"/>
213         
214                 <mkdir dir="${dist}/doc"/>
215                 <fixcrlf srcdir="${doc}"
216                         destdir="${dist}/doc"
217                         eol="lf"
218                         eof="remove"
219                 />
220         
221                 
222                 <mkdir dir="${dist}/models"/>
224                 <fixcrlf srcdir="${models}"
225                          destdir="${dist}/models"
226                          eol="lf"
227                          eof="remove"
228                 />
230                 <fixcrlf srcdir="${dist}"
231                          eol="lf"
232                          eof="remove"
233                          includes="README"
234                 />
236                 <fixcrlf srcdir="${dist}"
237                          eol="lf"
238                          eof="remove"
239                          includes="COPYING"
240                 />
242     </target>
244     <target name="dist-win"
245             depends="jar"
246             description="populate the windows distribuition directory">
247                         
248                         <copy failonerror="true"
249                                                 file="${idmclib.lib.win}"
250                                                 todir="${dist-win}"
251                       overwrite="yes"/>
253                 <copy failonerror="true"
254                       file="${jar_file}/"
255                       todir="${dist-win}"
256                       overwrite="yes"/>
258                 <copy failonerror="true"
259                       file="${basedir}/README"
260                       todir="${dist-win}"
261                       overwrite="yes"/>
263                 <copy failonerror="true"
264                       file="${basedir}/COPYING"
265                       todir="${dist-win}"
266                       overwrite="yes"/>
267         
268                 <copy failonerror="true"
269                       file="${basedir}/logo_new.jpg"
270                       todir="${dist-win}"
271                       overwrite="yes"/>         
272         
273                 <mkdir dir="${dist-win}/doc"/>
274                 <fixcrlf srcdir="${doc}"
275                          destdir="${dist-win}/doc"
276                          eol="crlf"
277                          eof="remove"
278                 />
280                 <mkdir dir="${dist-win}/models"/>
282                 <fixcrlf srcdir="${models}"
283                          destdir="${dist-win}/models"
284                          eol="crlf"
285                          eof="remove"
286                 />
288                 <fixcrlf srcdir="${dist-win}"
289                          eol="crlf"
290                          includes="README"
291                 />
292                 <fixcrlf srcdir="${dist-win}"
293                          eol="crlf"
294                          includes="COPYING"
295                 />
297     </target>
300     <!--         -->
301     <!-- javadoc -->
302     <!--         -->
303 <!-- 
304     <target name="javadoc">
305         <delete dir="${javadoc}" />
306         <mkdir dir="${javadoc}" />
308         <javadoc sourcepath="."
309                  classpath="."
310                         destdir="${javadoc}"
311                         doctitle="Dynamical Model Cruncher 2 (version ${version})">
313             <packageset dir="${src.java}" defaultexcludes="no"/>
314             
315         </javadoc>
317     </target>
321 <!--               -->
322 <!-- clean targets -->
323 <!--               -->
326     <!--           -->
327     <!-- clean-all -->
328     <!--           -->
329     <target name="clean-all"
330                 depends="clean-build, clean-dist, clean-archives"
331                 description="clean-build, clean-dist, clean-javadoc, clean-archives"/>
334     <!--             -->
335     <!-- clean-build -->
336     <!--             -->
337     <target name="clean-build"
338                 description="remove the build directory">
339         <delete dir="${build}"/>
340     </target>
343     <!--            -->
344     <!-- clean-dist -->
345     <!--            -->
346     <target name="clean-dist"
347                 description="remove the distribution directory">
348         <delete dir="${dist}"/>
349                 <delete dir="${dist-win}"/>
350     </target>
353     <!--               -->
354     <!-- clean-javadoc -->
355     <!--               -->
356 <!--
357     <target name="clean-javadoc" 
358                 description="remove the javadoc directory" >
359         <delete dir="${javadoc}"/>
360     </target>
363     <!--                -->
364     <!-- clean-archives -->
365     <!--                -->
366     <target name="clean-archives"
367                 description="remove the archives (*.bz2, *.zip)" >
368         <delete>
369                 <fileset dir="${basedir}" includes="*.bz2"/>
370                 <fileset dir="${basedir}" includes="*.zip"/>
371                 <fileset dir="${basedir}" includes="*.jar"/>
372                 <fileset dir="${basedir}" includes="*.exe"/>
373         </delete>
374     </target>
377     <!--             -->
378     <!-- clean-stale -->
379     <!--             -->
380     <target name="clean-stale"
381                 description="clean up stale .class files in src" >
382             <delete>
383                 <fileset dir="${src.java}" includes="**/*.class"/>
384             </delete>
385     </target>  
388 <!--                 -->
389 <!-- archive targets -->
390 <!--                 -->
392     <!-- sources patternset -->
393     <patternset id="sources">
394         <exclude name="**/*.aux"/>
395         <exclude name="**/*.dvi"/>
396         <exclude name="**/*.log"/>
397         <exclude name="doc/snapshots/"/>
398         <exclude name="build-eclipse/"/>
399         <exclude name="${javadoc}/"/>
400         <exclude name="${build}/"/>
401         <exclude name="${dist}/"/>
402         <exclude name="${dist-win}/"/>
403         <exclude name="**/.*"/>
404         <exclude name="**/*.class"/>
405         <exclude name="**/*.o"/>
406         <exclude name="**/*.d"/>
407         <exclude name="**/*.so"/>
408         <exclude name="**/*.dll"/>
409         <exclude name="**/*.jar"/>
410         <exclude name="**/*.tar*"/>
411         <exclude name="**/*.zip"/>
412         <exclude name="**/*.exe"/>
413     </patternset>
416     <!--         -->
417     <!-- tar-src -->
418     <!--         -->
419     <target name="tar-src" 
420                 description="create the source tar archive">
422         <property name="prefix" value="${name}-${version}"/>
424         <tar destfile="${name}-${version}-src.tar.bz2"
425              compression="bzip2">
427         <tarfileset dir="${basedir}" prefix="${prefix}">
428             <patternset refid="sources"/>
429         </tarfileset>
431         </tar>
433     </target>  
436     <!--          -->
437     <!-- tar-dist -->
438     <!--          -->
439     <target name="tar-dist" 
440             depends="dist-linux"
441             description="create the distribution tar archive">
443         <property name="prefix" value="${name}-${version}"/>
445         <tar destfile="${name}-${version}-bin.tar.bz2"
446              compression="bzip2">
448         <tarfileset dir="${dist}" prefix="${prefix}"/>
450         </tar>
452     </target>  
455     <!--         -->
456     <!-- zip-src -->
457     <!--         -->
458     <target name="zip-src" 
459             description="create the source zip archive">
461         <zip destfile="${name}-${version}-src.zip">
463             <zipfileset dir="${basedir}"
464                         prefix="${name}-${version}">
465                 <patternset refid="sources"/>
466             </zipfileset>
468         </zip>
470     </target> 
473     <!--                -->
474     <!-- zip-dist-linux -->
475     <!--                -->
476     <target name="zip-dist-linux"
477             description="create the linux distribution zip archive"
478             depends="dist-linux">
480         <zip destfile="${name}-${version}-linux.zip">
481             <zipfileset dir="${dist}"
482                         prefix="${name}-${version}"
483             />
484         </zip>
486     </target>  
489     <!--              -->
490     <!-- zip-dist-win -->
491     <!--              -->
492     <target name="zip-dist-win"
493             description="create the windows distribution zip archive"
494             depends="dist-win">
496         <zip destfile="${name}-${version}-win.zip">
497             <zipfileset dir="${dist-win}"
498                         prefix="${name}-${version}"
499             />
500         </zip>
502     </target>  
505     <!--                     -->
506     <!-- cross-win-installer -->
507     <!--                     -->
508     <target name="cross-win-installer"
509             description="create the windows installer package from linux with wine"
510             depends="dist-win">
512         <copy failonerror="true"
513               file="${basedir}/misc/dmcDue.nsi"
514               todir="${dist-win}"
515               overwrite="yes"/>
517         <exec os="Linux"
518               dir="dist-win"
519               executable="wine">
521               <arg value="/opt/NSIS-2.0/makensis.exe"/>
522               <arg value="dmcDue.nsi"/>
523         </exec>
525         <move failonerror="true"
526               todir="${basedir}"
527               overwrite="yes">
529             <fileset dir="${dist-win}">
530                 <include name="**/*.exe"/>
531             </fileset>
532         </move>
533      </target>  
535 </project>