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="${src-test.dir}"/>
40 <!-- <pathelement location="${ant.library.dir}/junit4.jar"/> -->
41 <pathelement location="lib-test/junit-4.7.jar"/>
48 <delete dir="${build.dir}"/>
55 <mkdir dir="${classes.dir}"/>
56 <echo>Compiling main classes</echo>
57 <javac debug="true" srcdir="${src.dir}" destdir="${classes.dir}" excludes="${main-dir}/*" classpathref="classpath"/>
58 <echo>Compiling startup classes</echo>
59 <javac debug="true" srcdir="${src.dir}/${main-dir}" destdir="${classes.dir}" source="1.4" classpathref="classpath"/>
60 <copy file="build.properties" todir="${dist.dir}"/>
65 <target name="jar" depends="build">
66 <copy todir="${dist.dir}/">
67 <fileset dir="." includes="LICENSE.TXT README.TXT ChangeLog ReleaseNotes build.properties fileformat.txt" />
68 <fileset dir="." includes="datafiles/ pix/" />
70 <mkdir dir="${jar.dir}"/>
71 <jar destfile="${jar.file}" basedir="${dist.dir}">
73 <attribute name="Main-Class" value="${main-class}"/>
74 <attribute name="SplashScreen-Image" value="pix/splashscreen.png"/>
76 <zipfileset src="lib/miglayout15-swing.jar" />
77 <zipfileset src="lib/jcommon-1.0.16.jar" />
78 <zipfileset src="lib/jfreechart-1.0.13.jar" />
84 <target name="dist-src">
86 Building source distribution
88 <mkdir dir="${build.dir}/${pkgname}"/>
89 <mkdir dir="${jar.dir}"/>
90 <copy todir="${build.dir}/${pkgname}">
91 <fileset dir="." includes="*">
94 <fileset dir="." includes="datafiles/ lib/ lib-test/ pix/ src/ test/"/>
96 <zip destfile="${dist.src}" basedir="${build.dir}" includes="${pkgname}/"/>
97 <delete dir="${build.dir}/${pkgname}"/>
101 <!-- DIST-SRC-TEST -->
102 <target name="dist-src-test" depends="dist-src">
104 Testing source distribution
106 <delete dir="${dist-test.dir}"/>
107 <mkdir dir="${dist-test.dir}"/>
108 <unzip dest="${dist-test.dir}" src="${dist.src}"/>
109 <ant dir="${dist-test.dir}/${pkgname}" antfile="build.xml" target="jar"/>
110 <ant dir="${dist-test.dir}/${pkgname}" antfile="build.xml" target="unittest"/>
111 <delete dir="${dist-test.dir}"/>
113 Source distribution test successful
119 <target name="dist-bin" depends="check,clean,unittest,jar">
120 <move file="${jar.file}" tofile="${dist.bin}"/>
125 <target name="dist" depends="dist-bin,dist-src,dist-src-test">
126 <echo>Distribution ${build.version} (${build.source}) built into directory ${jar.dir}</echo>
131 <target name="check" depends="checktodo,checkascii"/>
134 <target name="todo" depends="checktodo"/>
135 <target name="checktodo">
136 <tempfile property="todo.file" prefix="checktodo-"/>
137 <echo>Checking project for critical TODOs.</echo>
138 <concat destfile="${todo.file}">
139 <fileset dir="${src.dir}">
140 <include name="**/*.java"/>
142 <fileset dir="${src-test.dir}">
143 <include name="**/*.java"/>
147 <regexp pattern="TODO:.*CRITICAL"/>
148 </linecontainsregexp>
151 <loadfile srcfile="${todo.file}" property="criticaltodos"/>
152 <delete file="${todo.file}"/>
153 <fail if="criticaltodos">CRITICAL TODOs exist in project:
154 ${criticaltodos}</fail>
155 <echo>No critical TODOs in project.</echo>
160 <target name="ascii" depends="checkascii"/>
161 <target name="checkascii">
162 <tempfile property="ascii.file" prefix="checkascii-"/>
163 <echo>Checking project for non-ASCII characters.</echo>
164 <concat destfile="${ascii.file}">
165 <fileset dir="${src.dir}">
166 <include name="**/*.java"/>
168 <fileset dir="${src-test.dir}">
169 <include name="**/*.java"/>
173 <regexp pattern="\P{ASCII}"/>
174 </linecontainsregexp>
177 <loadfile srcfile="${ascii.file}" property="nonascii"/>
178 <delete file="${ascii.file}"/>
179 <fail if="nonascii">Non-ASCII characters exist in project:
181 <echo>No non-ASCII characters in project.</echo>
186 <target name="unittest" description="Execute unit tests" depends="build">
187 <echo>Building unit tests</echo>
188 <mkdir dir="${build-test.dir}"/>
189 <javac debug="true" srcdir="${src-test.dir}" destdir="${build-test.dir}" classpathref="test-classpath"/>
191 <echo>Running unit tests</echo>
192 <mkdir dir="tmp/rawtestoutput"/>
193 <junit fork="yes" forkmode="once" printsummary="false" failureproperty="junit.failure">
195 <path refid="test-classpath"/>
196 <path location="${basedir}"/>
198 <batchtest todir="tmp/rawtestoutput">
199 <fileset dir="${build-test.dir}">
200 <include name="**/Test*.class" />
201 <include name="**/*Test.class" />
202 <exclude name="**/*$*.class" />
203 <exclude name="Test.class" />
205 <formatter type="xml"/>
208 <junitreport todir="tmp">
209 <fileset dir="tmp/rawtestoutput"/>
210 <report todir="tmp/test-reports"/>
212 <fail if="junit.failure" message="Unit test(s) failed. See report in ${basedir}/tmp/test-reports/index.html"/>
214 Unit tests passed successfully.