minor update
[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="${src-test.dir}"/>
40 <!--            <pathelement location="${ant.library.dir}/junit4.jar"/> -->
41                 <pathelement location="lib-test/junit-4.7.jar"/>
42         </path>
43         
44
45         
46         <!-- CLEAN -->
47         <target name="clean">
48                 <delete dir="${build.dir}"/>
49                 <delete dir="tmp/"/>
50         </target>
51                 
52         
53         <!-- BUILD -->
54         <target name="build">
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}"/>
61         </target>
62         
63         
64         <!-- JAR -->
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/" />
69                 </copy>
70                 <mkdir dir="${jar.dir}"/>
71                 <jar destfile="${jar.file}" basedir="${dist.dir}">
72                         <manifest>
73                                 <attribute name="Main-Class" value="${main-class}"/>
74                                 <attribute name="SplashScreen-Image" value="pix/splashscreen.png"/>
75                         </manifest>
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" />
79                 </jar>
80         </target>
81         
82         
83         <!-- DIST-SRC -->
84         <target name="dist-src">
85                 <echo>                  
86                 Building source distribution
87                 </echo>
88                 <mkdir dir="${build.dir}/${pkgname}"/>
89                 <mkdir dir="${jar.dir}"/>
90                 <copy todir="${build.dir}/${pkgname}">
91                         <fileset dir="." includes="*">
92                                 <type type="file"/>
93                         </fileset>
94                         <fileset dir="." includes="datafiles/ lib/ lib-test/ pix/ src/ test/"/>
95                 </copy>
96                 <zip destfile="${dist.src}" basedir="${build.dir}" includes="${pkgname}/"/>
97                 <delete dir="${build.dir}/${pkgname}"/>
98         </target>
99         
100         
101         <!-- DIST-SRC-TEST -->
102         <target name="dist-src-test" depends="dist-src">
103                 <echo>
104                 Testing source distribution
105                 </echo>
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}"/>
112                 <echo>
113                 Source distribution test successful
114                 </echo>
115         </target>       
116         
117         
118         <!-- DIST-BIN -->
119         <target name="dist-bin" depends="check,clean,unittest,jar">
120                 <move file="${jar.file}" tofile="${dist.bin}"/>
121         </target>
122
123         
124         <!-- DIST -->
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>
127         </target>
128         
129         
130         <!-- CHECK -->
131         <target name="check" depends="checktodo,checkascii"/>
132         
133         <!-- CHECK TODOs -->
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"/>
141                         </fileset>
142                         <fileset dir="${src-test.dir}">
143                             <include name="**/*.java"/>
144                         </fileset>
145                         <filterchain>
146                                 <linecontainsregexp>
147                                         <regexp pattern="TODO:.*CRITICAL"/>
148                                 </linecontainsregexp>
149                         </filterchain>
150                 </concat>
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>
156         </target>
157         
158         
159         <!-- CHECK TODOs -->
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"/>
167                         </fileset>
168                         <fileset dir="${src-test.dir}">
169                             <include name="**/*.java"/>
170                         </fileset>
171                         <filterchain>
172                                 <linecontainsregexp>
173                                         <regexp pattern="\P{ASCII}"/>
174                                 </linecontainsregexp>
175                         </filterchain>
176                 </concat>
177                 <loadfile srcfile="${ascii.file}" property="nonascii"/>
178                 <delete file="${ascii.file}"/>
179                 <fail if="nonascii">Non-ASCII characters exist in project:
180 ${nonascii}</fail>
181                 <echo>No non-ASCII characters in project.</echo>
182         </target>
183         
184         
185         <!--  Unit tests  -->
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"/>
190                 
191                 <echo>Running unit tests</echo>
192                 <mkdir dir="tmp/rawtestoutput"/>
193                 <junit fork="yes" forkmode="once" printsummary="false" failureproperty="junit.failure">
194                         <classpath>
195                                 <path refid="test-classpath"/>
196                                 <path location="${basedir}"/>
197                         </classpath>
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" />
204                                 </fileset>
205                                 <formatter type="xml"/>
206                         </batchtest>
207                 </junit>
208                 <junitreport todir="tmp">
209                         <fileset dir="tmp/rawtestoutput"/>
210                         <report todir="tmp/test-reports"/>
211                 </junitreport>
212                 <fail if="junit.failure" message="Unit test(s) failed.  See report in ${basedir}/tmp/test-reports/index.html"/>
213                 <echo>
214         Unit tests passed successfully.
215                 </echo>
216         </target>
217     
218 </project>