micro code cleaning
[iDMC.git] / build.xml
blob56441cdb5d49f91aa79b1354ec680d9176488570
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,2007 -->
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.5"/>
17     <property name="libVersion" value="0.6.1"/>
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-${libVersion}-Source/build/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}/jidmclib.so"/>
37     <property name="idmclib.lib.win" value="${idmclib.src}/jidmclib.dll"/>
38     <property name="jar_file"      value="${basedir}/iDmc-${version}.jar"/>
40 <!--              -->
41 <!-- work targets -->
42 <!--              -->
44     <!--      -->
45     <!-- init -->
46     <!--      -->
47     <target name="init" depends="version">
48             <tstamp/>
49         <mkdir dir="${build}"/>
50     </target>
52         
53     <!--     -->
54     <!-- all -->
55     <!--     -->
56     <target name="all"
57                 description="compiles and creates all the archives (source and binary)"
58                 depends="all-linux, all-win"/>
60     <!--           -->
61     <!-- all-linux -->
62     <!--           -->
63     <target name="all-linux"
64                 description="compiles and creates all the bonary archives"
65                 depends="tar-dist, zip-dist-linux, tar-src, zip-src"/>
68     <!--         -->
69     <!-- all-win -->
70     <!--         -->
71     <target name="all-win"
72                 description="compiles and creates all the bonary archives"
73                 depends="zip-dist-win, zip-src"/>
75     <!--         -->
76     <!-- run     -->
77     <!--         -->
78     <target name="run-linux" description="run the application" depends="jar">
79         <java jar="${jar_file}" fork="true" dir="${dist}" classpath="${dist}" spawn="true"/>
80     </target>
81     <target name="run-windows" description="run the application" depends="dist-win">
82         <java jar="${jar_file}" fork="true" dir="${dist-win}" spawn="true"/>
83     </target>
85     <!--         -->
86     <!-- compile -->
87     <!--         -->
88     <target name="compile"
89                 depends="init, version"
90                 description="compile the java sources in the 'build' directory">
92         <!-- they say fork resolves some problems on Windows -->
93         <javac
94             srcdir="${src.java}"
95             destdir="${build}"
96             deprecation="yes"
97             failonerror="no"
98             fork="true"
99             target="1.4"
100             source="1.4"
101                 debug="yes"
102         >
103             <exclude name="**/junit/*"/>
104             <exclude name="**/*Test*"/>
105             
106             <sourcepath>
107                 <dirset dir="${idmclib.src}"/>
108                 <dirset dir="${jcommon.src}"/>
109                 <dirset dir="${jfreechart.src}"/>
110                 <dirset dir="${forms.src}"/>
111                 <dirset dir="${log4j.src}"/>
112             </sourcepath>
113         </javac>
114                 <!-- files used by reflection -->
115             <javac
116                 srcdir="${jcommon.src}"
117             destdir="${build}"
118             deprecation="yes"
119             failonerror="no"
120             fork="true" 
121             target="1.4"
122             source="1.4"
123             >
124                 <include name="org/jfree/resources/JCommonResources.java"/>
125                 <include name="org/jfree/ui/about/resources/AboutResources.java"/>
126         </javac>
128         <javac
129                 srcdir="${jfreechart.src}"
130             destdir="${build}"
131             deprecation="yes"
132             failonerror="no"
133             fork="true" 
134             target="1.4"
135             source="1.4"
136         >
137                 <include name="org/jfree/chart/resources/JFreeChartResources.java"/>
138                 <include name="org/jfree/resources/JCommonResources.java"/>
139         </javac>
141         <!-- copy the localization bundles -->
142         <copy todir="${build}">
143                 <fileset dir="${jcommon.src}">
144                         <include name="**/LocalizationBundle.properties"/>
145                 </fileset>
146                 <fileset dir="${jfreechart.src}">
147                         <include name="**/LocalizationBundle.properties"/>
148                 </fileset>
149         </copy>
151     </target>
152     
153     <target name="version">
154         <copy file="${basedir}/Version.template"
155             tofile="${basedir}/${src.java}/org/tsho/dmc2/Version.java">
156           <filterchain>
157               <replacetokens begintoken=" " endtoken=" ">
158                   <token key="versionAnchor" value="&quot;${version}&quot;" />
159               </replacetokens>
160           </filterchain>
161         </copy>
162     </target>
165     <!--     -->
166     <!-- jar -->
167     <!--     -->
168     <target name="jar"
169             depends="compile"
170             description="create the jarfile in the base directory">
171         <jar jarfile="${jar_file}"
172              basedir="${build}"
173              index="yes"
174              manifest="${src.java}/org/tsho/dmc2/dmc2.manifest">
175         </jar>
176     </target>
179     <!--            -->
180     <!-- dist-linux -->
181     <!--            -->
182     <target name="dist-linux"
183             depends="jar"
184             description="populate the linux distribuition directory">
185                         
186         <copy failonerror="true"
187             file="${idmclib.lib.unix}/"
188             todir="${dist}"
189           overwrite="yes"/>
191         <copy failonerror="true"
192               file="${jar_file}/"
193               todir="${dist}"
194               overwrite="yes"/>
196         <copy failonerror="true"
197               file="${basedir}/README"
198               todir="${dist}"
199               overwrite="yes"/>
201         <copy failonerror="true"
202               file="${basedir}/COPYING"
203               todir="${dist}"
204               overwrite="yes"/>
206         <copy failonerror="true"
207               file="${basedir}/logo_new.jpg"
208               todir="${dist}"
209               overwrite="yes"/>
211         <mkdir dir="${dist}/doc"/>
212         <fixcrlf srcdir="${doc}"
213                 destdir="${dist}/doc"
214                 eol="lf"
215                 eof="remove"
216         />
219         <mkdir dir="${dist}/models"/>
221         <fixcrlf srcdir="${models}"
222                  destdir="${dist}/models"
223                  eol="lf"
224                  eof="remove"
225         />
227         <fixcrlf srcdir="${dist}"
228                  eol="lf"
229                  eof="remove"
230                  includes="README"
231         />
233         <fixcrlf srcdir="${dist}"
234                  eol="lf"
235                  eof="remove"
236                  includes="COPYING"
237         />
238     </target>
240     <target name="dist-win"
241             depends="jar"
242             description="populate the windows distribuition directory">
243                         
244         <copy failonerror="true"
245             file="${idmclib.lib.win}"
246             todir="${dist-win}"
247         overwrite="yes"/>
249         <copy failonerror="true"
250               file="${jar_file}/"
251               todir="${dist-win}"
252               overwrite="yes"/>
254         <copy failonerror="true"
255               file="${basedir}/README"
256               todir="${dist-win}"
257               overwrite="yes"/>
259         <copy failonerror="true"
260               file="${basedir}/COPYING"
261               todir="${dist-win}"
262               overwrite="yes"/>
264         <copy failonerror="true"
265               file="${basedir}/logo_new.jpg"
266               todir="${dist-win}"
267               overwrite="yes"/>         
269         <mkdir dir="${dist-win}/doc"/>
270         <fixcrlf srcdir="${doc}"
271                  destdir="${dist-win}/doc"
272                  eol="crlf"
273                  eof="remove"
274         />
276         <mkdir dir="${dist-win}/models"/>
278         <fixcrlf srcdir="${models}"
279                  destdir="${dist-win}/models"
280                  eol="crlf"
281                  eof="remove"
282         />
284         <fixcrlf srcdir="${dist-win}"
285                  eol="crlf"
286                  includes="README"
287         />
288         <fixcrlf srcdir="${dist-win}"
289                  eol="crlf"
290                  includes="COPYING"
291         />
292     </target>
295     <!--         -->
296     <!-- javadoc -->
297     <!--         -->
298     <target name="javadoc">
299         <delete dir="${javadoc}" />
300         <mkdir dir="${javadoc}" />
302         <javadoc sourcepath="."
303                  classpath="."
304                 destdir="${javadoc}"
305                 doctitle="Dynamical Model Cruncher 2 (version ${version})">
306             <packageset dir="${src.java}" defaultexcludes="no"/>
307         </javadoc>
309     </target>
312 <!--               -->
313 <!-- clean targets -->
314 <!--               -->
317     <!--           -->
318     <!-- clean-all -->
319     <!--           -->
320     <target name="clean-all"
321                 depends="clean-build, clean-dist, clean-javadoc, clean-archives"
322                 description="clean-build, clean-dist, clean-javadoc, clean-archives"/>
325     <!--             -->
326     <!-- clean-build -->
327     <!--             -->
328     <target name="clean-build"
329                 description="remove the build directory">
330         <delete dir="${build}"/>
331         <delete file="${src.java}/org/tsho/dmc2/Version.java"/>
332     </target>
334     <!--            -->
335     <!-- clean-dist -->
336     <!--            -->
337     <target name="clean-dist"
338                 description="remove the distribution directory">
339         <delete dir="${dist}"/>
340         <delete dir="${dist-win}"/>
341     </target>
344     <!--               -->
345     <!-- clean-javadoc -->
346     <!--               -->
347     <target name="clean-javadoc" 
348                 description="remove the javadoc directory" >
349         <delete dir="${javadoc}"/>
350     </target>
352     <!--                -->
353     <!-- clean-archives -->
354     <!--                -->
355     <target name="clean-archives"
356                 description="remove the archives (*.bz2, *.zip)" >
357         <delete>
358                 <fileset dir="${basedir}" includes="*.bz2"/>
359                 <fileset dir="${basedir}" includes="*.zip"/>
360                 <fileset dir="${basedir}" includes="*.jar"/>
361                 <fileset dir="${basedir}" includes="*.exe"/>
362         </delete>
363     </target>
366     <!--             -->
367     <!-- clean-stale -->
368     <!--             -->
369     <target name="clean-stale"
370                 description="clean up stale .class files in src" >
371             <delete>
372                 <fileset dir="${src.java}" includes="**/*.class"/>
373             </delete>
374     </target>  
377 <!--                 -->
378 <!-- archive targets -->
379 <!--                 -->
381     <!-- sources patternset -->
382     <patternset id="sources">
383         <exclude name="**/*.aux"/>
384         <exclude name="**/*.dvi"/>
385         <exclude name="**/*.log"/>
386         <exclude name="doc/snapshots/"/>
387         <exclude name="build-eclipse/"/>
388         <exclude name="${javadoc}/"/>
389         <exclude name="${build}/"/>
390         <exclude name="${dist}/"/>
391         <exclude name="${dist-win}/"/>
392         <exclude name="**/.*"/>
393         <exclude name="**/*.class"/>
394         <exclude name="**/*.o"/>
395         <exclude name="**/*.d"/>
396         <exclude name="**/*.so"/>
397         <exclude name="**/*.dll"/>
398         <exclude name="**/*.jar"/>
399         <exclude name="**/*.tar*"/>
400         <exclude name="**/*.zip"/>
401         <exclude name="**/*.exe"/>
402     </patternset>
405     <!--         -->
406     <!-- tar-src -->
407     <!--         -->
408     <target name="tar-src" 
409                 description="create the source tar archive">
411         <property name="prefix" value="${name}-${version}"/>
413         <tar destfile="${name}-${version}-src.tar.bz2"
414              compression="bzip2">
416         <tarfileset dir="${basedir}" prefix="${prefix}">
417             <patternset refid="sources"/>
418         </tarfileset>
420         </tar>
422     </target>  
425     <!--          -->
426     <!-- tar-dist -->
427     <!--          -->
428     <target name="tar-dist" 
429             depends="dist-linux"
430             description="create the distribution tar archive">
432         <property name="prefix" value="${name}-${version}"/>
434         <tar destfile="${name}-${version}-bin.tar.bz2"
435              compression="bzip2">
437         <tarfileset dir="${dist}" prefix="${prefix}"/>
439         </tar>
441     </target>  
444     <!--         -->
445     <!-- zip-src -->
446     <!--         -->
447     <target name="zip-src" 
448             description="create the source zip archive">
450         <zip destfile="${name}-${version}-src.zip">
452             <zipfileset dir="${basedir}"
453                         prefix="${name}-${version}">
454                 <patternset refid="sources"/>
455             </zipfileset>
457         </zip>
459     </target> 
462     <!--                -->
463     <!-- zip-dist-linux -->
464     <!--                -->
465     <target name="zip-dist-linux"
466             description="create the linux distribution zip archive"
467             depends="dist-linux">
469         <zip destfile="${name}-${version}-linux.zip">
470             <zipfileset dir="${dist}"
471                         prefix="${name}-${version}"
472             />
473         </zip>
475     </target>  
478     <!--              -->
479     <!-- zip-dist-win -->
480     <!--              -->
481     <target name="zip-dist-win"
482             description="create the windows distribution zip archive"
483             depends="dist-win">
485         <zip destfile="${name}-${version}-win.zip">
486             <zipfileset dir="${dist-win}"
487                         prefix="${name}-${version}"
488             />
489         </zip>
491     </target>  
494     <!--                     -->
495     <!-- cross-win-installer -->
496     <!--                     -->
497     <target name="cross-win-installer"
498             description="create the windows installer package from linux with wine"
499             depends="dist-win">
501         <copy failonerror="true"
502               file="${basedir}/misc/dmcDue.nsi"
503               todir="${dist-win}"
504               overwrite="yes"/>
506         <exec os="Linux"
507               dir="dist-win"
508               executable="wine">
510               <arg value="/opt/NSIS-2.0/makensis.exe"/>
511               <arg value="dmcDue.nsi"/>
512         </exec>
514         <move failonerror="true"
515               todir="${basedir}"
516               overwrite="yes">
518             <fileset dir="${dist-win}">
519                 <include name="**/*.exe"/>
520             </fileset>
521         </move>
522      </target>  
524 </project>