205fb246bcfee2b454e7190dacc92f01925f5e31
[debian/openrocket] / core / build.xml
1 <project name="OpenRocket" basedir=".">
2
3         <property file="resources/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}/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"/>
40         </path>
41         
42
43         
44         <!-- CLEAN -->
45         <target name="clean">
46                 <delete dir="${build.dir}"/>
47                 <delete dir="tmp/"/>
48         </target>
49                 
50         
51         <!-- BUILD -->
52         <target name="build">
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"/>
56         </target>
57         
58         
59         <!-- JAR -->
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/" includes="datafiles/ pix/ l10n/ build.properties" />
64                         <fileset dir="src/" includes="META-INF/" />
65                 </copy>
66                 <mkdir dir="${jar.dir}"/>
67                 <jar destfile="${jar.file}" basedir="${dist.dir}">
68                         <manifest>
69                                 <attribute name="Main-Class" value="${main-class}"/>
70                                 <attribute name="SplashScreen-Image" value="pix/splashscreen.png"/>
71                         </manifest>
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" />
76                 </jar>
77         </target>
78         
79         
80         <!-- DIST-SRC -->
81         <target name="dist-src">
82                 <echo>                  
83                 Building source distribution
84                 </echo>
85                 <mkdir dir="${build.dir}/${pkgname}"/>
86                 <mkdir dir="${jar.dir}"/>
87                 <copy todir="${build.dir}/${pkgname}">
88                         <fileset dir="." includes="*" excludes="*.log">
89                                 <type type="file"/>
90                         </fileset>
91                         <fileset dir="" includes="resources/datafiles/ lib/ lib-test/ resources/pix/ src/ test/ resources/l10n/"/>
92                 </copy>
93                 <zip destfile="${dist.src}" basedir="${build.dir}" includes="${pkgname}/"/>
94                 <delete dir="${build.dir}/${pkgname}"/>
95         </target>
96         
97         
98         <!-- DIST-SRC-TEST -->
99         <target name="dist-src-test" depends="dist-src">
100                 <echo>
101                 Testing source distribution
102                 </echo>
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}"/>
109                 <echo>
110                 Source distribution test successful
111                 </echo>
112         </target>       
113         
114         
115         <!-- DIST-BIN -->
116         <target name="dist-bin" depends="check,clean,unittest,jar">
117                 <move file="${jar.file}" tofile="${dist.bin}"/>
118         </target>
119
120         
121         <!-- DIST -->
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>
124         </target>
125         
126         
127         <!-- CHECK -->
128         <target name="check" depends="checktodo,checkascii"/>
129         
130         <!-- CHECK TODOs -->
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"/>
138                         </fileset>
139                         <fileset dir="${src-test.dir}">
140                             <include name="**/*.java"/>
141                         </fileset>
142                         <filterchain>
143                                 <linecontainsregexp>
144                                         <regexp pattern="(FIXME|TODO:.*CRITICAL)"/>
145                                 </linecontainsregexp>
146                         </filterchain>
147                 </concat>
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>
153         </target>
154         
155         
156         <!-- CHECK TODOs -->
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"/>
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="false" 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                                         <include name="**/*Test.class" />
199                                         <exclude name="**/*$*.class" />
200                                         <exclude name="Test.class" />
201                                 </fileset>
202                                 <formatter type="xml"/>
203                         </batchtest>
204                 </junit>
205                 <junitreport todir="tmp">
206                         <fileset dir="tmp/rawtestoutput"/>
207                         <report todir="tmp/test-reports"/>
208                 </junitreport>
209                 <fail if="junit.failure" message="Unit test(s) failed.  See report in ${basedir}/tmp/test-reports/index.html"/>
210                 <echo>
211         Unit tests passed successfully.
212                 </echo>
213         </target>
214     
215 </project>