File: build.xml

package info (click to toggle)
caveconverter 0~20170114-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 4,792 kB
  • sloc: java: 9,290; xml: 242; makefile: 18
file content (308 lines) | stat: -rw-r--r-- 14,788 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
<?xml version="1.0" encoding="UTF-8"?>
<project name="CaveSurveyConverter" default="all" basedir="." >
	
	<property environment="env"/>
    <description>Compiles the CaveConverter project, builds excutable JARs for the command line converter and windowed application and runs automated tests.</description>

    <!-- include property file for build customizations -->
    <property file="build.properties"/>

    <property name="src.dir" value="src"/>
    <property name="test.dir" value="test"/>
    <property name="build.dir" value="build"/>
    <property name="build.classes.dir" value="${build.dir}/classes"/>
    <property name="build.data.dir" value="${build.dir}/test/data"/>
    <property name="instrumented.classes.dir" value="${build.dir}/instrumented_classes"/>
    <property name="test.classes.dir" value="${build.dir}/test_classes"/>
	<property name="rel.pack.dir" value="${build.dir}/CaveConverter"/>
    <property name="docs.dir" value="doc"/>
    <property name="dist.dir" value="dist"/>
    <property name="cmdjarfilename" value="CaveConverter.jar"/>
    <property name="guijarfilename" value="CaveConverterGUI.jar"/>
    <property name="javadoc.dir" value="${build.dir}/javadoc"/>
    <property name="testreports.dir" value="${build.dir}/reports"/>
    <property name="coveragereports.dir" value="${build.dir}/coveragereports"/>
    <property name="cobertura.ser" value="${basedir}/cobertura.ser"/>

    <property name="lib.dir" value="/usr/share/java/"/>

	<property name="source.version" value="1.6"/>
    <property name="target.version" value="1.6"/>
    <property name="build.debug" value="true"/>	

    <property name="cobertura.dir" value="${lib.dir}"/>
    <property name="junit.dir" value="${lib.dir}"/>

    <!-- Cobertura -->
    <path id="cobertura.classpath">
        <fileset dir="${cobertura.dir}">
            <include name="cobertura*.jar" />
        </fileset>
    </path>
    <taskdef classpathref="cobertura.classpath" resource="tasks.properties" />


    <fileset dir="${junit.dir}" id="junit.jars">
        <include name="junit4.jar" />
    </fileset>

    <path id="javasrc.classpath">
        <path refid="cobertura.classpath" />
    </path>

    <path id="test.compile.classpath">
        <path refid="javasrc.classpath"/>
        <pathelement path="${instrumented.classes.dir}"/>
        <pathelement path="${build.classes.dir}"/>
        <fileset refid="junit.jars"/>
        <path refid="cobertura.classpath" />
    </path>

    <path id="test.run.classpath">
        <path refid="test.compile.classpath"/>
        <pathelement path="${test.classes.dir}"/>
    </path>

    <target name="init" >
     	<echo message="JAVA_HOME = ${env.JAVA_HOME}" />
        <mkdir dir="${build.classes.dir}"/>
        <mkdir dir="${dist.dir}"/>
        <mkdir dir="${build.data.dir}/private"/>
    </target>

    <target name="clean" depends="clean.tests" description="Cleans up all build and test output apart from coverage reports and javadoc." >
        <delete dir="${build.classes.dir}" failonerror="on"/>
        <delete dir="${build.data.dir}" failonerror="on"/>
        <delete dir="${rel.pack.dir}" failonerror="on"/>
        <delete dir="${dist.dir}" failonerror="on"/>
    	<delete file="${build.dir}/${cmdjarfilename}"  failonerror="on"/>
    	<delete file="${build.dir}/${guijarfilename}"  failonerror="on"/>
    </target>

    <target name="compile" depends="init" description="Compiles all the Java source code." >
        <javac debug="${build.debug}" srcdir="${src.dir}" destdir="${build.classes.dir}" 
               source="${source.version}" target="${target.version}" 
               classpathref="javasrc.classpath" includeantruntime="false" />
		<copy todir="${build.classes.dir}/footleg/cavesurvey/gui/swing/images">
			<fileset dir="${src.dir}/footleg/cavesurvey/gui/swing/images"/>
		</copy>
		<copy tofile="${build.classes.dir}/footleg/cavesurvey/gui/app.properties">
			<fileset file="build.properties"/>
		</copy>
    </target>

    <!-- Complete rebuild and test -->
    <target name="all" depends="clean,zip,zipsrc,coverage.regressions,javadoc" 
		description="Complete clean rebuild of code. Runs all tests, generates all reports and zip archives." />
	
    <!-- Build jar file for release -->
    <target name="jar" depends="compile" description="Compiles all code and assembles a jar file for the command line tool." >
        <antcall target="makejar">
            <param name="main_class" value="footleg.cavesurvey.converter.CaveConverter"/>
            <param name="jarfilename" value="${cmdjarfilename}"/>
            <param name="exclude" value="**/gui/**"/>
        </antcall>
    </target>

    <target name="guijar" depends="compile" description="Compiles all code and assembles a jar file for the Swing GUI applicaton." >
        <antcall target="makejar">
            <param name="main_class" value="footleg.cavesurvey.gui.swing.MainForm"/>
            <param name="jarfilename" value="${guijarfilename}"/>
            <param name="exclude" value="**/gui/javafx/**"/>
        </antcall>
    </target>
	
    <target name="makejar" description="Assembles a jar file using the main class defined before calling this target." >
        <jar destfile="${build.dir}/${jarfilename}" basedir="${build.classes.dir}" 
    	     includes="footleg/**/*" excludes="${exclude}" >
            <manifest>
                <attribute name="Main-Class" 
                		value="${main_class}"/>
		        <attribute name="Implementation-Vendor"
		                value="${application.vendor}"/>
		        <attribute name="Implementation-Title"
		                value="${application.title}"/>
		        <attribute name="Implementation-Version" 
		        		value="${build.version}"/>
            </manifest>
        </jar>
    </target>

    <!-- =================================================================== -->
    <!-- Creates a zip file containing the binary release                    -->
    <!-- =================================================================== -->
	<target name="zip" depends="jar,guijar" description="Builds the re-distributable zip file of the complete application (excluding source code)." >
        <zip destfile="${dist.dir}/CaveConverter.zip" >
    		<zipfileset file="${build.dir}/${cmdjarfilename}" prefix="CaveConverter" />
    		<zipfileset file="${build.dir}/${guijarfilename}" prefix="CaveConverter" />
            <zipfileset dir="${docs.dir}" prefix="CaveConverter" >
	            <include name="*.bat" />
	            <include name="change_log.txt" />
	            <include name="readme.html" />
	            <include name="cmdlineref.html" />
	            <include name="SwildonsEntSeriesModel.png" />
            </zipfileset>
        </zip>
    </target>

    <!-- =================================================================== -->
    <!-- Creates a zip file containing the source and public tests release   -->
    <!-- =================================================================== -->
	<target name="zipsrc" depends="init" description="Builds the re-distributable zip file of the project source code." >
        <zip destfile="${dist.dir}/CaveConverter-src.zip" >
            <zipfileset dir="${docs.dir}" prefix="CaveConverter_src/doc" >
	            <include name="*.bat" />
	            <include name="change_log.txt" />
	            <include name="COPYING" />
	            <include name="readme.html" />
	            <include name="cmdlineref.html" />
	            <include name="SwildonsEntSeriesModel.png" />
            </zipfileset>
    		<zipfileset dir="src" prefix="CaveConverter_src/src" >
	            <exclude name="**/gui/javafx/**" />
            </zipfileset>
    		<zipfileset dir="test" prefix="CaveConverter_src/test" >
	            <exclude name="**/*.bat" />
	            <exclude name="**/name/**" />
	            <exclude name="**/regression/*Private*" />
	            <exclude name="data/**" />
            </zipfileset>
    		<zipfileset dir="test/data/regression" prefix="CaveConverter_src/test/data/regression" >
		        <include name="*.dat" />
	            <include name="*.dxf" />
	            <include name="*.text" />
	            <include name="*.txt" />
		        <include name="*.svx" />
            </zipfileset>
    		<zipfileset file="build.xml" prefix="CaveConverter_src" />
    		<zipfileset file="build.properties" prefix="CaveConverter_src" />
    		<zipfileset file="README" prefix="CaveConverter_src" />
        </zip>
    </target>

	<!-- =================================================================== -->
    <!-- Targets to test java classes                                        -->
    <!-- =================================================================== -->
    <target name="clean.tests" >
        <delete dir="${test.classes.dir}" failonerror="on"/>
        <delete dir="${testreports.dir}" failonerror="on"/>
    	<delete dir="${instrumented.classes.dir}"  failonerror="on"/>
    	<delete file="${cobertura.ser}"  failonerror="on"/>
    	<delete file="${basedir}/CaveConverter.log"  failonerror="on"/>
    </target>

    <target name="init.tests" >
        <mkdir dir="${test.classes.dir}"/>
        <mkdir dir="${testreports.dir}"/>
        <mkdir dir="${build.classes.dir}"/>
    </target>

    <target name="compile.test" depends="jar,instrument.java,init.tests" >
        <javac debug="${build.debug}" srcdir="${test.dir}" destdir="${test.classes.dir}"
               source="${source.version}" target="${target.version}"
               classpathref="test.compile.classpath" includeantruntime="false" />
    </target>

    <!-- =================================================================== -->
    <!-- Execute unit tests.                                                 -->
    <!-- =================================================================== -->
	
    <!-- Fileset for classes to run unit tests -->
	<fileset dir="${test.dir}" id="unit.tests">
        <include name="**/*Test.java"/>
        <exclude name="**/regression/*Test.java"/>
    </fileset>
	
    <!-- Fileset for classes to run regression tests -->
	<fileset dir="${test.dir}" id="regression.tests">
        <include name="**/regression/*Test.java"/>
    </fileset>

    <target name="unit.test" depends="clean.tests, compile.test" description="Runs all unit tests." >
        <junit printsummary="yes" fork="yes" showoutput="off" haltonfailure="on" >
            <sysproperty key="net.sourceforge.cobertura.datafile" file="${cobertura.ser}" />
            <classpath refid="test.run.classpath"/>
            <batchtest fork="yes" todir="${testreports.dir}">
            	<fileset refid="unit.tests"/>
                <formatter type="xml"/>
            </batchtest>
        </junit>
    </target>
    
    <target name="test.all" depends="clean.tests, compile.test" description="Runs all unit tests and regression tests." >
        <junit printsummary="yes" fork="true" showoutput="off" haltonfailure="on" >
            <sysproperty key="net.sourceforge.cobertura.datafile" file="${cobertura.ser}" />
            <classpath refid="test.run.classpath"/>
            <batchtest fork="yes" todir="${testreports.dir}">
            	<fileset refid="unit.tests"/>
            	<fileset refid="regression.tests"/>
                <formatter type="xml"/>
            </batchtest>
        </junit>
    </target>
    

    <!-- =================================================================== -->
    <!-- Javadoc -->
    <!-- =================================================================== -->
    <path id="javadoc.classpath">
    	<!--     <path refid="javasrc.classpath"/>
        <fileset dir="${build.classes.dir}" >
            <include name="**/*.class" />
        </fileset>
		<fileset refid="jscience.jars" /> -->
    </path>
	
	<target name="javadoc" depends="compile" description="Compiles Javadoc for the project source code." >
        <javadoc packagenames="footleg.cavesurvey.*"
                 sourcepath="${src.dir}"
                 classpathref="javadoc.classpath"
                 defaultexcludes="yes"
                 destdir="${javadoc.dir}"
                 author="true"
                 version="true"
                 use="true"
                 windowtitle="Cave Converter Javadoc"
                 noindex="false" notree="false" nohelp="false" nonavbar="False"
                 verbose="false">
            <doctitle><![CDATA[<h1>Footleg Cave</h1>]]></doctitle>
            <bottom><![CDATA[<i>Copyright &#169; 2015 Footleg. Distributed under the terms of the GNU General Public License.</i>]]></bottom>
            <tag name="to.do" scope="all" description="To do:"/>
            <group title="Cave Converter" packages="footleg.cavesurvey.tools.cmdline"/>
            <group title="Cave Survey Data Model" packages="footleg.cavesurvey.data.model"/>
            <group title="Cave Survey File Readers/Writers" packages="footleg.cavesurvey.data.reader,footleg.cavesurvey.data.writer"/>
        </javadoc>
    </target>

    <!-- =================================================================== -->
    <!-- Java code coverage Cobertura                                        -->
    <!-- =================================================================== -->
    <target name="instrument.java">
    	<delete file="${cobertura.ser}"/>
        <cobertura-instrument todir="${instrumented.classes.dir}" datafile="${cobertura.ser}">
            <fileset dir="${build.classes.dir}">
                <include name="**/*.class"/>
            </fileset>
        </cobertura-instrument>
    </target>
	
    <target name="coverage" depends="unit.test" description="Runs unit tests and generates coverage reports for these tests." >
    	<delete dir="${coveragereports.dir}"/>
        <cobertura-report format="html" destdir="${coveragereports.dir}" datafile="${cobertura.ser}">
            <fileset dir="${src.dir}">
                <include name="**/*.java"/>
            </fileset>
        </cobertura-report>
    </target>

    <target name="coverage.regressions" depends="test.all" description="Runs unit tests and regression tests and generates coverage reports for all tests." >
    	<delete dir="${coveragereports.dir}"/>
        <cobertura-report format="html" destdir="${coveragereports.dir}" datafile="${cobertura.ser}">
            <fileset dir="${src.dir}">
                <include name="**/*.java"/>
            </fileset>
        </cobertura-report>
    </target>

</project>