/
build.xml
305 lines (259 loc) · 10.5 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
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
<?xml version="1.0"?>
<project name="hqapi" default="compile" basedir=".">
<property environment="ENV" />
<property name="build.dir" location="build"/>
<property name="dist.dir" location="${build.dir}/dist"/>
<property name="javadoc.dir" location="${build.dir}/javadoc"/>
<property file="hqu/hqapi1/plugin.properties"/>
<path id="compile.classpath">
<fileset dir="lib" includes="*.jar"/>
</path>
<path id="all.classpath">
<fileset dir="lib" includes="*.jar"/>
<path location="${build.dir}/classes" />
</path>
<taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask"
classpathref="compile.classpath"/>
<taskdef name="wjc"
classname="org.jvnet.ws.wadl2java.WJCTask"
classpathref="compile.classpath"/>
<!-- Generate the Java XML bindings -->
<target name="generate">
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.dir}/src"/>
<mkdir dir="${build.dir}/classes"/>
<xjc destdir="${build.dir}/src" extension="true" removeOldOutput="yes"
package="org.hyperic.hq.hqapi1.types">
<schema dir="xsd" includes="HQApi1.xsd"/>
<produces dir="${build.dir}/src/org/hyperic/hq/hqapi1/types"
includes="**/"/>
</xjc>
<mkdir dir="${build.dir}/src/org/hyperic/hq/hqapi1/wadl"/>
<wjc description="xsd/HQApi1.wadl" package="org.hyperic.hq.hqapi1.wadl"
autoSchemaPackage="false" target="build/src">
<produces dir="build/src/org/hyperic/hq/hqapi1/wadl" includes="*.java"/>
</wjc>
</target>
<target name="compile" depends="generate">
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.dir}/src"/>
<mkdir dir="${build.dir}/classes"/>
<javac destdir="${build.dir}/classes"
optimize="off"
debug="on"
target="1.5" source="1.5"
classpathref="compile.classpath">
<src>
<path location="${build.dir}/src"/>
<path location="src"/>
</src>
</javac>
</target>
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<!-- Package a distribution -->
<target name="dist" depends="compile,javadoc">
<mkdir dir="${dist.dir}"/>
<!-- Copy UI plugin -->
<copy todir="${dist.dir}">
<fileset dir="hqu">
<include name="hqapi1/**"/>
</fileset>
</copy>
<!-- Bundle client package in plugin public directory with all
necessary jars, javadoc and xsds. -->
<property name="client.dir" value="${build.dir}/hqapi1-${plugin.version}"/>
<mkdir dir="${client.dir}"/>
<mkdir dir="${client.dir}/lib"/>
<copy todir="${client.dir}/lib">
<fileset dir="${basedir}/lib">
<include name="*.jar"/>
<exclude name="*clover*.jar"/>
</fileset>
</copy>
<copy todir="${client.dir}">
<fileset dir="${build.dir}">
<include name="javadoc/**"/>
</fileset>
</copy>
<jar file="${client.dir}/hqapi1-${plugin.version}.jar">
<fileset dir="${build.dir}/classes">
<include name="**"/>
<exclude name="**/test/*.class"/>
<!-- We don't include the wadl bindings -->
<exclude name="**/wadl/*.class"/>
</fileset>
</jar>
<mkdir dir="${client.dir}/xsd"/>
<copy toDir="${client.dir}/xsd">
<fileset dir="${basedir}/xsd">
<include name="*.xsd"/>
<include name="*.wadl"/>
</fileset>
</copy>
<mkdir dir="${client.dir}/bin"/>
<copy todir="${client.dir}/bin">
<fileset dir="${basedir}/bin">
<include name="*.sh"/>
<include name="*.bat"/>
</fileset>
</copy>
<chmod perm="+x" type="file">
<fileset dir="${client.dir}/bin">
<include name="*.sh"/>
<include name="*.bat"/>
</fileset>
</chmod>
<mkdir dir="${dist.dir}/hqapi1/public"/>
<tar tarfile="${dist.dir}/hqapi1/public/hqapi1-${plugin.version}.tar.gz"
longfile="gnu"
compression="gzip">
<tarfileset dir="${build.dir}" mode="755">
<include name="hqapi1-${plugin.version}/**"/>
</tarfileset>
</tar>
<!-- Include hqapi1.jar in plugin classpath -->
<copy toDir="${dist.dir}/hqapi1/lib"
file="${client.dir}/hqapi1-${plugin.version}.jar"/>
<zip destfile="${dist.dir}/hqapi1-${plugin.version}.zip"
basedir="${dist.dir}"/>
</target>
<!-- Run a single test -->
<target name="single-test">
<fail message="Must specify a test case system property: -Dtestcase=org.hyperic.My_test"
unless="testcase"/>
<echo message="Running Single Test: ${testcase}"/>
<antcall target="test">
<param name="single.test" value="true" />
</antcall>
</target>
<!-- Run the full test suite -->
<target name="test" depends="compile">
<mkdir dir="${build.dir}/testresults"/>
<property name="log" value="info"/>
<junit printsummary="yes" fork="no"
haltonfailure="no" showoutput="true">
<sysproperty key="log" value="${log}"/>
<sysproperty key="clover.distributed.coverage" value="ON"/>
<sysproperty key="clover.server" value="true"/>
<classpath refid="all.classpath"/>
<formatter type="xml"/>
<test name="${testcase}" todir="${build.dir}/testresults"
if="single.test" />
<batchtest fork="no" todir="${build.dir}/testresults"
unless="single.test">
<fileset dir="${build.dir}/classes">
<include name="**/*_test.class"/>
<!-- temp exclude until we re-enable SSL -->
<exclude name="**/SSL_test.class"/>
</fileset>
</batchtest>
</junit>
<junitreport todir="${build.dir}/testresults">
<fileset dir="${build.dir}/testresults">
<include name="*.xml" />
</fileset>
<report todir="${build.dir}/testresults" />
</junitreport>
</target>
<!-- Target to hot deploy the plugins into a running HQ instance -->
<target name="deploy" depends="dist">
<delete dir="${ENV.TOMCAT_HOME}/webapps/ROOT/hqu/hqapi1"/>
<sleep seconds="2"/>
<copy toDir="${ENV.TOMCAT_HOME}/webapps/ROOT/hqu/">
<fileset dir="${dist.dir}">
<include name="hqapi1/**"/>
</fileset>
</copy>
</target>
<target name="javadoc">
<mkdir dir="${javadoc.dir}"/>
<javadoc destdir="${javadoc.dir}"
private="false"
package="false"
protected="false"
version="true"
author="true"
maxmemory="256M"
use="true"
packagenames="org.hyperic.*"
excludepackagenames="org.hyperic.hq.hqapi1.test.*,org.hyperic.hq.hqapi1.examples.*,org.hyperic.hq.hqapi1.tools.*,org.hyperic.hq.hqapi1.wadl.*"
windowtitle="Hyperic HQ API">
<sourcepath>
<pathelement location="src"/>
<pathelement location="${build.dir}/src"/>
</sourcepath>
<classpath>
<path refid="all.classpath"/>
</classpath>
<doctitle><![CDATA[Hyperic HQ API Specification]]></doctitle>
<bottom>
<![CDATA[Copyright © 2008 <a href="http://www.hyperic.com">Hyperic, Inc.</a>, All Rights Reserved.]]>
</bottom>
</javadoc>
</target>
<property name="clover.output.dir" value="${build.dir}/clover"/>
<property name="clover.staging.dir" value="${clover.output.dir}/staging"/>
<property name="clover.coverage" value="0%"/>
<property name="clover.enforce" value="false"/>
<target name="clover" depends="clover.pre, clover.instrument, clover.compile, test" description="Executes all tests resulting from a compilation of the test tree returning test coverage metrics."/>
<target name="clover.init">
<taskdef resource="cloverlib.xml" classpathref="compile.classpath"/>
</target>
<target name="clover.pre">
<delete dir="${clover.output.dir}" quiet="true"/>
<mkdir dir="${clover.output.dir}"/>
</target>
<target name="clover.instrument" depends="clover.init">
<instrument input.dir="src" output.dir="${clover.staging.dir}"/>
</target>
<target name="clover.compile" depends="generate">
<javac destdir="${build.dir}/classes"
optimize="off"
debug="on"
target="1.5" source="1.5"
classpathref="compile.classpath">
<src>
<path location="${build.dir}/src"/>
<path location="${clover.staging.dir}"/>
</src>
</javac>
<delete dir="${clover.staging.dir}" quiet="true"/>
</target>
<macrodef name="instrument">
<attribute name="input.dir"/>
<attribute name="output.dir"/>
<sequential>
<clover-instr initstring="${clover.db.file}" destdir="@{output.dir}" source="1.5">
<fileset dir="@{input.dir}">
<include name="**/*.java"/>
</fileset>
</clover-instr>
<copy todir="@{output.dir}">
<fileset dir="@{input.dir}">
<exclude name="**/*.java"/>
<exclude name="*.java"/>
</fileset>
</copy>
</sequential>
</macrodef>
<target name="clover.post" depends="clover.init">
<clover-report initstring="${clover.db.file}">
<current outfile="${clover.output.dir}/clover.xml">
<format type="xml"/>
</current>
</clover-report>
<clover-report initstring="${clover.db.file}">
<current outfile="${clover.output.dir}/html">
<format type="html"/>
</current>
</clover-report>
<clover-report initstring="${clover.db.file}">
<current outfile="${clover.output.dir}/clover.pdf" summary="true">
<format type="pdf"/>
</current>
</clover-report>
<clover-check initstring="${clover.db.file}" target="${clover.coverage}" haltOnFailure="${clover.enforce}"/>
</target>
</project>