Removed the old exp4j-0.2.9.jar and corrected the build.xml to use the new exp4j...
[debian/openrocket] / core / build.xml
1 <project name="OpenRocket" basedir=".">
2
3         <property file="resources/build.properties" />
4         
5         <property name="src.dir"        value="src"/>           <!-- Source directory -->
6         <property name="src-test.dir"   value="test"/>          <!-- Test directory -->
7         <property name="build.dir"      value="build"/>         <!-- Build directory -->
8         <property name="build-test.dir" value="build/test"/><!-- Build directory -->
9                 
10         <!-- Distribution directory, from which stuff is jar'ed -->
11         <property name="dist.dir"       value="${build.dir}/dist"/> 
12         <property name="dist-test.dir"  value="${build.dir}/dist-test"/>
13         
14         <property name="classes.dir" value="${dist.dir}"/>      <!-- Directory for classes -->
15         <property name="jar.dir"     value="${build.dir}/jar"/> <!-- Directory for built jar's -->
16         <property name="lib.dir"     value="lib"/>                              <!-- Library source directory -->
17
18         <property name="pkgname"     value="${ant.project.name}-${build.version}"/>
19         
20         <property name="jar.file"    value="${jar.dir}/${ant.project.name}.jar"/>
21         <property name="dist.bin"    value="${jar.dir}/${pkgname}.jar"/>
22         <property name="dist.src"    value="${jar.dir}/${pkgname}-src.zip"/>
23         
24         <!-- The main class of the application -->
25         <property name="main-class"  value="net.sf.openrocket.startup.Startup"/>
26
27         
28         <!-- Classpath definitions -->
29         <path id="classpath">
30                 <fileset dir="${lib.dir}" includes="**/*.jar"/>
31         </path>
32         
33         <path id="test-classpath">
34                 <path refid="classpath"/>
35                 <pathelement location="${basedir}/resources"/>
36                 <pathelement location="${build-test.dir}"/>
37                 <pathelement location="${classes.dir}"/>
38                 <pathelement location="${src-test.dir}"/>
39                 <fileset dir="lib-test/" includes="*.jar"/>
40         </path>
41
42         <path id="run-classpath">
43                 <path refid="classpath"/>
44                 <pathelement location="${basedir}/resources"/>
45                 <pathelement location="${classes.dir}"/>
46         </path>
47
48         <!-- Add Ant-contrib tasks so we can use for loop -->
49         <taskdef resource="net/sf/antcontrib/antlib.xml">
50                 <classpath>
51                         <pathelement location="lib-extra/ant-contrib-1.0b3.jar"/>
52                 </classpath>
53         </taskdef>
54
55         
56         <!-- CLEAN -->
57         <target name="clean" description="Removes all build artifacts">
58                 <delete dir="${build.dir}"/>
59                 <delete dir="tmp/"/>
60         </target>
61                 
62         
63         <!-- BUILD -->
64         <target name="build">
65                 <mkdir dir="${classes.dir}"/>
66                 <echo level="info">Compiling main classes</echo>
67                 <javac debug="true" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
68         </target>
69         
70         <!-- Executible Eclipse-Jar-In-Jar style JAR -->
71         <target name="jar" depends="core-jar" description="Create the OpenRocket jar-in-jar Executable">
72                 <mkdir dir="${jar.dir}" />
73                 <jar destfile="${jar.file}">
74                         <manifest>
75                                 <attribute name="Main-Class" value="org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader" />
76                                 <attribute name="Rsrc-Main-Class" value="${main-class}" />
77                                 <attribute name="SplashScreen-Image" value="pix/splashscreen.png" />
78                                 <attribute name="Class-Path" value="." />
79                                 <attribute name="Rsrc-Class-Path" value="./ main/${ant.project.name}-Core.jar lib/jfreechart-1.0.13.jar lib/jcommon-1.0.16.jar lib/gluegen-rt.jar lib/miglayout15-swing.jar lib/iText-5.0.2.jar lib/jogl.all.jar lib/opencsv-2.3.jar lib/OrangeExtensions-1.2.jar" />
80                         </manifest>
81
82                         <!-- Unzip the Eclipse JIJ Loader -->
83                         <zipfileset src="lib/jar-in-jar-loader.jar" />
84                         
85                         <!-- Include, in the root of the JAR, the resources needed by OR -->
86                         <fileset dir="src/" includes="META-INF/" />
87                         <fileset dir="resources/" />
88                         
89                         <!-- Include the core OpenRocket JAR -->
90                         <zipfileset dir="${build.dir}/" prefix="main">
91                                 <include name="${ant.project.name}-Core.jar"/>
92                         </zipfileset>
93                         
94                         <!-- Include libraries needed by OR -->
95                         <zipfileset dir="${lib.dir}" prefix="lib">
96                                 <include name="*.jar"/>
97                         </zipfileset>
98                         <zipfileset dir="${lib.dir}/jogl" prefix="lib">
99                                 <include name="*.jar"/>
100                         </zipfileset>
101                         
102                         <!-- Include metafiles about OR -->
103                         <fileset dir="." includes="LICENSE.TXT README.TXT ChangeLog ReleaseNotes fileformat.txt" />
104                 </jar>
105         </target>
106         
107         
108         <!-- Core OpenRocket JAR -->
109         <target name="core-jar" depends="build" description="Create the OpenRocket code-only jar file">
110                 <jar destfile="${build.dir}/${ant.project.name}-Core.jar" basedir="${dist.dir}">
111                         <manifest>
112                                 <attribute name="Main-Class" value="${main-class}"/>
113                                 <attribute name="SplashScreen-Image" value="pix/splashscreen.png"/>
114                         </manifest>
115                         <zipfileset src="lib/exp4j-rdg.jar" />
116                 </jar>
117         </target>
118
119         <!-- CONVERT vendor csv to ORC files -->
120         <macrodef name="build-orc-file">
121                 <attribute name="dir"/>
122                 <attribute name="vendor"/>
123                 <sequential>
124                         <echo>Generating ORC file for vendor @{vendor}</echo>
125                         <java classname="net.sf.openrocket.preset.loader.RocksimComponentFileTranslator"
126                                 fork="true"
127                                 classpathref="run-classpath"
128                                 failonerror="true">
129                                 <arg value="@{dir}"/>
130                                 <arg value="resources/datafiles/presets/@{vendor}.orc"/>
131                         </java>
132                 </sequential>
133         </macrodef>
134
135         <target name="generate-orc-files"
136                 description="Generate ORC file from vendor csv"
137                 depends="build">
138
139                 <for param="vendor-dir">
140                         <dirset dir="resources-src/datafiles/rocksim_components"
141                                 includes="*"/>
142                         <sequential>
143                                 <propertyregex property="vendor"
144                                         override="true"
145                                         input="@{vendor-dir}"
146                                         select="\1"
147                                         regexp=".*[/\\]([^/\\]*)$"/>
148                                 <build-orc-file dir="@{vendor-dir}" vendor="${vendor}"/>
149                         </sequential>
150                 </for>
151         </target>
152         
153         <!-- DIST-SRC -->
154         <target name="dist-src">
155                 <echo>                  
156                 Building source distribution
157                 </echo>
158                 <mkdir dir="${build.dir}/${pkgname}"/>
159                 <mkdir dir="${jar.dir}"/>
160                 <copy todir="${build.dir}/${pkgname}">
161                         <fileset dir="." includes="*" excludes="*.log">
162                                 <type type="file"/>
163                         </fileset>
164                         <fileset dir="." includes="resources/ lib/ lib-test/ src/ test/"/>
165                 </copy>
166                 <zip destfile="${dist.src}" basedir="${build.dir}" includes="${pkgname}/"/>
167                 <delete dir="${build.dir}/${pkgname}"/>
168         </target>
169         
170         
171         <!-- DIST-SRC-TEST -->
172         <target name="dist-src-test" depends="dist-src">
173                 <echo>
174                 Testing source distribution
175                 </echo>
176                 <delete dir="${dist-test.dir}"/>
177                 <mkdir dir="${dist-test.dir}"/>
178                 <unzip dest="${dist-test.dir}" src="${dist.src}"/>
179                 <ant dir="${dist-test.dir}/${pkgname}" antfile="build.xml" target="jar"/>
180                 <ant dir="${dist-test.dir}/${pkgname}" antfile="build.xml" target="unittest"/>
181                 <delete dir="${dist-test.dir}"/>
182                 <echo>
183                 Source distribution test successful
184                 </echo>
185         </target>       
186         
187         
188         <!-- DIST-BIN -->
189         <target name="dist-bin" depends="check,clean,unittest,jar">
190                 <move file="${jar.file}" tofile="${dist.bin}"/>
191         </target>
192
193         
194         <!-- DIST -->
195         <target name="dist" depends="dist-bin,dist-src,dist-src-test">
196                 <echo>Distribution ${build.version} (${build.source}) built into directory ${jar.dir}</echo>
197         </target>
198         
199         
200         <!-- CHECK -->
201         <target name="check" depends="checktodo,checkascii"/>
202         
203         <!-- CHECK TODOs -->
204         <target name="todo" depends="checktodo"/>
205         <target name="checktodo">
206                 <tempfile property="todo.file" prefix="checktodo-"/>
207                 <echo>Checking project for FIXMEs.</echo>
208                 <concat destfile="${todo.file}">
209                         <fileset dir="${src.dir}">
210                             <include name="**/*.java"/>
211                         </fileset>
212                         <fileset dir="${src-test.dir}">
213                             <include name="**/*.java"/>
214                         </fileset>
215                         <filterchain>
216                                 <linecontainsregexp>
217                                         <regexp pattern="(FIXME|TODO:.*CRITICAL)"/>
218                                 </linecontainsregexp>
219                         </filterchain>
220                 </concat>
221                 <loadfile srcfile="${todo.file}" property="criticaltodos"/>
222                 <delete file="${todo.file}"/>
223                 <fail if="criticaltodos">CRITICAL TODOs exist in project:
224 ${criticaltodos}</fail>
225                 <echo>No critical TODOs in project.</echo>
226         </target>
227         
228         
229         <!-- CHECK TODOs -->
230         <target name="ascii" depends="checkascii"/>
231         <target name="checkascii">
232                 <tempfile property="ascii.file" prefix="checkascii-"/>
233                 <echo>Checking project for non-ASCII characters.</echo>
234                 <concat destfile="${ascii.file}">
235                         <fileset dir="${src.dir}">
236                             <include name="**/*.java"/>
237                         </fileset>
238                         <fileset dir="${src-test.dir}">
239                             <include name="**/*.java"/>
240                         </fileset>
241                         <filterchain>
242                                 <linecontainsregexp>
243                                         <regexp pattern="\P{ASCII}"/>
244                                 </linecontainsregexp>
245                         </filterchain>
246                 </concat>
247                 <loadfile srcfile="${ascii.file}" property="nonascii"/>
248                 <delete file="${ascii.file}"/>
249                 <fail if="nonascii">Non-ASCII characters exist in project:
250 ${nonascii}</fail>
251                 <echo>No non-ASCII characters in project.</echo>
252         </target>
253         
254         
255         <!--  Unit tests  -->
256         <target name="unittest" description="Execute unit tests" depends="build">
257                 <echo>Building unit tests</echo>
258                 <mkdir dir="${build-test.dir}"/>
259                 <javac debug="true" srcdir="${src-test.dir}" destdir="${build-test.dir}" classpathref="test-classpath"/>
260                 
261                 <echo>Running unit tests</echo>
262                 <mkdir dir="tmp/rawtestoutput"/>
263                 <junit fork="yes" forkmode="once" printsummary="false" failureproperty="junit.failure">
264                         <classpath>
265                                 <path refid="test-classpath"/>
266                                 <path location="${basedir}"/>
267                         </classpath>
268                         <batchtest todir="tmp/rawtestoutput">
269                                 <fileset dir="${build-test.dir}">
270                                         <include name="**/Test*.class" />
271                                         <include name="**/*Test.class" />
272                                         <exclude name="**/*$*.class" />
273                                         <exclude name="Test.class" />
274                                 </fileset>
275                                 <formatter type="xml"/>
276                         </batchtest>
277                 </junit>
278                 <junitreport todir="tmp">
279                         <fileset dir="tmp/rawtestoutput"/>
280                         <report todir="tmp/test-reports"/>
281                 </junitreport>
282                 <fail if="junit.failure" message="Unit test(s) failed.  See report in ${basedir}/tmp/test-reports/index.html"/>
283                 <echo>
284         Unit tests passed successfully.
285                 </echo>
286         </target>
287     
288 </project>