-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
205 lines (179 loc) · 7.89 KB
/
build.xml
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
<project name="Sidannarverkefni" default="jar" basedir=".">
<!-- ======================================================== -->
<!-- Global properties -->
<!-- ======================================================== -->
<property name="root.dir" value="build"/>
<property name="src.java" value="src"/>
<property name="output.dir" value="${root.dir}/classes"/>
<property name="dist.dir" value="${root.dir}/dist"/>
<property name="lib.dir" value="lib"/>
<property name="instrumented.dir" value="${root.dir}/instrumented"/>
<property name="jar.file" value="Sidannarverkefni.jar"/>
<property name="test.dir" location="${output.dir}/tests" />
<property name="cobertura.dir" location="${lib.dir}/cobertura" />
<taskdef resource="checkstyletask.properties"
classpath="lib/checkstyle/checkstyle-5.6-all.jar"/>
<path id="classpath.base">
<pathelement location="${output.dir}" />
</path>
<path id="classpath.test">
<pathelement location="lib/junit-4.9.jar" />
<pathelement location="${test.dir}" />
<path refid="classpath.base" />
</path>
<path id="cobertura.classpath">
<pathelement location="${cobertura.dir}/cobertura.jar" />
<pathelement location="${cobertura.dir}/asm-3.0.jar" />
<pathelement location="${cobertura.dir}/asm-tree-3.0.jar" />
<pathelement location="${cobertura.dir}/jakarta-oro-2.0.8.jar" />
<pathelement location="${cobertura.dir}/log4j-1.2.9.jar" />
<path refid="classpath.test" />
</path>
<taskdef classpathref="cobertura.classpath" resource="tasks.properties"/>
<path id="checkstyle.depend">
<pathelement location="lib/checkstyle/antlr-2.7.7.jar" />
<pathelement location="lib/checkstyle/commons-beanutils-core-1.8.3.jar" />
<pathelement location="lib/checkstyle/commons-cli-1.2.jar" />
<pathelement location="lib/checkstyle/google-collections-1.0.jar" />
<pathelement location="lib/checkstyle/checkstyle-5.6-all.jar.jar" />
</path>
<!-- ======================================================== -->
<target name="checkstyle"
description="Generates a report of code convention violations.">
<checkstyle config="codingrules.xml"
failureProperty="checkstyle.failure"
failOnViolation="false">
<fileset dir="src" includes="**/*.java"/>
<classpath refid="checkstyle.depend" />
</checkstyle>
</target>
<!-- ======================================================== -->
<target name="init" depends="checkstyle"
description="Prepare by creating output directories">
<mkdir dir="${output.dir}"/>
<mkdir dir="${dist.dir}"/>
<mkdir dir="${test.dir}"/>
<mkdir dir="${instrumented.dir}"/>
</target>
<!-- ======================================================== -->
<target name="compile" depends="init"
description="Compilation of all source files">
<javac debug="true" srcdir="${src.java}"
destdir="${output.dir}" >
<classpath refid="cobertura.classpath" />
</javac>
</target>
<target name="instrument" depends="init,compile">
<!--
Remove the coverage data file and any old instrumentation.
-->
<delete file="cobertura.ser"/>
<delete dir="${instrumented.dir}" />
<!--
Instrument the application classes, writing the
instrumented classes into ${build.instrumented.dir}.
-->
<cobertura-instrument todir="${instrumented.dir}">
<!--
The following line causes instrument to ignore any
source line containing a reference to log4j, for the
purposes of coverage reporting.
-->
<ignore regex="org.apache.log4j.*" />
<fileset dir="${output.dir}">
<!--
Instrument all the application classes, but
don't instrument the test classes.
-->
<include name="**/*.class" />
<exclude name="**/*Test.class" />
</fileset>
</cobertura-instrument>
</target>
<!-- ======================================================== -->
<target name="test" depends="compile">
<junit fork="yes" dir="${basedir}" failureProperty="test.failed">
<!--
Note the classpath order: instrumented classes are before the
original (uninstrumented) classes. This is important.
-->
<classpath location="${instrumented.dir}" />
<classpath location="${output.dir}" />
<!--
The instrumented classes reference classes used by the
Cobertura runtime, so Cobertura and its dependencies
must be on your classpath.
-->
<classpath refid="cobertura.classpath" />
<formatter type="xml" />
<test name="tests.UnitTests" />
<batchtest todir="${root.dir}">
<fileset dir="src">
<include name="**/*Test.java" />
</fileset>
</batchtest>
</junit>
<junitreport todir="${root.dir}">
<fileset dir="${root.dir}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${root.dir}" />
</junitreport>
</target>
<!-- ======================================================== -->
<target name="coverage-check">
<cobertura-check branchrate="34" totallinerate="100" />
</target>
<target name="coverage-report">
<!--
Generate an XML file containing the coverage data using
the "srcdir" attribute.
-->
<cobertura-report srcdir="src" destdir="${root.dir}" format="xml" />
</target>
<target name="summary-coverage-report">
<!--
Generate an summary XML file containing the coverage data using
the "srcdir" attribute.
-->
<cobertura-report srcdir="src" destdir="${root.dir}" format="summaryXml" />
</target>
<target name="alternate-coverage-report">
<!--
Generate a series of HTML files containing the coverage
data in a user-readable form using nested source filesets.
-->
<cobertura-report destdir="${root.dir}">
<fileset dir="src">
<include name="**/*.java"/>
</fileset>
</cobertura-report>
</target>
<target name="jar" depends="test"
description="Create the JAR">
<jar jarfile="${dist.dir}/${jar.file}">
<fileset dir="${output.dir}">
<exclude name="**/tests/**"/>
</fileset>
<manifest>
<attribute name="Main-Class" value="Game.Application"/>
</manifest>
</jar>
</target>
<!-- ======================================================== -->
<target name="run" depends="jar"
description="Runs the process">
<java classname="Game.Application">
<classpath>
<pathelement path="${java.class.path}"/>
<pathelement location="${dist.dir}/Sidannarverkefni.jar"/>
</classpath>
</java>
</target>
<!-- ======================================================== -->
<target name="clean" depends="jar" description="Delete all generated files">
<delete dir="${output.dir}" />
<delete dir="${test.dir}"/>
</target>
<target name="coverage" depends="compile,instrument,test,coverage-report,summary-coverage-report,alternate-coverage-report" description="Compile, instrument ourself, run the tests and generate JUnit and coverage reports."/>
</project>