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"/>
46 <delete dir="${build.dir}"/>
53 <mkdir dir="${classes.dir}"/>
54 <echo level="info">Compiling main classes</echo>
55 <javac debug="true" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
60 <target name="jar" depends="build">
61 <copy todir="${dist.dir}/">
62 <fileset dir="." includes="LICENSE.TXT README.TXT ChangeLog ReleaseNotes fileformat.txt" />
63 <fileset dir="resources/"/>
64 <fileset dir="src/" includes="META-INF/" />
66 <mkdir dir="${jar.dir}"/>
67 <jar destfile="${jar.file}" basedir="${dist.dir}">
69 <attribute name="Main-Class" value="${main-class}"/>
70 <attribute name="SplashScreen-Image" value="pix/splashscreen.png"/>
72 <zipfileset src="lib/miglayout15-swing.jar" />
73 <zipfileset src="lib/jcommon-1.0.16.jar" />
74 <zipfileset src="lib/jfreechart-1.0.13.jar" />
75 <zipfileset src="lib/iText-5.0.2.jar" />
81 <target name="dist-src">
83 Building source distribution
85 <mkdir dir="${build.dir}/${pkgname}"/>
86 <mkdir dir="${jar.dir}"/>
87 <copy todir="${build.dir}/${pkgname}">
88 <fileset dir="." includes="*" excludes="*.log">
91 <fileset dir="." includes="resources/ lib/ lib-test/ src/ test/"/>
93 <zip destfile="${dist.src}" basedir="${build.dir}" includes="${pkgname}/"/>
94 <delete dir="${build.dir}/${pkgname}"/>
98 <!-- DIST-SRC-TEST -->
99 <target name="dist-src-test" depends="dist-src">
101 Testing source distribution
103 <delete dir="${dist-test.dir}"/>
104 <mkdir dir="${dist-test.dir}"/>
105 <unzip dest="${dist-test.dir}" src="${dist.src}"/>
106 <ant dir="${dist-test.dir}/${pkgname}" antfile="build.xml" target="jar"/>
107 <ant dir="${dist-test.dir}/${pkgname}" antfile="build.xml" target="unittest"/>
108 <delete dir="${dist-test.dir}"/>
110 Source distribution test successful
116 <target name="dist-bin" depends="check,clean,unittest,jar">
117 <move file="${jar.file}" tofile="${dist.bin}"/>
122 <target name="dist" depends="dist-bin,dist-src,dist-src-test">
123 <echo>Distribution ${build.version} (${build.source}) built into directory ${jar.dir}</echo>
128 <target name="check" depends="checktodo,checkascii"/>
131 <target name="todo" depends="checktodo"/>
132 <target name="checktodo">
133 <tempfile property="todo.file" prefix="checktodo-"/>
134 <echo>Checking project for FIXMEs.</echo>
135 <concat destfile="${todo.file}">
136 <fileset dir="${src.dir}">
137 <include name="**/*.java"/>
139 <fileset dir="${src-test.dir}">
140 <include name="**/*.java"/>
144 <regexp pattern="(FIXME|TODO:.*CRITICAL)"/>
145 </linecontainsregexp>
148 <loadfile srcfile="${todo.file}" property="criticaltodos"/>
149 <delete file="${todo.file}"/>
150 <fail if="criticaltodos">CRITICAL TODOs exist in project:
151 ${criticaltodos}</fail>
152 <echo>No critical TODOs in project.</echo>
157 <target name="ascii" depends="checkascii"/>
158 <target name="checkascii">
159 <tempfile property="ascii.file" prefix="checkascii-"/>
160 <echo>Checking project for non-ASCII characters.</echo>
161 <concat destfile="${ascii.file}">
162 <fileset dir="${src.dir}">
163 <include name="**/*.java"/>
165 <fileset dir="${src-test.dir}">
166 <include name="**/*.java"/>
170 <regexp pattern="\P{ASCII}"/>
171 </linecontainsregexp>
174 <loadfile srcfile="${ascii.file}" property="nonascii"/>
175 <delete file="${ascii.file}"/>
176 <fail if="nonascii">Non-ASCII characters exist in project:
178 <echo>No non-ASCII characters in project.</echo>
183 <target name="unittest" description="Execute unit tests" depends="build">
184 <echo>Building unit tests</echo>
185 <mkdir dir="${build-test.dir}"/>
186 <javac debug="true" srcdir="${src-test.dir}" destdir="${build-test.dir}" classpathref="test-classpath"/>
188 <echo>Running unit tests</echo>
189 <mkdir dir="tmp/rawtestoutput"/>
190 <junit fork="yes" forkmode="once" printsummary="false" failureproperty="junit.failure">
192 <path refid="test-classpath"/>
193 <path location="${basedir}"/>
195 <batchtest todir="tmp/rawtestoutput">
196 <fileset dir="${build-test.dir}">
197 <include name="**/Test*.class" />
198 <include name="**/*Test.class" />
199 <exclude name="**/*$*.class" />
200 <exclude name="Test.class" />
202 <formatter type="xml"/>
205 <junitreport todir="tmp">
206 <fileset dir="tmp/rawtestoutput"/>
207 <report todir="tmp/test-reports"/>
209 <fail if="junit.failure" message="Unit test(s) failed. See report in ${basedir}/tmp/test-reports/index.html"/>
211 Unit tests passed successfully.