File: build.xml

package info (click to toggle)
libhamcrest-java 1.3-9
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 1,052 kB
  • sloc: java: 6,568; xml: 372; makefile: 40; sh: 14
file content (339 lines) | stat: -rw-r--r-- 19,976 bytes parent folder | download | duplicates (2)
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
330
331
332
333
334
335
336
337
338
339
<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"/>
	<tstamp><format property="build.timestamp" pattern="yyyy-MM-dd HH:mm:ss" timezone="GMT"/></tstamp>

    <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"
                     modulename="hamcrest-generator-nodeps"
                     classpath="/usr/share/java/qdox.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="/usr/share/java/jarjar.jar"/>
        <jarjar jarfile="build/hamcrest-generator-${version}.jar">
            <zipfileset src="build/hamcrest-generator-nodeps-${version}.jar"/>
            <zipfileset src="/usr/share/java/qdox.jar"/>
            <rule pattern="com.thoughtworks.qdox.**" result="org.hamcrest.generator.qdox.@1"/>
        </jarjar>
        <copy file="build/hamcrest-generator-nodeps-${version}-sources.jar" tofile="build/hamcrest-generator-${version}-sources.jar"/>
    </target>

    <target name="core" depends="generator" description="Build core Hamcrest library">
        <java-to-jar srcdir="hamcrest-core/src/main/java" modulename="hamcrest-core"/>

        <!-- 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"
                     modulename="hamcrest-core"
                     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"
                     modulename="hamcrest-library"
                     classpath="/usr/share/java/hamcrest-core.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"
                     modulename="hamcrest-library"
                     classpath="/usr/share/java/hamcrest-core.jar"/>
    </target>

    <target name="integration" depends="core, library" description="Build integration with external tools">
        <java-to-jar srcdir="hamcrest-integration/src/main/java"
                     modulename="hamcrest-integration"
                     classpath="/usr/share/java/hamcrest-core.jar;
                                /usr/share/java/hamcrest-library.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" modulename="hamcrest-unit-test"
            classpath="/usr/share/java/hamcrest-core.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>
                <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"/>
                <fileset dir="/usr/share/java">
                    <include name="junit.jar"/>
                    <include name="junit4.jar"/>
                    <include name="easymock.jar"/>
                    <include name="jmock.jar"/>
                </fileset>
            </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"
                     modulename="hamcrest-examples"
                     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.">
        <mkdir dir="build/temp/hamcrest-all-${version}.jar.manifest"/>
        <manifest file="build/temp/hamcrest-all-${version}.jar.manifest/MANIFEST.MF">
            <attribute name="Implementation-Title" value="hamcrest-all"/>
            <attribute name="Implementation-Vendor" value="hamcrest.org"/>
            <attribute name="Implementation-Version" value="${version}"/>
            <attribute name="Built-By" value="${user.name}"/>
            <attribute name="Built-Date" value="${build.timestamp}"/>
        </manifest>
        <jar jarfile="build/hamcrest-all-${version}.jar" duplicate="preserve" manifest="build/temp/hamcrest-all-${version}.jar.manifest/MANIFEST.MF">
            <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>
        <jar jarfile="build/hamcrest-all-${version}-sources.jar" duplicate="preserve" manifest="build/temp/hamcrest-all-${version}.jar.manifest/MANIFEST.MF">
            <zipfileset src="build/hamcrest-core-${version}-sources.jar"/>
            <zipfileset src="build/hamcrest-library-${version}-sources.jar"/>
            <zipfileset src="build/hamcrest-generator-${version}-sources.jar"/>
            <zipfileset src="build/hamcrest-integration-${version}-sources.jar"/>
        </jar>
    </target>

    <target name="javadoc" description="build javadoc jars">
        <java-to-javadoc-jar modulename="hamcrest-generator-nodeps"/>
        <java-to-javadoc-jar modulename="hamcrest-core"/>
        <java-to-javadoc-jar modulename="hamcrest-library"/>
        <java-to-javadoc-jar modulename="hamcrest-integration"/>
        <copy file="build/hamcrest-generator-nodeps-${version}-javadoc.jar" tofile="build/hamcrest-generator-${version}-javadoc.jar"/>

        <javadoc packagenames="org.hamcrest.*" defaultexcludes="yes"
                 destdir="build/temp/hamcrest-all-${version}-javadoc.jar.contents" author="true" version="true" use="true"
                 windowtitle="Hamcrest" source="1.6" failonerror="no" overview="overview.html">
            <classpath>
                <fileset dir="lib/integration">
                    <include name="*.jar"/>
                </fileset>
            </classpath>
            <packageset dir="build/temp/hamcrest-core-${version}-sources.jar.contents"/>
            <packageset dir="build/temp/hamcrest-library-${version}-sources.jar.contents" excludes="org/hamcrest/internal"/>
            <packageset dir="build/temp/hamcrest-integration-${version}-sources.jar.contents"/>
            
            <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="/usr/share/doc/junit-doc/javadoc/"/>
            <link offline="false" href="/usr/share/doc/junit4-doc/javadoc_40/"/>
        </javadoc>
        <jar jarfile="build/hamcrest-all-${version}-javadoc.jar">
            <fileset dir="build/temp/hamcrest-all-${version}-javadoc.jar.contents"/>
        </jar>
    </target>

    <target name="package" depends="core, generator, library, integration, bigjar, unit-test, examples, javadoc" description="Package for distribution">
        <copy todir="build">
            <fileset dir="pom" includes="*.pom"/>
            <filterset><filter token="VERSION" value="${version}"/></filterset>
            <mapper type="regexp" from="(.*)\.pom" to="\1-${version}.pom"/>
        </copy>
        <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-parent-${version}*"/>
                <include name="hamcrest-core-${version}*"/>
                <include name="hamcrest-library-${version}*"/>
                <include name="hamcrest-generator-${version}*"/>
                <include name="hamcrest-integration-${version}*"/>
                <include name="hamcrest-all-${version}*"/>
            </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-parent-${version}*"/>
                <include name="hamcrest-core-${version}*"/>
                <include name="hamcrest-library-${version}*"/>
                <include name="hamcrest-generator-${version}*"/>
                <include name="hamcrest-integration-${version}*"/>
                <include name="hamcrest-all-${version}*"/>
            </tarfileset>
        </tar>
    </target>

    <target name="bundle" description="Create a release bundle for deployment to maven central" depends="clean, package">
        <exec executable="gpg" dir="build"><arg value="-ab"/><arg value="hamcrest-parent-${version}.pom"/></exec>
        <exec executable="gpg" dir="build"><arg value="-ab"/><arg value="hamcrest-core-${version}.pom"/></exec>
        <exec executable="gpg" dir="build"><arg value="-ab"/><arg value="hamcrest-core-${version}.jar"/></exec>
        <exec executable="gpg" dir="build"><arg value="-ab"/><arg value="hamcrest-core-${version}-javadoc.jar"/></exec>
        <exec executable="gpg" dir="build"><arg value="-ab"/><arg value="hamcrest-core-${version}-sources.jar"/></exec>
        <exec executable="gpg" dir="build"><arg value="-ab"/><arg value="hamcrest-generator-${version}.pom"/></exec>
        <exec executable="gpg" dir="build"><arg value="-ab"/><arg value="hamcrest-generator-${version}.jar"/></exec>
        <exec executable="gpg" dir="build"><arg value="-ab"/><arg value="hamcrest-generator-${version}-javadoc.jar"/></exec>
        <exec executable="gpg" dir="build"><arg value="-ab"/><arg value="hamcrest-generator-${version}-sources.jar"/></exec>
        <exec executable="gpg" dir="build"><arg value="-ab"/><arg value="hamcrest-library-${version}.pom"/></exec>
        <exec executable="gpg" dir="build"><arg value="-ab"/><arg value="hamcrest-library-${version}.jar"/></exec>
        <exec executable="gpg" dir="build"><arg value="-ab"/><arg value="hamcrest-library-${version}-javadoc.jar"/></exec>
        <exec executable="gpg" dir="build"><arg value="-ab"/><arg value="hamcrest-library-${version}-sources.jar"/></exec>
        <exec executable="gpg" dir="build"><arg value="-ab"/><arg value="hamcrest-integration-${version}.pom"/></exec>
        <exec executable="gpg" dir="build"><arg value="-ab"/><arg value="hamcrest-integration-${version}.jar"/></exec>
        <exec executable="gpg" dir="build"><arg value="-ab"/><arg value="hamcrest-integration-${version}-javadoc.jar"/></exec>
        <exec executable="gpg" dir="build"><arg value="-ab"/><arg value="hamcrest-integration-${version}-sources.jar"/></exec>
        <exec executable="gpg" dir="build"><arg value="-ab"/><arg value="hamcrest-all-${version}.pom"/></exec>
        <exec executable="gpg" dir="build"><arg value="-ab"/><arg value="hamcrest-all-${version}.jar"/></exec>
        <exec executable="gpg" dir="build"><arg value="-ab"/><arg value="hamcrest-all-${version}-javadoc.jar"/></exec>
        <exec executable="gpg" dir="build"><arg value="-ab"/><arg value="hamcrest-all-${version}-sources.jar"/></exec>
        <jar destfile="build/maven-bundle-parent.jar">
            <fileset dir="build">
                <include name="hamcrest-parent-${version}*"/>
            </fileset>
        </jar>
        <jar destfile="build/maven-bundle-core.jar">
            <fileset dir="build">
                <include name="hamcrest-core-${version}*"/>
            </fileset>
        </jar>
        <jar destfile="build/maven-bundle-library.jar">
            <fileset dir="build">
                <include name="hamcrest-library-${version}*"/>
            </fileset>
        </jar>
        <jar destfile="build/maven-bundle-generator.jar">
            <fileset dir="build">
                <include name="hamcrest-generator-${version}*"/>
            </fileset>
        </jar>
        <jar destfile="build/maven-bundle-integration.jar">
            <fileset dir="build">
                <include name="hamcrest-integration-${version}*"/>
            </fileset>
        </jar>
        <jar destfile="build/maven-bundle-all.jar">
            <fileset dir="build">
                <include name="hamcrest-all-${version}*"/>
            </fileset>
        </jar>
    </target>

    <macrodef name="java-to-jar" description="Compile Java source for a module and build a Jar">
        <attribute name="srcdir" description="Directory containg Java source"/>
        <attribute name="modulename" description="Name of the module to jar"/>
        <attribute name="classpath" description="Anything additional to add on the classpath" default=""/>
        <sequential>
            <mkdir dir="build/temp/@{modulename}-${version}.jar.manifest"/>
            <manifest file="build/temp/@{modulename}-${version}.jar.manifest/MANIFEST.MF">
                <attribute name="Implementation-Title" value="@{modulename}"/>
                <attribute name="Implementation-Vendor" value="hamcrest.org"/>
                <attribute name="Implementation-Version" value="${version}"/>
                <attribute name="Built-By" value="${user.name}"/>
                <attribute name="Built-Date" value="${build.timestamp}"/>
            </manifest>
            <mkdir dir="build/temp/@{modulename}-${version}.jar.contents"/>
            <javac srcdir="@{srcdir}" destdir="build/temp/@{modulename}-${version}.jar.contents" debug="${debug}" target="1.5" includeantruntime="false">
                <classpath>
                    <pathelement path="@{classpath}"/>
                    <fileset dir="/usr/share/java">
                        <include name="junit.jar"/>
                        <include name="junit4.jar"/>
                        <include name="easymock.jar"/>
                        <include name="jmock.jar"/>
                        <include name="hamcrest-core.jar"/>
                    </fileset>
                </classpath>
            </javac>
            <copy file="LICENSE.txt" todir="build/temp/@{modulename}-${version}.jar.contents"/>
            <jar jarfile="build/@{modulename}-${version}.jar" manifest="build/temp/@{modulename}-${version}.jar.manifest/MANIFEST.MF">
                <fileset dir="build/temp/@{modulename}-${version}.jar.contents"/>
            </jar>

            <!-- Build sources jar -->
            <copy todir="build/temp/@{modulename}-${version}-sources.jar.contents">
                <fileset dir="@{srcdir}"/>
            </copy>
            <jar jarfile="build/@{modulename}-${version}-sources.jar" manifest="build/temp/@{modulename}-${version}.jar.manifest/MANIFEST.MF">
                <fileset dir="build/temp/@{modulename}-${version}-sources.jar.contents"/>
            </jar>
        </sequential>
    </macrodef>

    <macrodef name="java-to-javadoc-jar" description="Generate javadoc for a module and build a Jar">
        <attribute name="modulename" description="Name of the module to document"/>
        <sequential>
            <javadoc packagenames="org.hamcrest.*" sourcepath="build/temp/@{modulename}-${version}-sources.jar.contents" defaultexcludes="yes"
                     destdir="build/temp/@{modulename}-${version}-javadoc.jar.contents" author="true" version="true" use="true"
                     windowtitle="Hamcrest" source="1.6" failonerror="yes">
                <classpath>
                    <fileset dir="lib/integration">
                        <include name="*.jar"/>
                    </fileset>
                    <fileset file="/usr/share/java/qdox.jar"/>
                    <fileset file="build/hamcrest-core-${version}.jar"/>
                    <fileset file="build/hamcrest-library-${version}.jar"/>
                    <fileset file="build/hamcrest-generator-${version}.jar"/>
                    <fileset file="build/hamcrest-integration-${version}.jar"/>
                </classpath>
            </javadoc>
            <jar jarfile="build/@{modulename}-${version}-javadoc.jar">
                <fileset dir="build/temp/@{modulename}-${version}-javadoc.jar.contents"/>
            </jar>
        </sequential>
    </macrodef>
</project>