forked from hamcrest/JavaHamcrest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
216 lines (196 loc) · 10.8 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
<project name="hamcrest" default="all">
<property name="version" value="SNAPSHOT" description="Version number to use in build files"/>
<property name="haltonfailure" value="true" description="Whether to halt the build if the tests fail"/>
<property name="debug" value="true" description="Whether to build with debug information"/>
<target name="all" depends="clean, package" description="Performs clean build, runs tests and packages for distribution"/>
<target name="clean" description="Clean up all built files">
<delete dir="build"/>
</target>
<target name="generator" description="Build code generator tool">
<java-to-jar srcdir="hamcrest-generator/src/main/java"
destjar="build/temp/hamcrest-generator-${version}-nodeps.jar"
classpath="lib/generator/qdox-1.12.jar"/>
<!-- Bundle QDox classes in hamcrest-generator.jar using JarJar to place classes under a different package -->
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="lib/generator/jarjar-1.3.jar"/>
<jarjar jarfile="build/hamcrest-generator-${version}.jar">
<zipfileset src="build/temp/hamcrest-generator-${version}-nodeps.jar"/>
<zipfileset src="lib/generator/qdox-1.12.jar"/>
<rule pattern="com.thoughtworks.qdox.**" result="org.hamcrest.generator.qdox.@1"/>
</jarjar>
</target>
<target name="core" depends="generator" description="Build core Hamcrest library">
<java-to-jar srcdir="hamcrest-core/src/main/java" destjar="build/hamcrest-core-${version}.jar"/>
<!-- Generate one class with all static imports -->
<mkdir dir="build/temp/hamcrest-core/generated-code"/>
<java classname="org.hamcrest.generator.config.XmlConfigurator"
fork="yes"
failonerror="yes"
classpath="
build/hamcrest-core-${version}.jar;
build/hamcrest-generator-${version}.jar;
">
<arg value="core-matchers.xml"/>
<arg value="hamcrest-core/src/main/java"/>
<arg value="org.hamcrest.CoreMatchers"/>
<arg value="build/temp/hamcrest-core/generated-code"/>
</java>
<!-- Append to core jar -->
<java-to-jar srcdir="build/temp/hamcrest-core/generated-code"
destjar="build/hamcrest-core-${version}.jar"
classpath="build/hamcrest-core-${version}.jar"/>
</target>
<target name="library"
depends="core,generator"
description="Build library of matchers">
<mkdir dir="build/temp/hamcrest-library/generated-code"/>
<java-to-jar srcdir="hamcrest-library/src/main/java"
destjar="build/hamcrest-library-${version}.jar"
classpath="build/hamcrest-core-${version}.jar"/>
<!-- Generate one class with all static imports -->
<java classname="org.hamcrest.generator.config.XmlConfigurator"
fork="yes"
failonerror="yes"
classpath="
build/hamcrest-core-${version}.jar;
build/hamcrest-generator-${version}.jar;
build/hamcrest-library-${version}.jar;
">
<arg value="matchers.xml"/>
<arg value="hamcrest-core/src/main/java,hamcrest-library/src/main/java"/>
<arg value="org.hamcrest.Matchers"/>
<arg value="build/temp/hamcrest-library/generated-code"/>
</java>
<!-- Append to library jar -->
<java-to-jar srcdir="build/temp/hamcrest-library/generated-code"
destjar="build/hamcrest-library-${version}.jar"
classpath="build/hamcrest-core-${version}.jar"/>
</target>
<target name="integration" depends="core, library" description="Build integration with external tools">
<java-to-jar srcdir="hamcrest-integration/src/main/java" destjar="build/hamcrest-integration-${version}.jar"
classpath="
build/hamcrest-core-${version}.jar;
build/hamcrest-library-${version}.jar"/>
</target>
<target name="unit-test" depends="core, library, integration, generator" description="Build and run unit tests.">
<java-to-jar srcdir="hamcrest-unit-test/src/main/java" destjar="build/hamcrest-unit-test-${version}.jar"
classpath="
build/hamcrest-core-${version}.jar;
build/hamcrest-library-${version}.jar;
build/hamcrest-integration-${version}.jar;
build/hamcrest-generator-${version}.jar"/>
<junit printsummary="no" fork="no" haltonfailure="${haltonfailure}">
<formatter type="brief" usefile="no"/>
<classpath>
<fileset dir="lib/integration">
<include name="*.jar"/>
</fileset>
<pathelement path="build/hamcrest-core-${version}.jar"/>
<pathelement path="build/hamcrest-library-${version}.jar"/>
<pathelement path="build/hamcrest-integration-${version}.jar"/>
<pathelement path="build/hamcrest-generator-${version}.jar"/>
<pathelement path="build/hamcrest-unit-test-${version}.jar"/>
</classpath>
<batchtest>
<fileset dir="hamcrest-unit-test/src/main/java">
<include name="**/*Test*"/>
<exclude name="**/Abstract*"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="examples" depends="core, library, integration" description="Build and run unit tests.">
<java-to-jar srcdir="hamcrest-examples/src/main/java"
destjar="build/hamcrest-examples-${version}.jar"
classpath="
build/hamcrest-core-${version}.jar;
build/hamcrest-library-${version}.jar;
build/hamcrest-integration-${version}.jar"/>
</target>
<target name="bigjar" depends="core, library, integration, generator"
description="Build a single Jar (hamcrest-all.jar) that contains core, library, generator and integration.">
<jar jarfile="build/hamcrest-all-${version}.jar" duplicate="preserve">
<zipfileset src="build/hamcrest-core-${version}.jar"/>
<zipfileset src="build/hamcrest-library-${version}.jar"/>
<zipfileset src="build/hamcrest-generator-${version}.jar"/>
<zipfileset src="build/hamcrest-integration-${version}.jar"/>
</jar>
</target>
<target name="package" depends="core, generator, library, integration, bigjar, unit-test, examples" description="Package for distribution">
<zip zipfile="build/hamcrest-${version}.zip">
<zipfileset dir="." prefix="hamcrest-${version}">
<include name="hamcrest-*/**"/>
<include name="lib/**"/>
<include name="*.txt"/>
<include name="build.xml"/>
<include name="*matchers.xml"/>
</zipfileset>
<zipfileset dir="build" prefix="hamcrest-${version}">
<include name="hamcrest-core-${version}.jar"/>
<include name="hamcrest-generator-${version}.jar"/>
<include name="hamcrest-library-${version}.jar"/>
<include name="hamcrest-integration-${version}.jar"/>
<include name="hamcrest-all-${version}.jar"/>
</zipfileset>
</zip>
<tar tarfile="build/hamcrest-${version}.tgz" compression="gzip" longfile="gnu">
<tarfileset dir="." prefix="hamcrest-${version}">
<include name="hamcrest-*/**"/>
<include name="lib/**"/>
<include name="*.txt"/>
<include name="build.xml"/>
<include name="*matchers.xml"/>
</tarfileset>
<tarfileset dir="build" prefix="hamcrest-${version}">
<include name="hamcrest-core-${version}.jar"/>
<include name="hamcrest-generator-${version}.jar"/>
<include name="hamcrest-library-${version}.jar"/>
<include name="hamcrest-integration-${version}.jar"/>
<include name="hamcrest-all-${version}.jar"/>
</tarfileset>
</tar>
</target>
<target name="javadoc" depends="library">
<mkdir dir="build/javadoc"/>
<javadoc destdir="build/javadoc" source="1.6" failonerror="yes" overview="overview.html">
<classpath>
<fileset dir="lib/integration">
<include name="*.jar"/>
</fileset>
</classpath>
<packageset dir="hamcrest-core/src/main/java"/>
<packageset dir="hamcrest-library/src/main/java" excludes="org/hamcrest/internal"/>
<packageset dir="hamcrest-integration/src/main/java"/>
<packageset dir="build/temp/hamcrest-core/generated-code"/>
<packageset dir="build/temp/hamcrest-library/generated-code"/>
<group title="Hamcrest API and Utility Classes" packages="org.hamcrest"/>
<group title="Matcher Library" packages="org.hamcrest.*"/>
<group title="Integration" packages="org.hamcrest.integration, org.hamcrest.integration.*"/>
<link offline="false" href="http://www.junit.org/junit/javadoc/3.8.1/"/>
<link offline="false" href="http://kentbeck.github.com/junit/javadoc/latest/"/>
</javadoc>
</target>
<macrodef name="java-to-jar" description="Compile Java source and build a Jar">
<attribute name="srcdir" description="Directory containg Java source"/>
<attribute name="destjar" description="Path to Jar"/>
<attribute name="classpath" description="Anything additional to add on the classpath" default=""/>
<sequential>
<mkdir dir="build/temp/@{destjar}.contents"/>
<javac srcdir="@{srcdir}" destdir="build/temp/@{destjar}.contents" debug="${debug}" target="1.5">
<classpath>
<fileset dir="lib/integration">
<include name="*.jar"/>
</fileset>
<pathelement path="@{classpath}"/>
</classpath>
</javac>
<copy file="LICENSE.txt" todir="build/temp/@{destjar}.contents"/>
<!-- Put Java source in Jars for user's convenience. -->
<copy todir="build/temp/@{destjar}.contents">
<fileset dir="@{srcdir}"/>
</copy>
<jar jarfile="@{destjar}">
<fileset dir="build/temp/@{destjar}.contents"/>
</jar>
</sequential>
</macrodef>
</project>