-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
329 lines (298 loc) · 13.1 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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
<?xml version='1.0' encoding='UTF-8' ?>
<!--
Copyright 2010-2013 Kevin Seim
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project name="beanio" xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<!-- Load build properties -->
<property file="build.properties" />
<!-- Load Maven Ant tasks -->
<path id="maven-ant-tasks.classpath" path="lib/maven-ant-tasks-2.1.1.jar" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="antlib:org.apache.maven.artifact.ant"
classpathref="maven-ant-tasks.classpath" />
<!-- Delete all build artifacts -->
<target name="clean" description="Delete all build artifacts">
<delete dir="${target}" />
</target>
<target name="init">
<tstamp />
<!-- create the build directory -->
<mkdir dir="${target}" />
<property name="classes.main" location="${target}/classes/main" />
<property name="classes.test" location="${target}/classes/test" />
<property name="classes.emma" location="${target}/classes/emma" />
<!-- main classpath -->
<path id="classpath.main">
<fileset dir="lib">
<include name="*.jar" />
</fileset>
</path>
</target>
<!-- Compile main source files (src -> target/classes/main) -->
<target name="compile" depends="init" description="Compiles Java source files under src/">
<mkdir dir="${classes.main}" />
<javac srcdir="src" destdir="${classes.main}" includeantruntime="false"
debug="true" source="1.5" target="1.5" classpathref="classpath.main" />
</target>
<!-- Create the beanio jar -->
<target name="jar" depends="compile" description="Creates beanio.jar">
<!-- Format the OSGi Export-Package manifiest header -->
<dirset id="osgi.dirs" dir="src/org/beanio">
<exclude name="xsd"/>
<exclude name="xsd/2012"/>
<exclude name="xsd/2011"/>
</dirset>
<pathconvert refid="osgi.dirs" property="osgi.packages" dirsep="." pathsep=';version="${version}",'>
<map from="${basedir}/src/" to=""/>
</pathconvert>
<property name="osgi.export-package" value='${osgi.packages};version="${version}"' />
<!-- JarJar is used to package ASM with BeanIO -->
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="lib/jarjar-1.3.jar"/>
<jarjar destfile="${target}/beanio.jar">
<manifest>
<attribute name="Implementation-Title" value="BeanIO ${version}" />
<attribute name="Implementation-Version" value="${version}" />
<!-- OSGi manifest headers -->
<attribute name="Bundle-ManifestVersion" value="2"/>
<attribute name="Bundle-Vendor" value="Kevin Seim"/>
<attribute name="Bundle-Name" value="BeanIO"/>
<attribute name="Bundle-Description" value="BeanIO OSGi support"/>
<attribute name="Bundle-SymbolicName" value="org.beanio"/>
<attribute name="Bundle-Version" value="${version}"/>
<attribute name="Bundle-License" value="http://www.apache.org/licenses/LICENSE-2.0"/>
<attribute name="Bundle-DocURL" value="http://beanio.org"/>
<attribute name="Export-Package" value="${osgi.export-package}"/>
<attribute name="DynamicImport-Package" value="*"/>
</manifest>
<metainf dir="${basedir}">
<include name="LICENSE.txt" />
<include name="LICENSE-ASM.txt" />
<include name="NOTICE.txt" />
</metainf>
<fileset dir="${classes.main}" />
<fileset dir="src">
<exclude name="**/*.java" />
<exclude name="**/package.html" />
</fileset>
<!-- Bundle ASM with BeanIO -->
<zipfileset src="lib/asm-4.0.jar" />
<rule pattern="org.objectweb.asm.**" result="org.beanio.internal.asm.@1"/>
</jarjar>
</target>
<!-- Creates docs related directories -->
<target name="docs-init" depends="init">
<delete dir="${target}/docs" />
<mkdir dir="${target}/docs/api" />
</target>
<!-- Create API documentation -->
<target name="docs-api" depends="docs-init">
<javadoc sourcepath="src" destdir="${target}/docs/api" windowtitle="BeanIO 2.0 API" access="protected"
header="BeanIO ${version}" classpathref="classpath.main">
<doctitle><![CDATA[<h2>BeanIO 2.0 API</h2>]]></doctitle>
<bottom><![CDATA[<i>Copyright © 2010-2013 Kevin Seim</i>]]></bottom>
<link href="http://download.oracle.com/javase/6/docs/api/" />
<link href="http://static.springsource.org/spring-batch/apidocs/" />
<link href="http://static.springsource.org/spring/docs/2.5.x/api/" />
</javadoc>
</target>
<target name="docs" depends="docs-init,docs-api"
description="Runs javadoc for Java source file under src/" />
<!-- Create the release ZIP -->
<target name="package" depends="jar,docs" description="Creates the release ZIP">
<property name="parent" value="beanio-${version}" />
<zip destfile="${target}/beanio-${version}.zip">
<zipfileset dir="${target}" prefix="${parent}">
<include name="beanio.jar" />
<include name="docs/**" />
</zipfileset>
<zipfileset dir="${basedir}" prefix="${parent}">
<include name="docs/**" />
<include name="src/**" />
<include name="test/**" />
<include name="*.txt" />
<include name="*.xml" />
<include name="*.properties" />
</zipfileset>
</zip>
</target>
<!-- Create website tar -->
<target name="site" depends="init,docs" description="Create site tar">
<tar destfile="${target}/beanio-site.tar.gz" compression="gzip">
<tarfileset prefix="2.0/" dir="${basedir}">
<include name="docs/**" />
</tarfileset>
<tarfileset prefix="2.0/" dir="${target}">
<include name="docs/**" />
</tarfileset>
<tarfileset dir="${basedir}/site">
<include name="**/*" />
</tarfileset>
<tarfileset dir="${basedir}/src/org/beanio/xsd">
<include name="2012/**" />
</tarfileset>
</tar>
</target>
<!-- Prepare for test execution -->
<target name="test-init" depends="init">
<path id="classpath.test">
<pathelement location="${target}/beanio.jar" />
<pathelement location="${classes.test}" />
<pathelement location="test" />
<fileset dir="lib">
<include name="*.jar" />
<exclude name="jarjar-1.3.jar" />
</fileset>
</path>
<property name="temp" refid="classpath.test"/>
<echo message="${temp}" />
<!-- Compile test classes -->
<mkdir dir="${classes.test}" />
<javac srcdir="test" destdir="${classes.test}" debug="true" includeAntRuntime="false" classpathref="classpath.test" />
<property name="junit.report.dir" value="${target}/report/junit" />
<delete dir="${junit.report.dir}" failonerror="false" />
<mkdir dir="${junit.report.dir}" />
<condition property="flag.emma">
<and>
<istrue value="${emma.enabled}" />
</and>
</condition>
</target>
<!-- Run JUnit without capturing coverage -->
<target name="test-junit" depends="test-init" unless="flag.emma">
<junit printsummary="true" fork="true" forkmode="once" haltonfailure="true">
<formatter type="plain" />
<classpath refid="classpath.test" />
<batchtest fork="true" todir="${junit.report.dir}">
<fileset dir="test">
<include name="**/*Test.java" />
<exclude name="org/beanio/parser/ParserTest.java" />
<exclude name="org/beanio/parser/xml/XmlParserTest.java" />
</fileset>
</batchtest>
</junit>
</target>
<!-- Run JUnit while monitoring code coverage with Emma -->
<target name="test-emma" depends="test-init" if="flag.emma">
<mkdir dir="${target}/classes/emma" />
<mkdir dir="${target}/report/emma" />
<path id="emma.lib">
<fileset dir="lib">
<include name="emma*.jar" />
</fileset>
</path>
<taskdef resource="emma_ant.properties" classpathref="emma.lib" />
<!-- Instrument the Java classes using Emma -->
<path id="main">
<pathelement location="${target}/classes/main" />
</path>
<emma enabled="true">
<instr instrpathref="main" destdir="${target}/classes/emma" metadatafile="${target}/report/emma/metadata.emma" merge="true" />
</emma>
<!-- Add the instrumented classes to the test classpath -->
<path id="classpath.test.emma">
<pathelement location="${target}/classes/emma" />
<path refid="classpath.test" />
</path>
<!-- Run the JUnit test cases -->
<junit printsummary="true" fork="true" forkmode="once" haltonfailure="true">
<formatter type="plain" />
<classpath refid="classpath.test.emma" />
<jvmarg value="-Demma.coverage.out.file=${target}/report/emma/coverage.emma" />
<jvmarg value="-Demma.coverage.out.merge=true" />
<batchtest fork="true" todir="${junit.report.dir}">
<fileset dir="test">
<include name="**/*Test.java" />
<exclude name="org/beanio/parser/ParserTest.java" />
<exclude name="org/beanio/parser/xml/XmlParserTest.java" />
</fileset>
</batchtest>
</junit>
<!-- Create the coverage report -->
<emma enabled="true">
<report sourcepath="src">
<fileset dir="${target}/report/emma">
<include name="*.emma" />
</fileset>
<html outfile="${target}/report/emma/coverage.html" />
</report>
</emma>
</target>
<!-- Create beanio JAR's for a Maven repository -->
<target name="maven-jars" depends="jar,docs-api" description="Creates Maven repository JAR's">
<property name="maven.jar" value="${target}/${maven.artifactId}-${version}.jar" />
<property name="maven.sources.jar" value="${target}/${maven.artifactId}-${version}-sources.jar" />
<property name="maven.javadoc.jar" value="${target}/${maven.artifactId}-${version}-javadoc.jar" />
<copy file="${target}/beanio.jar" toFile="${maven.jar}" />
<jar destfile="${maven.sources.jar}">
<manifest>
<attribute name="Implementation-Title" value="BeanIO ${version}" />
<attribute name="Implementation-Version" value="${version}" />
</manifest>
<metainf dir="${basedir}">
<include name="LICENSE.txt" />
<include name="NOTICE.txt" />
</metainf>
<fileset dir="src">
<exclude name="**/package.html" />
</fileset>
</jar>
<jar destfile="${maven.javadoc.jar}">
<manifest>
<attribute name="Implementation-Title" value="BeanIO ${version}" />
<attribute name="Implementation-Version" value="${version}" />
</manifest>
<metainf dir="${basedir}">
<include name="LICENSE.txt" />
<include name="NOTICE.txt" />
</metainf>
<fileset dir="${target}/docs/api" />
</jar>
</target>
<!-- Deploy Maven beanio JAR's to the configured repository -->
<target name="maven-deploy" depends="maven-jars" description="Deploy to Maven repository">
<!-- sign and deploy the main artifact -->
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.1:sign-and-deploy-file" />
<arg value="-Durl=${maven.repository.url}" />
<arg value="-DrepositoryId=${maven.repository.id}" />
<arg value="-DpomFile=pom.xml" />
<arg value="-Dversion=${version}" />
<arg value="-Dfile=${maven.jar}" />
<arg value="-Pgpg" />
</artifact:mvn>
<!-- sign and deploy the sources artifact -->
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.1:sign-and-deploy-file" />
<arg value="-Durl=${maven.repository.url}" />
<arg value="-DrepositoryId=${maven.repository.id}" />
<arg value="-DpomFile=pom.xml" />
<arg value="-Dversion=${version}" />
<arg value="-Dfile=${maven.sources.jar}" />
<arg value="-Dclassifier=sources" />
<arg value="-Pgpg" />
</artifact:mvn>
<!-- sign and deploy the javadoc artifact -->
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.1:sign-and-deploy-file" />
<arg value="-Durl=${maven.repository.url}" />
<arg value="-DrepositoryId=${maven.repository.id}" />
<arg value="-DpomFile=pom.xml" />
<arg value="-Dversion=${version}" />
<arg value="-Dfile=${maven.javadoc.jar}" />
<arg value="-Dclassifier=javadoc" />
<arg value="-Pgpg" />
</artifact:mvn>
</target>
<target name="test" depends="compile,jar,test-init,test-junit,test-emma"
description="Executes JUnit test cases, generates Emma converage report if enabled" />
<target name="build" depends="compile,jar,docs,package" />
</project>