updates for 0.9.4
[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         <property name="main-dir" value="net/sf/openrocket/startup"/>
27
28         
29         <!-- Classpath definitions -->
30         <path id="classpath">
31                 <fileset dir="${lib.dir}" includes="**/*.jar"/>
32         </path>
33         
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"/>
41         </path>
42         
43
44         
45         <!-- CLEAN -->
46         <target name="clean">
47                 <delete dir="${build.dir}"/>
48                 <delete dir="tmp/"/>
49         </target>
50                 
51         
52         <!-- BUILD -->
53         <target name="build">
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}"/>
60         </target>
61         
62         
63         <!-- JAR -->
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/" />
68                 </copy>
69                 <mkdir dir="${jar.dir}"/>
70                 <jar destfile="${jar.file}" basedir="${dist.dir}">
71                         <manifest>
72                                 <attribute name="Main-Class" value="${main-class}"/>
73                                 <attribute name="SplashScreen-Image" value="pix/splashscreen.png"/>
74                         </manifest>
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" />
78                 </jar>
79         </target>
80         
81         
82         <!-- DIST-SRC -->
83         <target name="dist-src">
84                 <echo>                  
85                 Building source distribution
86                 </echo>
87                 <mkdir dir="${build.dir}/${pkgname}"/>
88                 <mkdir dir="${jar.dir}"/>
89                 <copy todir="${build.dir}/${pkgname}">
90                         <fileset dir="." includes="*">
91                                 <type type="file"/>
92                         </fileset>
93                         <fileset dir="." includes="datafiles/ lib/ lib-test/ pix/ src/ test/"/>
94                 </copy>
95                 <zip destfile="${dist.src}" basedir="${build.dir}" includes="${pkgname}/"/>
96                 <delete dir="${build.dir}/${pkgname}"/>
97         </target>
98         
99         
100         <!-- DIST-SRC-TEST -->
101         <target name="dist-src-test" depends="dist-src">
102                 <echo>
103                 Testing source distribution
104                 </echo>
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}"/>
111                 <echo>
112                 Source distribution test successful
113                 </echo>
114         </target>       
115         
116         
117         <!-- DIST-BIN -->
118         <target name="dist-bin" depends="check,clean,unittest,jar">
119                 <move file="${jar.file}" tofile="${dist.bin}"/>
120         </target>
121
122         
123         <!-- DIST -->
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>
126         </target>
127         
128         
129         <!-- CHECK -->
130         <target name="check" depends="checktodo,checkascii"/>
131         
132         <!-- CHECK TODOs -->
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"/>
139                         </fileset>
140                         <fileset dir="${src-test.dir}">
141                             <include name="**/*.java"/>
142                         </fileset>
143                         <filterchain>
144                                 <linecontainsregexp>
145                                         <regexp pattern="TODO:.*CRITICAL"/>
146                                 </linecontainsregexp>
147                         </filterchain>
148                 </concat>
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>
154         </target>
155         
156         
157         <!-- CHECK TODOs -->
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"/>
164                         </fileset>
165                         <fileset dir="${src-test.dir}">
166                             <include name="**/*.java"/>
167                         </fileset>
168                         <filterchain>
169                                 <linecontainsregexp>
170                                         <regexp pattern="\P{ASCII}"/>
171                                 </linecontainsregexp>
172                         </filterchain>
173                 </concat>
174                 <loadfile srcfile="${ascii.file}" property="nonascii"/>
175                 <delete file="${ascii.file}"/>
176                 <fail if="nonascii">Non-ASCII characters exist in project:
177 ${nonascii}</fail>
178                 <echo>No non-ASCII characters in project.</echo>
179         </target>
180         
181         
182         <!--  Unit tests  -->
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"/>
187                 
188                 <echo>Running unit tests</echo>
189                 <mkdir dir="tmp/rawtestoutput"/>
190                 <junit fork="yes" forkmode="once" printsummary="true" failureproperty="junit.failure">
191                         <classpath>
192                                 <path refid="test-classpath"/>
193                                 <path location="${basedir}"/>
194                         </classpath>
195                         <batchtest todir="tmp/rawtestoutput">
196                                 <fileset dir="${build-test.dir}">
197                                         <include name="**/*Test*.class" />
198                                         <exclude name="**/*$*.class" />
199                                         <exclude name="Test.class" />
200                                 </fileset>
201                                 <formatter type="xml"/>
202                         </batchtest>
203                 </junit>
204                 <junitreport todir="tmp">
205                         <fileset dir="tmp/rawtestoutput"/>
206                         <report todir="tmp/test-reports"/>
207                 </junitreport>
208                 <fail if="junit.failure" message="Unit test(s) failed.  See report in ${basedir}/tmp/test-reports/index.html"/>
209                 <echo>
210         Unit tests passed successfully.
211                 </echo>
212         </target>
213     
214 </project>