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 -->
17 <property name="pkgname" value="${ant.project.name}-${build.version}"/>
19 <property name="jar.file" value="${jar.dir}/${ant.project.name}.jar"/>
20 <property name="dist.bin" value="${jar.dir}/${pkgname}.jar"/>
21 <property name="dist.src" value="${jar.dir}/${pkgname}-src.zip"/>
23 <!-- The main class of the application -->
24 <property name="main-class" value="net.sf.openrocket.startup.Startup"/>
27 <!-- Classpath definitions -->
29 <!-- update manifest class-path definition below too when making changes here -->
30 <pathelement location="/usr/share/java/jcommon.jar"/>
31 <pathelement location="/usr/share/java/jfreechart.jar"/>
32 <pathelement location="/usr/share/java/miglayout.jar"/>
35 <path id="test-classpath">
36 <path refid="classpath"/>
37 <pathelement location="${basedir}"/>
38 <pathelement location="${build-test.dir}"/>
39 <pathelement location="${classes.dir}"/>
40 <pathelement location="${src-test.dir}"/>
41 <pathelement location="/usr/share/java/junit4.jar"/>
48 <delete dir="${build.dir}"/>
55 <mkdir dir="${classes.dir}"/>
56 <echo level="info">Compiling main classes</echo>
57 <javac debug="true" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
58 <echo level="info">Copying build.properties</echo>
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/ l10n/" />
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"/>
74 <attribute name="Class-Path" value="/usr/share/j
75 ava/jcommon.jar /usr/share/java/jfreechart.jar /usr/share/java/miglayout.jar /usr/share/java/itext.jar"/>
82 <target name="dist-src">
84 Building source distribution
86 <mkdir dir="${build.dir}/${pkgname}"/>
87 <mkdir dir="${jar.dir}"/>
88 <copy todir="${build.dir}/${pkgname}">
89 <fileset dir="." includes="*">
92 <fileset dir="." includes="datafiles/ pix/ src/ test/"/>
94 <zip destfile="${dist.src}" basedir="${build.dir}" includes="${pkgname}/"/>
95 <delete dir="${build.dir}/${pkgname}"/>
99 <!-- DIST-SRC-TEST -->
100 <target name="dist-src-test" depends="dist-src">
102 Testing source distribution
104 <delete dir="${dist-test.dir}"/>
105 <mkdir dir="${dist-test.dir}"/>
106 <unzip dest="${dist-test.dir}" src="${dist.src}"/>
107 <ant dir="${dist-test.dir}/${pkgname}" antfile="build.xml" target="jar"/>
108 <ant dir="${dist-test.dir}/${pkgname}" antfile="build.xml" target="unittest"/>
109 <delete dir="${dist-test.dir}"/>
111 Source distribution test successful
117 <target name="dist-bin" depends="check,clean,unittest,jar">
118 <move file="${jar.file}" tofile="${dist.bin}"/>
123 <target name="dist" depends="dist-bin,dist-src,dist-src-test">
124 <echo>Distribution ${build.version} (${build.source}) built into directory ${jar.dir}</echo>
129 <target name="check" depends="checktodo,checkascii"/>
132 <target name="todo" depends="checktodo"/>
133 <target name="checktodo">
134 <tempfile property="todo.file" prefix="checktodo-"/>
135 <echo>Checking project for critical TODOs.</echo>
136 <concat destfile="${todo.file}">
137 <fileset dir="${src.dir}">
138 <include name="**/*.java"/>
140 <fileset dir="${src-test.dir}">
141 <include name="**/*.java"/>
145 <regexp pattern="TODO:.*CRITICAL"/>
146 </linecontainsregexp>
149 <loadfile srcfile="${todo.file}" property="criticaltodos"/>
150 <delete file="${todo.file}"/>
151 <fail if="criticaltodos">CRITICAL TODOs exist in project:
152 ${criticaltodos}</fail>
153 <echo>No critical TODOs in project.</echo>
158 <target name="ascii" depends="checkascii"/>
159 <target name="checkascii">
160 <tempfile property="ascii.file" prefix="checkascii-"/>
161 <echo>Checking project for non-ASCII characters.</echo>
162 <concat destfile="${ascii.file}">
163 <fileset dir="${src.dir}">
164 <include name="**/*.java"/>
166 <fileset dir="${src-test.dir}">
167 <include name="**/*.java"/>
171 <regexp pattern="\P{ASCII}"/>
172 </linecontainsregexp>
175 <loadfile srcfile="${ascii.file}" property="nonascii"/>
176 <delete file="${ascii.file}"/>
177 <fail if="nonascii">Non-ASCII characters exist in project:
179 <echo>No non-ASCII characters in project.</echo>
184 <target name="unittest" description="Execute unit tests" depends="build">
185 <echo>Building unit tests</echo>
186 <mkdir dir="${build-test.dir}"/>
187 <javac debug="true" srcdir="${src-test.dir}" destdir="${build-test.dir}" classpathref="test-classpath"/>
189 <echo>Running unit tests</echo>
190 <mkdir dir="tmp/rawtestoutput"/>
191 <junit fork="yes" forkmode="once" printsummary="false" failureproperty="junit.failure">
193 <path refid="test-classpath"/>
194 <path location="${basedir}"/>
196 <batchtest todir="tmp/rawtestoutput">
197 <fileset dir="${build-test.dir}">
198 <include name="**/Test*.class" />
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.