SafetyMutex and rocket optimization updates
[debian/openrocket] / build.xml
1 <project name="OpenRocket" basedir=".">
2
3         <property file="build.properties" />
4         
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 -->
9                 
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"/>
13         
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 -->
17
18         <property name="pkgname"     value="${ant.project.name}-${build.version}"/>
19         
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"/>
23         
24         <!-- The main class of the application -->
25         <property name="main-class"  value="net.sf.openrocket.startup.Startup"/>
26
27         
28         <!-- Classpath definitions -->
29         <path id="classpath">
30                 <fileset dir="${lib.dir}" includes="**/*.jar"/>
31         </path>
32         
33         <path id="test-classpath">
34                 <path refid="classpath"/>
35                 <pathelement location="${basedir}"/>
36                 <pathelement location="${build-test.dir}"/>
37                 <pathelement location="${classes.dir}"/>
38                 <pathelement location="${src-test.dir}"/>
39                 <pathelement location="lib-test/junit-dep-4.8.2.jar"/>
40                 <pathelement location="lib-test/hamcrest-core-1.3.0RC1.jar"/>
41                 <pathelement location="lib-test/hamcrest-library-1.3.0RC1.jar"/>
42                 <pathelement location="lib-test/jmock-2.6.0-RC2.jar"/>
43                 <pathelement location="lib-test/jmock-junit4-2.6.0-RC2.jar"/>
44         </path>
45         
46
47         
48         <!-- CLEAN -->
49         <target name="clean">
50                 <delete dir="${build.dir}"/>
51                 <delete dir="tmp/"/>
52         </target>
53                 
54         
55         <!-- BUILD -->
56         <target name="build">
57                 <mkdir dir="${classes.dir}"/>
58                 <echo level="info">Compiling main classes</echo>
59                 <javac debug="true" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
60                 <echo level="info">Copying build.properties</echo>
61                 <copy file="build.properties" todir="${dist.dir}"/>
62         </target>
63         
64         
65         <!-- JAR -->
66         <target name="jar" depends="build">
67                 <copy todir="${dist.dir}/">
68                         <fileset dir="." includes="LICENSE.TXT README.TXT ChangeLog ReleaseNotes build.properties fileformat.txt" />
69                         <fileset dir="." includes="datafiles/ pix/" />
70                 </copy>
71                 <mkdir dir="${jar.dir}"/>
72                 <jar destfile="${jar.file}" basedir="${dist.dir}">
73                         <manifest>
74                                 <attribute name="Main-Class" value="${main-class}"/>
75                                 <attribute name="SplashScreen-Image" value="pix/splashscreen.png"/>
76                         </manifest>
77                         <zipfileset src="lib/miglayout15-swing.jar" />
78                         <zipfileset src="lib/jcommon-1.0.16.jar" />
79                         <zipfileset src="lib/jfreechart-1.0.13.jar" />
80                 </jar>
81         </target>
82         
83         
84         <!-- DIST-SRC -->
85         <target name="dist-src">
86                 <echo>                  
87                 Building source distribution
88                 </echo>
89                 <mkdir dir="${build.dir}/${pkgname}"/>
90                 <mkdir dir="${jar.dir}"/>
91                 <copy todir="${build.dir}/${pkgname}">
92                         <fileset dir="." includes="*">
93                                 <type type="file"/>
94                         </fileset>
95                         <fileset dir="." includes="datafiles/ lib/ lib-test/ pix/ src/ test/"/>
96                 </copy>
97                 <zip destfile="${dist.src}" basedir="${build.dir}" includes="${pkgname}/"/>
98                 <delete dir="${build.dir}/${pkgname}"/>
99         </target>
100         
101         
102         <!-- DIST-SRC-TEST -->
103         <target name="dist-src-test" depends="dist-src">
104                 <echo>
105                 Testing source distribution
106                 </echo>
107                 <delete dir="${dist-test.dir}"/>
108                 <mkdir dir="${dist-test.dir}"/>
109                 <unzip dest="${dist-test.dir}" src="${dist.src}"/>
110                 <ant dir="${dist-test.dir}/${pkgname}" antfile="build.xml" target="jar"/>
111                 <ant dir="${dist-test.dir}/${pkgname}" antfile="build.xml" target="unittest"/>
112                 <delete dir="${dist-test.dir}"/>
113                 <echo>
114                 Source distribution test successful
115                 </echo>
116         </target>       
117         
118         
119         <!-- DIST-BIN -->
120         <target name="dist-bin" depends="check,clean,unittest,jar">
121                 <move file="${jar.file}" tofile="${dist.bin}"/>
122         </target>
123
124         
125         <!-- DIST -->
126         <target name="dist" depends="dist-bin,dist-src,dist-src-test">
127                 <echo>Distribution ${build.version} (${build.source}) built into directory ${jar.dir}</echo>
128         </target>
129         
130         
131         <!-- CHECK -->
132         <target name="check" depends="checktodo,checkascii"/>
133         
134         <!-- CHECK TODOs -->
135         <target name="todo" depends="checktodo"/>
136         <target name="checktodo">
137                 <tempfile property="todo.file" prefix="checktodo-"/>
138                 <echo>Checking project for critical TODOs.</echo>
139                 <concat destfile="${todo.file}">
140                         <fileset dir="${src.dir}">
141                             <include name="**/*.java"/>
142                         </fileset>
143                         <fileset dir="${src-test.dir}">
144                             <include name="**/*.java"/>
145                         </fileset>
146                         <filterchain>
147                                 <linecontainsregexp>
148                                         <regexp pattern="TODO:.*CRITICAL"/>
149                                 </linecontainsregexp>
150                         </filterchain>
151                 </concat>
152                 <loadfile srcfile="${todo.file}" property="criticaltodos"/>
153                 <delete file="${todo.file}"/>
154                 <fail if="criticaltodos">CRITICAL TODOs exist in project:
155 ${criticaltodos}</fail>
156                 <echo>No critical TODOs in project.</echo>
157         </target>
158         
159         
160         <!-- CHECK TODOs -->
161         <target name="ascii" depends="checkascii"/>
162         <target name="checkascii">
163                 <tempfile property="ascii.file" prefix="checkascii-"/>
164                 <echo>Checking project for non-ASCII characters.</echo>
165                 <concat destfile="${ascii.file}">
166                         <fileset dir="${src.dir}">
167                             <include name="**/*.java"/>
168                         </fileset>
169                         <fileset dir="${src-test.dir}">
170                             <include name="**/*.java"/>
171                         </fileset>
172                         <filterchain>
173                                 <linecontainsregexp>
174                                         <regexp pattern="\P{ASCII}"/>
175                                 </linecontainsregexp>
176                         </filterchain>
177                 </concat>
178                 <loadfile srcfile="${ascii.file}" property="nonascii"/>
179                 <delete file="${ascii.file}"/>
180                 <fail if="nonascii">Non-ASCII characters exist in project:
181 ${nonascii}</fail>
182                 <echo>No non-ASCII characters in project.</echo>
183         </target>
184         
185         
186         <!--  Unit tests  -->
187         <target name="unittest" description="Execute unit tests" depends="build">
188                 <echo>Building unit tests</echo>
189                 <mkdir dir="${build-test.dir}"/>
190                 <javac debug="true" srcdir="${src-test.dir}" destdir="${build-test.dir}" classpathref="test-classpath"/>
191                 
192                 <echo>Running unit tests</echo>
193                 <mkdir dir="tmp/rawtestoutput"/>
194                 <junit fork="yes" forkmode="once" printsummary="false" failureproperty="junit.failure">
195                         <classpath>
196                                 <path refid="test-classpath"/>
197                                 <path location="${basedir}"/>
198                         </classpath>
199                         <batchtest todir="tmp/rawtestoutput">
200                                 <fileset dir="${build-test.dir}">
201                                         <include name="**/Test*.class" />
202                                         <include name="**/*Test.class" />
203                                         <exclude name="**/*$*.class" />
204                                         <exclude name="Test.class" />
205                                 </fileset>
206                                 <formatter type="xml"/>
207                         </batchtest>
208                 </junit>
209                 <junitreport todir="tmp">
210                         <fileset dir="tmp/rawtestoutput"/>
211                         <report todir="tmp/test-reports"/>
212                 </junitreport>
213                 <fail if="junit.failure" message="Unit test(s) failed.  See report in ${basedir}/tmp/test-reports/index.html"/>
214                 <echo>
215         Unit tests passed successfully.
216                 </echo>
217         </target>
218     
219 </project>