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"/>
72 <target name="jar" depends="build" description="Create the OpenRocket jar file">
73 <copy todir="${dist.dir}/">
74 <fileset dir="." includes="LICENSE.TXT README.TXT ChangeLog ReleaseNotes fileformat.txt" />
75 <fileset dir="resources/"/>
76 <fileset dir="src/" includes="META-INF/" />
78 <mkdir dir="${jar.dir}"/>
79 <jar destfile="${jar.file}" basedir="${dist.dir}">
81 <attribute name="Main-Class" value="${main-class}"/>
82 <attribute name="SplashScreen-Image" value="pix/splashscreen.png"/>
84 <zipfileset src="lib/miglayout15-swing.jar" />
85 <zipfileset src="lib/jcommon-1.0.16.jar" />
86 <zipfileset src="lib/jfreechart-1.0.13.jar" />
87 <zipfileset src="lib/iText-5.0.2.jar" />
88 <zipfileset src="lib/opencsv-2.3.jar" />
89 <zipfileset src="lib/exp4j-0.2.9.jar" />
93 <!-- CONVERT vendor csv to ORC files -->
94 <macrodef name="build-orc-file">
95 <attribute name="dir"/>
96 <attribute name="vendor"/>
98 <echo>Generating ORC file for vendor @{vendor}</echo>
99 <java classname="net.sf.openrocket.preset.loader.RocksimComponentFileTranslator"
101 classpathref="run-classpath"
103 <arg value="@{dir}"/>
104 <arg value="resources/datafiles/presets/@{vendor}.orc"/>
109 <target name="generate-orc-files"
110 description="Generate ORC file from vendor csv"
113 <for param="vendor-dir">
114 <dirset dir="resources-src/datafiles/rocksim_components"
117 <propertyregex property="vendor"
119 input="@{vendor-dir}"
121 regexp=".*[/\\]([^/\\]*)$"/>
122 <build-orc-file dir="@{vendor-dir}" vendor="${vendor}"/>
128 <target name="dist-src">
130 Building source distribution
132 <mkdir dir="${build.dir}/${pkgname}"/>
133 <mkdir dir="${jar.dir}"/>
134 <copy todir="${build.dir}/${pkgname}">
135 <fileset dir="." includes="*" excludes="*.log">
138 <fileset dir="." includes="resources/ lib/ lib-test/ src/ test/"/>
140 <zip destfile="${dist.src}" basedir="${build.dir}" includes="${pkgname}/"/>
141 <delete dir="${build.dir}/${pkgname}"/>
145 <!-- DIST-SRC-TEST -->
146 <target name="dist-src-test" depends="dist-src">
148 Testing source distribution
150 <delete dir="${dist-test.dir}"/>
151 <mkdir dir="${dist-test.dir}"/>
152 <unzip dest="${dist-test.dir}" src="${dist.src}"/>
153 <ant dir="${dist-test.dir}/${pkgname}" antfile="build.xml" target="jar"/>
154 <ant dir="${dist-test.dir}/${pkgname}" antfile="build.xml" target="unittest"/>
155 <delete dir="${dist-test.dir}"/>
157 Source distribution test successful
163 <target name="dist-bin" depends="check,clean,unittest,jar">
164 <move file="${jar.file}" tofile="${dist.bin}"/>
169 <target name="dist" depends="dist-bin,dist-src,dist-src-test">
170 <echo>Distribution ${build.version} (${build.source}) built into directory ${jar.dir}</echo>
175 <target name="check" depends="checktodo,checkascii"/>
178 <target name="todo" depends="checktodo"/>
179 <target name="checktodo">
180 <tempfile property="todo.file" prefix="checktodo-"/>
181 <echo>Checking project for FIXMEs.</echo>
182 <concat destfile="${todo.file}">
183 <fileset dir="${src.dir}">
184 <include name="**/*.java"/>
186 <fileset dir="${src-test.dir}">
187 <include name="**/*.java"/>
191 <regexp pattern="(FIXME|TODO:.*CRITICAL)"/>
192 </linecontainsregexp>
195 <loadfile srcfile="${todo.file}" property="criticaltodos"/>
196 <delete file="${todo.file}"/>
197 <fail if="criticaltodos">CRITICAL TODOs exist in project:
198 ${criticaltodos}</fail>
199 <echo>No critical TODOs in project.</echo>
204 <target name="ascii" depends="checkascii"/>
205 <target name="checkascii">
206 <tempfile property="ascii.file" prefix="checkascii-"/>
207 <echo>Checking project for non-ASCII characters.</echo>
208 <concat destfile="${ascii.file}">
209 <fileset dir="${src.dir}">
210 <include name="**/*.java"/>
212 <fileset dir="${src-test.dir}">
213 <include name="**/*.java"/>
217 <regexp pattern="\P{ASCII}"/>
218 </linecontainsregexp>
221 <loadfile srcfile="${ascii.file}" property="nonascii"/>
222 <delete file="${ascii.file}"/>
223 <fail if="nonascii">Non-ASCII characters exist in project:
225 <echo>No non-ASCII characters in project.</echo>
230 <target name="unittest" description="Execute unit tests" depends="build">
231 <echo>Building unit tests</echo>
232 <mkdir dir="${build-test.dir}"/>
233 <javac debug="true" srcdir="${src-test.dir}" destdir="${build-test.dir}" classpathref="test-classpath"/>
235 <echo>Running unit tests</echo>
236 <mkdir dir="tmp/rawtestoutput"/>
237 <junit fork="yes" forkmode="once" printsummary="false" failureproperty="junit.failure">
239 <path refid="test-classpath"/>
240 <path location="${basedir}"/>
242 <batchtest todir="tmp/rawtestoutput">
243 <fileset dir="${build-test.dir}">
244 <include name="**/Test*.class" />
245 <include name="**/*Test.class" />
246 <exclude name="**/*$*.class" />
247 <exclude name="Test.class" />
249 <formatter type="xml"/>
252 <junitreport todir="tmp">
253 <fileset dir="tmp/rawtestoutput"/>
254 <report todir="tmp/test-reports"/>
256 <fail if="junit.failure" message="Unit test(s) failed. See report in ${basedir}/tmp/test-reports/index.html"/>
258 Unit tests passed successfully.