1 <project name="OpenRocket" basedir=".">
3 <property file="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"/>
26 <property name="main-dir" value="net/sf/openrocket/startup"/>
29 <!-- Classpath definitions -->
31 <fileset dir="${lib.dir}" includes="**/*.jar"/>
34 <path id="test-classpath">
35 <path refid="classpath"/>
36 <pathelement location="${basedir}"/>
37 <pathelement location="${build-test.dir}"/>
38 <pathelement location="${classes.dir}"/>
39 <!-- <pathelement location="${ant.library.dir}/junit4.jar"/> -->
40 <pathelement location="lib-test/junit-4.7.jar"/>
47 <delete dir="${build.dir}"/>
54 <mkdir dir="${classes.dir}"/>
55 <echo>Compiling main classes</echo>
56 <javac debug="true" srcdir="${src.dir}" destdir="${classes.dir}" excludes="${main-dir}/*" classpathref="classpath"/>
57 <echo>Compiling startup classes</echo>
58 <javac debug="true" srcdir="${src.dir}/${main-dir}" destdir="${classes.dir}" source="1.4" classpathref="classpath"/>
59 <copy file="build.properties" todir="${dist.dir}"/>
64 <target name="jar" depends="build">
65 <copy todir="${dist.dir}/">
66 <fileset dir="." includes="LICENSE.TXT README.TXT ChangeLog ReleaseNotes build.properties fileformat.txt" />
67 <fileset dir="." includes="datafiles/ pix/" />
69 <mkdir dir="${jar.dir}"/>
70 <jar destfile="${jar.file}" basedir="${dist.dir}">
72 <attribute name="Main-Class" value="${main-class}"/>
73 <attribute name="SplashScreen-Image" value="pix/splashscreen.png"/>
75 <zipfileset src="lib/miglayout15-swing.jar" />
76 <zipfileset src="lib/jcommon-1.0.16.jar" />
77 <zipfileset src="lib/jfreechart-1.0.13.jar" />
83 <target name="dist-src">
85 Building source distribution
87 <mkdir dir="${build.dir}/${pkgname}"/>
88 <mkdir dir="${jar.dir}"/>
89 <copy todir="${build.dir}/${pkgname}">
90 <fileset dir="." includes="*">
93 <fileset dir="." includes="datafiles/ lib/ lib-test/ pix/ src/ test/"/>
95 <zip destfile="${dist.src}" basedir="${build.dir}" includes="${pkgname}/"/>
96 <delete dir="${build.dir}/${pkgname}"/>
100 <!-- DIST-SRC-TEST -->
101 <target name="dist-src-test" depends="dist-src">
103 Testing source distribution
105 <delete dir="${dist-test.dir}"/>
106 <mkdir dir="${dist-test.dir}"/>
107 <unzip dest="${dist-test.dir}" src="${dist.src}"/>
108 <ant dir="${dist-test.dir}/${pkgname}" antfile="build.xml" target="jar"/>
109 <ant dir="${dist-test.dir}/${pkgname}" antfile="build.xml" target="unittest"/>
110 <delete dir="${dist-test.dir}"/>
112 Source distribution test successful
118 <target name="dist-bin" depends="check,clean,unittest,jar">
119 <move file="${jar.file}" tofile="${dist.bin}"/>
124 <target name="dist" depends="dist-bin,dist-src,dist-src-test">
125 <echo>Distribution ${build.version} (${build.source}) built into directory ${jar.dir}</echo>
130 <target name="check" depends="checktodo,checkascii"/>
133 <target name="todo" depends="checktodo"/>
134 <target name="checktodo">
135 <tempfile property="todo.file" prefix="checktodo-"/>
136 <echo>Checking project for critical TODOs.</echo>
137 <concat destfile="${todo.file}">
138 <fileset dir="${src.dir}">
139 <include name="**/*.java"/>
141 <fileset dir="${src-test.dir}">
142 <include name="**/*.java"/>
146 <regexp pattern="TODO:.*CRITICAL"/>
147 </linecontainsregexp>
150 <loadfile srcfile="${todo.file}" property="criticaltodos"/>
151 <delete file="${todo.file}"/>
152 <fail if="criticaltodos">CRITICAL TODOs exist in project:
153 ${criticaltodos}</fail>
154 <echo>No critical TODOs in project.</echo>
159 <target name="ascii" depends="checkascii"/>
160 <target name="checkascii">
161 <tempfile property="ascii.file" prefix="checkascii-"/>
162 <echo>Checking project for non-ASCII characters.</echo>
163 <concat destfile="${ascii.file}">
164 <fileset dir="${src.dir}">
165 <include name="**/*.java"/>
167 <fileset dir="${src-test.dir}">
168 <include name="**/*.java"/>
172 <regexp pattern="\P{ASCII}"/>
173 </linecontainsregexp>
176 <loadfile srcfile="${ascii.file}" property="nonascii"/>
177 <delete file="${ascii.file}"/>
178 <fail if="nonascii">Non-ASCII characters exist in project:
180 <echo>No non-ASCII characters in project.</echo>
185 <target name="unittest" description="Execute unit tests" depends="build">
186 <echo>Building unit tests</echo>
187 <mkdir dir="${build-test.dir}"/>
188 <javac debug="true" srcdir="${src-test.dir}" destdir="${build-test.dir}" classpathref="test-classpath"/>
190 <echo>Running unit tests</echo>
191 <mkdir dir="tmp/rawtestoutput"/>
192 <junit fork="yes" forkmode="once" printsummary="true" failureproperty="junit.failure">
194 <path refid="test-classpath"/>
195 <path location="${basedir}"/>
197 <batchtest todir="tmp/rawtestoutput">
198 <fileset dir="${build-test.dir}">
199 <include name="**/*Test*.class" />
200 <exclude name="**/*$*.class" />
201 <exclude name="Test.class" />
203 <formatter type="xml"/>
206 <junitreport todir="tmp">
207 <fileset dir="tmp/rawtestoutput"/>
208 <report todir="tmp/test-reports"/>
210 <fail if="junit.failure" message="Unit test(s) failed. See report in ${basedir}/tmp/test-reports/index.html"/>
212 Unit tests passed successfully.