1 <project name="OpenRocket" basedir=".">
3 <property file="resources/build.properties" />
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 -->
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"/>
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 -->
18 <property name="pkgname" value="${ant.project.name}-${build.version}"/>
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"/>
24 <!-- The main class of the application -->
25 <property name="main-class" value="net.sf.openrocket.startup.Startup"/>
28 <!-- Classpath definitions -->
30 <fileset dir="${lib.dir}" includes="**/*.jar"/>
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"/>
42 <path id="run-classpath">
43 <path refid="classpath"/>
44 <pathelement location="${basedir}/resources"/>
45 <pathelement location="${classes.dir}"/>
48 <!-- Add Ant-contrib tasks so we can use for loop -->
49 <taskdef resource="net/sf/antcontrib/antlib.xml">
51 <pathelement location="lib-extra/ant-contrib-1.0b3.jar"/>
57 <target name="clean" description="Removes all build artifacts">
58 <delete dir="${build.dir}"/>
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"/>
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}">
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" />
82 <!-- Unzip the Eclipse JIJ Loader -->
83 <zipfileset src="lib/jar-in-jar-loader.jar" />
85 <!-- Include, in the root of the JAR, the resources needed by OR -->
86 <fileset dir="src/" includes="META-INF/" />
87 <fileset dir="resources/" />
89 <!-- Include the core OpenRocket JAR -->
90 <zipfileset dir="${build.dir}/" prefix="main">
91 <include name="${ant.project.name}-Core.jar"/>
94 <!-- Include libraries needed by OR -->
95 <zipfileset dir="${lib.dir}" prefix="lib">
96 <include name="*.jar"/>
98 <zipfileset dir="${lib.dir}/jogl" prefix="lib">
99 <include name="*.jar"/>
102 <!-- Include metafiles about OR -->
103 <fileset dir="." includes="LICENSE.TXT README.TXT ChangeLog ReleaseNotes fileformat.txt" />
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}">
112 <attribute name="Main-Class" value="${main-class}"/>
113 <attribute name="SplashScreen-Image" value="pix/splashscreen.png"/>
115 <zipfileset src="lib/exp4j-0.2.9.jar" />
119 <!-- CONVERT vendor csv to ORC files -->
120 <macrodef name="build-orc-file">
121 <attribute name="dir"/>
122 <attribute name="vendor"/>
124 <echo>Generating ORC file for vendor @{vendor}</echo>
125 <java classname="net.sf.openrocket.preset.loader.RocksimComponentFileTranslator"
127 classpathref="run-classpath"
129 <arg value="@{dir}"/>
130 <arg value="resources/datafiles/presets/@{vendor}.orc"/>
135 <target name="generate-orc-files"
136 description="Generate ORC file from vendor csv"
139 <for param="vendor-dir">
140 <dirset dir="resources-src/datafiles/rocksim_components"
143 <propertyregex property="vendor"
145 input="@{vendor-dir}"
147 regexp=".*[/\\]([^/\\]*)$"/>
148 <build-orc-file dir="@{vendor-dir}" vendor="${vendor}"/>
154 <target name="dist-src">
156 Building source distribution
158 <mkdir dir="${build.dir}/${pkgname}"/>
159 <mkdir dir="${jar.dir}"/>
160 <copy todir="${build.dir}/${pkgname}">
161 <fileset dir="." includes="*" excludes="*.log">
164 <fileset dir="." includes="resources/ lib/ lib-test/ src/ test/"/>
166 <zip destfile="${dist.src}" basedir="${build.dir}" includes="${pkgname}/"/>
167 <delete dir="${build.dir}/${pkgname}"/>
171 <!-- DIST-SRC-TEST -->
172 <target name="dist-src-test" depends="dist-src">
174 Testing source distribution
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}"/>
183 Source distribution test successful
189 <target name="dist-bin" depends="check,clean,unittest,jar">
190 <move file="${jar.file}" tofile="${dist.bin}"/>
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>
201 <target name="check" depends="checktodo,checkascii"/>
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"/>
212 <fileset dir="${src-test.dir}">
213 <include name="**/*.java"/>
217 <regexp pattern="(FIXME|TODO:.*CRITICAL)"/>
218 </linecontainsregexp>
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>
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"/>
238 <fileset dir="${src-test.dir}">
239 <include name="**/*.java"/>
243 <regexp pattern="\P{ASCII}"/>
244 </linecontainsregexp>
247 <loadfile srcfile="${ascii.file}" property="nonascii"/>
248 <delete file="${ascii.file}"/>
249 <fail if="nonascii">Non-ASCII characters exist in project:
251 <echo>No non-ASCII characters in project.</echo>
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"/>
261 <echo>Running unit tests</echo>
262 <mkdir dir="tmp/rawtestoutput"/>
263 <junit fork="yes" forkmode="once" printsummary="false" failureproperty="junit.failure">
265 <path refid="test-classpath"/>
266 <path location="${basedir}"/>
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" />
275 <formatter type="xml"/>
278 <junitreport todir="tmp">
279 <fileset dir="tmp/rawtestoutput"/>
280 <report todir="tmp/test-reports"/>
282 <fail if="junit.failure" message="Unit test(s) failed. See report in ${basedir}/tmp/test-reports/index.html"/>
284 Unit tests passed successfully.