forked from hamcrest/JavaHamcrest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.xml
More file actions
189 lines (174 loc) · 8.31 KB
/
build.xml
File metadata and controls
189 lines (174 loc) · 8.31 KB
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
<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="api"
description="Build API">
<java-to-jar srcdir="src/api"
destjar="build/hamcrest-api-${version}.jar"/>
</target>
<target name="generator"
depends="api"
description="Build code generator tool">
<java-to-jar srcdir="src/generator"
destjar="build/hamcrest-generator-${version}.jar"
classpath="build/hamcrest-api-${version}.jar"/>
</target>
<target name="library"
depends="api,generator"
description="Build library of matchers">
<java-to-jar srcdir="src/library"
destjar="build/hamcrest-library-${version}.jar"
classpath="build/hamcrest-api-${version}.jar"/>
<!-- Generate one class with all static imports -->
<mkdir dir="build/generated-code"/>
<java classname="org.hamcrest.generator.config.XmlConfigurator"
fork="yes"
failonerror="yes"
classpath="
build/hamcrest-api-${version}.jar;
build/hamcrest-generator-${version}.jar;
build/hamcrest-library-${version}.jar
">
<arg value="matchers.xml"/>
<arg value="org.hamcrest.Matchers"/>
<arg value="build/generated-code"/>
</java>
<!-- Append to library jar -->
<java-to-jar srcdir="build/generated-code"
destjar="build/hamcrest-library-${version}.jar"
classpath="build/hamcrest-api-${version}.jar"/>
</target>
<target name="integration"
depends="api, library"
description="Build integration with external tools">
<java-to-jar srcdir="src/integration"
destjar="build/hamcrest-integration-${version}.jar"
classpath="
build/hamcrest-api-${version}.jar;
build/hamcrest-library-${version}.jar"/>
</target>
<target name="unit-test"
depends="api, library, integration, generator"
description="Build and run unit tests.">
<java-to-jar srcdir="src/unit-test"
destjar="build/hamcrest-unit-test-${version}.jar"
classpath="
build/hamcrest-api-${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-api-${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="src/unit-test">
<exclude name="**/Abstract*"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="examples"
depends="api, library, integration"
description="Build and run unit tests.">
<java-to-jar srcdir="src/examples"
destjar="build/hamcrest-examples-${version}.jar"
classpath="
build/hamcrest-api-${version}.jar;
build/hamcrest-library-${version}.jar;
build/hamcrest-integration-${version}.jar"/>
</target>
<target name="bigjar"
depends="api, library, integration, generator"
description="Build a single Jar (hamcrest-all.jar) that contains api, library, generator and integration.">
<jar jarfile="build/hamcrest-all-${version}.jar" duplicate="preserve">
<fileset dir="build/temp/build/hamcrest-api-${version}.jar.contents"/>
<fileset dir="build/temp/build/hamcrest-library-${version}.jar.contents"/>
<fileset dir="build/temp/build/hamcrest-generator-${version}.jar.contents"/>
<fileset dir="build/temp/build/hamcrest-integration-${version}.jar.contents"/>
</jar>
</target>
<target name="package"
depends="api,generator,library,integration,bigjar,unit-test,examples"
description="Package for distribution">
<zip zipfile="build/hamcrest-${version}.zip">
<zipfileset dir="." prefix="hamcrest-${version}">
<include name="src/**"/>
<include name="lib/**"/>
<include name="*.txt"/>
<include name="build.xml"/>
<include name="matchers.xml"/>
</zipfileset>
<zipfileset dir="build" prefix="hamcrest-${version}">
<include name="hamcrest-api-${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">
<tarfileset dir="." prefix="hamcrest-${version}">
<include name="src/**"/>
<include name="lib/**"/>
<include name="*.txt"/>
<include name="build.xml"/>
<include name="matchers.xml"/>
</tarfileset>
<tarfileset dir="build" prefix="hamcrest-${version}">
<include name="hamcrest-api-${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>
<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}">
<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>