-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.xml
303 lines (278 loc) · 10.7 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
<project name="MessagePack for Java" default="jar"
xmlns:ivy="antlib:org.apache.ivy.ant"
xmlns:mvn="urn:maven-artifact-ant">
<property name="Name" value="MessagePack"/>
<property name="name" value="msgpack"/>
<property name="version" value="0.0.1"/>
<property name="fullname" value="${name}-${version}"/>
<property name="year" value="2011"/>
<!-- Load user's default properties. -->
<property file="${user.home}/build.properties" />
<property name="src.dir" value="${basedir}/src/main/java"/>
<property name="java.src.dir" value="${src.dir}/"/>
<property name="build.dir" value="${basedir}/build"/>
<property name="lib.dir" value="${basedir}/lib"/>
<property name="dist.dir" value="${basedir}/dist"/>
<property name="build.classes" value="${build.dir}/classes"/>
<property name="build.doc" value="${build.dir}/doc"/>
<property name="build.javadoc" value="${build.doc}/api/"/>
<property name="build.javadoc.log" value="${build.dir}/javadoc.log"/>
<property name="test.count" value="100"/>
<property name="test.junit.output.format" value="plain"/>
<property name="test.java.src.dir" value="${basedir}/src/test/java"/>
<property name="test.java.build.dir" value="${build.dir}/test"/>
<property name="test.java.classes" value="${test.java.build.dir}/classes"/>
<property name="test.java.include" value="Test*"/>
<property name="javac.encoding" value="ISO-8859-1"/>
<property name="javac.debug" value="on"/>
<property name="javac.optimize" value="on"/>
<property name="javac.deprecation" value="off"/>
<property name="javac.version" value="1.6"/>
<property name="javac.args" value=""/>
<property name="javac.args.warnings" value="-Xlint:unchecked"/>
<property name="javadoc.link.java"
value="http://java.sun.com/javase/6/docs/api/"/>
<property name="javadoc.packages" value="org.${name}.*"/>
<!-- ivy settings -->
<property name="ivy.version" value="2.1.0"/>
<property name="ivy.url"
value="http://repo2.maven.org/maven2/org/apache/ivy/ivy" />
<property name="ivy.home" value="${user.home}/.ant" />
<property name="ivy.lib" value="${build.dir}/lib"/>
<property name="ivy.test.lib" value="${build.dir}/test/lib"/>
<property name="mvn.repo"
value="https://repository.apache.org/content/repositories/snapshots"/>
<!-- the normal classpath -->
<path id="libs">
<fileset dir="${ivy.lib}">
<include name="**/*.jar" />
</fileset>
</path>
<path id="java.classpath">
<pathelement location="${build.classes}"/>
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
<exclude name="**/excluded/" />
</fileset>
<fileset dir="${ant.home}/lib">
<include name="ant.jar" />
</fileset>
<path refid="libs" />
</path>
<path id="test.libs">
<fileset dir="${ivy.test.lib}">
<include name="**/*.jar" />
</fileset>
</path>
<path id="test.java.classpath">
<pathelement location="${test.java.classes}" />
<path refid="java.classpath"/>
<path refid="test.libs"/>
</path>
<!-- init & clean -->
<target name="init">
<mkdir dir="${build.dir}" />
<mkdir dir="${lib.dir}" />
<mkdir dir="${build.classes}" />
<mkdir dir="${test.java.build.dir}"/>
<mkdir dir="${test.java.classes}"/>
<mkdir dir="${ivy.lib}"/>
<mkdir dir="${ivy.test.lib}"/>
<condition property="ivy.jar.exists">
<available file="${lib.dir}/ivy-${ivy.version}.jar"/>
</condition>
</target>
<target name="clean">
<delete dir="${build.dir}" />
</target>
<!-- ivy targets -->
<target name="ivy-download" unless="ivy.jar.exists" depends="init">
<delete dir="${lib.dir}"
includes="ivy-*.jar" excludes="ivy-${ivy.version}.jar"/>
<get src="${ivy.url}/${ivy.version}/ivy-${ivy.version}.jar"
dest="${lib.dir}/ivy-${ivy.version}.jar" usetimestamp="true"/>
</target>
<target name="ivy-init" depends="ivy-download" unless="ivy.initialized">
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant" classpathref="java.classpath"/>
<!-- ensure that ivy taskdef is only run once, otw ant will error -->
<property name="ivy.initialized" value="true"/>
</target>
<target name="ivy-retrieve-build" depends="init,ivy-init">
<ivy:retrieve type="jar" conf="build"
pattern="${ivy.lib}/[artifact]-[revision].[ext]"/>
</target>
<target name="ivy-retrieve-test" depends="init,ivy-init">
<ivy:retrieve type="jar" conf="test"
pattern="${ivy.test.lib}/[artifact]-[revision].[ext]"/>
</target>
<!-- compiler -->
<macrodef name="java-compiler">
<attribute name="dest" default="${build.classes}"/>
<attribute name="includes" default="**/*.java"/>
<attribute name="excludes" default=""/>
<attribute name="classpath" default="java.classpath"/>
<element name="src" implicit="yes"/>
<sequential>
<javac
destdir="@{dest}"
includes="@{includes}"
excludes="@{excludes}"
encoding="${javac.encoding}"
debug="${javac.debug}"
optimize="${javac.optimize}"
target="${javac.version}"
source="${javac.version}"
deprecation="${javac.deprecation}">
<compilerarg line="${javac.args} ${javac.args.warnings}" />
<classpath refid="@{classpath}"/>
<src />
</javac>
</sequential>
</macrodef>
<!-- compile -->
<target name="compile" depends="init,ivy-retrieve-build">
<java-compiler>
<src path="${java.src.dir}"/>
</java-compiler>
</target>
<!-- test -->
<macrodef name="test-runner">
<attribute name="files.location" />
<attribute name="tests.pattern" />
<attribute name="test.dir" default="${test.java.build.dir}" />
<sequential>
<junit showoutput="yes"
printsummary="withOutAndErr"
haltonfailure="no"
fork="yes" forkMode="once"
errorProperty="tests.failed" failureProperty="tests.failed">
<sysproperty key="test.count" value="${test.count}"/>
<sysproperty key="test.dir" value="@{test.dir}"/>
<classpath refid="test.java.classpath"/>
<formatter type="${test.junit.output.format}"/>
<batchtest todir="${test.java.build.dir}" unless="testcase">
<fileset dir="@{files.location}"
includes="@{tests.pattern}"
excludes="**/${test.java.exclude}.java" />
</batchtest>
<batchtest todir="${test.java.build.dir}" if="testcase">
<fileset dir="@{files.location}" includes="**/${testcase}.java"/>
</batchtest>
</junit>
<fail if="tests.failed">Tests Failed!</fail>
</sequential>
</macrodef>
<target name="compile-test" depends="ivy-retrieve-test,compile">
<java-compiler dest="${test.java.classes}"
classpath="test.java.classpath">
<src path="${test.java.src.dir}/org" />
</java-compiler>
</target>
<target name="test" depends="init,compile-test">
<test-runner files.location="${test.java.src.dir}"
tests.pattern="**/${test.java.include}.java"/>
</target>
<!-- jar -->
<target name="jar" depends="compile">
<jar jarfile="${build.dir}/${name}-${version}.jar" basedir="${build.classes}" >
<manifest>
<section name="org/${name}">
<attribute name="Implementation-Title" value="${Name}"/>
<attribute name="Implementation-Version" value="${version}"/>
</section>
</manifest>
</jar>
</target>
<!-- javadoc -->
<target name="javadoc" depends="compile" description="Generate javadoc">
<mkdir dir="${build.javadoc}"/>
<record name="${build.javadoc.log}" action="start"/>
<javadoc
Locale="en_US"
packagenames="org.${org}.${name}.*"
destdir="${build.javadoc}"
encoding="UTF-8"
docencoding="UTF-8"
author="true"
version="true"
use="true"
windowtitle="${Name} ${version} API"
doctitle="${Name} ${version} API"
bottom="Copyright &copy; ${year} The ${Name} Project"
>
<packageset dir="${java.src.dir}"/>
<link href="${javadoc.link.java}"/>
<classpath >
<path refid="java.classpath" />
</classpath>
</javadoc>
<record name="${build.javadoc.log}" action="stop"/>
<condition property="javadoc.warnings">
<isfileselected file="${build.javadoc.log}">
<contains text=": warning - "/>
</isfileselected>
</condition>
<fail if="javadoc.warnings">Javadoc warnings!</fail>
</target>
<target name="javadoc-jar" depends="javadoc">
<jar jarfile="${build.dir}/${fullname}-javadoc.jar">
<fileset dir="${build.javadoc}" includes="**/*"/>
</jar>
</target>
<!-- sources -->
<target name="source">
<jar jarfile="${build.dir}/${fullname}-sources.jar">
<fileset dir="${java.src.dir}" includes="**/*.java"/>
</jar>
</target>
<!-- pom -->
<target name="pom" depends="ivy-init">
<ivy:makepom ivyfile="${basedir}/ivy.xml"
pomfile="${dist.dir}/${fullname}.pom">
<mapping conf="default" scope="compile"/>
<mapping conf="test" scope="test"/>
</ivy:makepom>
</target>
<!-- dist -->
<target name="dist" depends="jar, pom, source, javadoc-jar"
description="Build distribution">
<mkdir dir="${dist.dir}"/>
<copy todir="${dist.dir}">
<fileset file="${build.dir}/${fullname}.jar"/>
<fileset file="${build.dir}/${fullname}-sources.jar"/>
<fileset file="${build.dir}/${fullname}-javadoc.jar"/>
</copy>
</target>
<!-- maven: install msgpack into local m2 cache -->
<target name="mvn-install" depends="jar, pom, source, javadoc-jar"
description="Installs msgpack to local m2 cache">
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="urn:maven-artifact-ant"
classpathref="java.classpath"/>
<mvn:pom file="${dist.dir}/${fullname}.pom" id="msgpack"/>
<mvn:install file="${build.dir}/${fullname}.jar">
<attach file="${build.dir}/${fullname}-sources.jar"
classifier="sources" />
<attach file="${build.dir}/${fullname}-javadoc.jar"
classifier="javadoc" />
<pom refid="msgpack"/>
</mvn:install>
</target>
<!-- maven: create local repository into ${basedir}/maven2 -->
<target name="mvn-deploy" depends="jar, pom, source, javadoc-jar"
description="Deploys MessagePack to Maven repo.">
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="urn:maven-artifact-ant"
classpathref="java.classpath"/>
<mvn:pom file="${dist.dir}/${fullname}.pom" id="msgpack"/>
<mvn:deploy file="${build.dir}/${fullname}.jar">
<remoteRepository url="file://localhost/${basedir}/maven2/"/>
<attach file="${build.dir}/${fullname}-sources.jar"
classifier="sources" />
<attach file="${build.dir}/${fullname}-javadoc.jar"
classifier="javadoc" />
<pom refid="msgpack"/>
</mvn:deploy>
</target>
</project>