update to 0.9.7pre
[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="todo" depends="checktodo"/>
134         <target name="checktodo">
135                 <tempfile property="todo.file" prefix="checktodo-"/>
136                 <echo>Checking project for critical TODOs.</echo>
137                 <concat destfile="${todo.file}">
138                         <fileset dir="${src.dir}">
139                             <include name="**/*.java"/>
140                         </fileset>
141                         <fileset dir="${src-test.dir}">
142                             <include name="**/*.java"/>
143                         </fileset>
144                         <filterchain>
145                                 <linecontainsregexp>
146                                         <regexp pattern="TODO:.*CRITICAL"/>
147                                 </linecontainsregexp>
148                         </filterchain>
149                 </concat>
150                 <loadfile srcfile="${todo.file}" property="criticaltodos"/>
151                 <delete file="${todo.file}"/>
152                 <fail if="criticaltodos">CRITICAL TODOs exist in project:
153 ${criticaltodos}</fail>
154                 <echo>No critical TODOs in project.</echo>
155         </target>
156         
157         
158         <!-- CHECK TODOs -->
159         <target name="ascii" depends="checkascii"/>
160         <target name="checkascii">
161                 <tempfile property="ascii.file" prefix="checkascii-"/>
162                 <echo>Checking project for non-ASCII characters.</echo>
163                 <concat destfile="${ascii.file}">
164                         <fileset dir="${src.dir}">
165                             <include name="**/*.java"/>
166                         </fileset>
167                         <fileset dir="${src-test.dir}">
168                             <include name="**/*.java"/>
169                         </fileset>
170                         <filterchain>
171                                 <linecontainsregexp>
172                                         <regexp pattern="\P{ASCII}"/>
173                                 </linecontainsregexp>
174                         </filterchain>
175                 </concat>
176                 <loadfile srcfile="${ascii.file}" property="nonascii"/>
177                 <delete file="${ascii.file}"/>
178                 <fail if="nonascii">Non-ASCII characters exist in project:
179 ${nonascii}</fail>
180                 <echo>No non-ASCII characters in project.</echo>
181         </target>
182         
183         
184         <!--  Unit tests  -->
185         <target name="unittest" description="Execute unit tests" depends="build">
186                 <echo>Building unit tests</echo>
187                 <mkdir dir="${build-test.dir}"/>
188                 <javac debug="true" srcdir="${src-test.dir}" destdir="${build-test.dir}" classpathref="test-classpath"/>
189                 
190                 <echo>Running unit tests</echo>
191                 <mkdir dir="tmp/rawtestoutput"/>
192                 <junit fork="yes" forkmode="once" printsummary="true" failureproperty="junit.failure">
193                         <classpath>
194                                 <path refid="test-classpath"/>
195                                 <path location="${basedir}"/>
196                         </classpath>
197                         <batchtest todir="tmp/rawtestoutput">
198                                 <fileset dir="${build-test.dir}">
199                                         <include name="**/*Test*.class" />
200                                         <exclude name="**/*$*.class" />
201                                         <exclude name="Test.class" />
202                                 </fileset>
203                                 <formatter type="xml"/>
204                         </batchtest>
205                 </junit>
206                 <junitreport todir="tmp">
207                         <fileset dir="tmp/rawtestoutput"/>
208                         <report todir="tmp/test-reports"/>
209                 </junitreport>
210                 <fail if="junit.failure" message="Unit test(s) failed.  See report in ${basedir}/tmp/test-reports/index.html"/>
211                 <echo>
212         Unit tests passed successfully.
213                 </echo>
214         </target>
215     
216 </project>