Skip to content

Commit 7ced29c

Browse files
author
joeretro
committed
Build file refactoring. Broken each module into it's own build rules. Allows building of a single module and makes it more extensible.
1 parent 31faeb3 commit 7ced29c

1 file changed

Lines changed: 85 additions & 21 deletions

File tree

‎build.xml‎

Lines changed: 85 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,98 @@
11
<project name="hamcrest" default="all">
22

3-
<property name="version" value="SNAPSHOT"/>
3+
<property name="version"
4+
value="SNAPSHOT"
5+
description="Version number to use in build files"/>
46

5-
<target name="all" depends="clean, build,test,package"
6-
description="Performs clean build, test and package for distribution"/>
7+
<property name="haltonfailure"
8+
value="true"
9+
description="Whether to halt the build if the tests fail"/>
710

8-
<target name="clean" description="Clean up all built files">
11+
<target name="all"
12+
depends="clean, package"
13+
description="Performs clean build, runs tests and packages for distribution"/>
14+
15+
<target name="clean"
16+
description="Clean up all built files">
917
<delete dir="build"/>
1018
</target>
1119

12-
<target name="build" description="Build project">
13-
<mkdir dir="build"/>
14-
<java-to-jar srcdir="src/api" destjar="build/hamcrest-api-${version}.jar"/>
15-
<java-to-jar srcdir="src/generator" destjar="build/hamcrest-generator-${version}.jar"
20+
<target name="api"
21+
description="Build API">
22+
<java-to-jar srcdir="src/api"
23+
destjar="build/hamcrest-api-${version}.jar"/>
24+
</target>
25+
26+
<target name="generator"
27+
depends="api"
28+
description="Build code generator tool">
29+
<java-to-jar srcdir="src/generator"
30+
destjar="build/hamcrest-generator-${version}.jar"
1631
classpath="build/hamcrest-api-${version}.jar"/>
17-
<java-to-jar srcdir="src/library" destjar="build/hamcrest-library-${version}.jar"
32+
</target>
33+
34+
<target name="library"
35+
depends="api"
36+
description="Build library of matchers">
37+
<java-to-jar srcdir="src/library"
38+
destjar="build/hamcrest-library-${version}.jar"
1839
classpath="build/hamcrest-api-${version}.jar"/>
19-
<java-to-jar srcdir="src/integration" destjar="build/hamcrest-integration-${version}.jar"
20-
classpath="build/hamcrest-api-${version}.jar;build/hamcrest-library-${version}.jar"/>
21-
<java-to-jar srcdir="src/unit-test" destjar="build/hamcrest-unit-test-${version}.jar"
22-
classpath="build/hamcrest-api-${version}.jar;build/hamcrest-library-${version}.jar;build/hamcrest-integration-${version}.jar;build/hamcrest-generator-${version}.jar"/>
23-
<java-to-jar srcdir="src/examples" destjar="build/hamcrest-examples-${version}.jar"
24-
classpath="build/hamcrest-api-${version}.jar;build/hamcrest-library-${version}.jar;build/hamcrest-integration-${version}.jar"/>
2540
</target>
2641

27-
<target name="test" description="Test project">
28-
<!-- TODO -->
42+
<target name="integration"
43+
depends="api, library"
44+
description="Build integration with external tools">
45+
<java-to-jar srcdir="src/integration"
46+
destjar="build/hamcrest-integration-${version}.jar"
47+
classpath="
48+
build/hamcrest-api-${version}.jar;
49+
build/hamcrest-library-${version}.jar"/>
50+
</target>
51+
52+
<target name="unit-test"
53+
depends="api, library, integration, generator"
54+
description="Build and run unit tests.">
55+
<java-to-jar srcdir="src/unit-test"
56+
destjar="build/hamcrest-unit-test-${version}.jar"
57+
classpath="
58+
build/hamcrest-api-${version}.jar;
59+
build/hamcrest-library-${version}.jar;
60+
build/hamcrest-integration-${version}.jar;
61+
build/hamcrest-generator-${version}.jar"/>
62+
<junit printsummary="no" fork="no" haltonfailure="${haltonfailure}">
63+
<formatter type="brief" usefile="no"/>
64+
<classpath>
65+
<fileset dir="lib/integration">
66+
<include name="*.jar"/>
67+
</fileset>
68+
<pathelement path="build/hamcrest-api-${version}.jar"/>
69+
<pathelement path="build/hamcrest-library-${version}.jar"/>
70+
<pathelement path="build/hamcrest-integration-${version}.jar"/>
71+
<pathelement path="build/hamcrest-generator-${version}.jar"/>
72+
<pathelement path="build/hamcrest-unit-test-${version}.jar"/>
73+
</classpath>
74+
<batchtest>
75+
<fileset dir="src/unit-test">
76+
<exclude name="**/Abstract*"/>
77+
</fileset>
78+
</batchtest>
79+
</junit>
80+
</target>
81+
82+
<target name="examples"
83+
depends="api, library, integration"
84+
description="Build and run unit tests.">
85+
<java-to-jar srcdir="src/examples"
86+
destjar="build/hamcrest-examples-${version}.jar"
87+
classpath="
88+
build/hamcrest-api-${version}.jar;
89+
build/hamcrest-library-${version}.jar;
90+
build/hamcrest-integration-${version}.jar"/>
2991
</target>
3092

31-
<target name="package" depends="build" description="Package for distribution">
93+
<target name="package"
94+
depends="api,generator,library,integration,unit-test,examples"
95+
description="Package for distribution">
3296
<zip zipfile="build/hamcrest-${version}.zip">
3397
<zipfileset dir="." prefix="hamcrest-${version}">
3498
<include name="src/**"/>
@@ -44,12 +108,12 @@
44108
</zip>
45109
</target>
46110

47-
<macrodef name="java-to-jar" description="Compile Java source and build a Jar">
111+
<macrodef name="java-to-jar"
112+
description="Compile Java source and build a Jar">
48113
<attribute name="srcdir" description="Directory containg Java source"/>
49114
<attribute name="destjar" description="Path to Jar"/>
50115
<attribute name="classpath" description="Anything additional to add on the classpath" default=""/>
51116
<sequential>
52-
<echo message="* Java source (@{srcdir}) -> Jar (@{destjar})"/>
53117
<mkdir dir="build/temp/@{destjar}.contents"/>
54118
<javac srcdir="@{srcdir}" destdir="build/temp/@{destjar}.contents">
55119
<classpath>
@@ -62,7 +126,7 @@
62126
<jar jarfile="@{destjar}">
63127
<fileset dir="build/temp/@{destjar}.contents"/>
64128
<fileset dir="@{srcdir}"/>
65-
<!-- Also put Java source in Jar for user's convenience. -->
129+
<!-- Put Java source in Jars for user's convenience. -->
66130
</jar>
67131
</sequential>
68132
</macrodef>

0 commit comments

Comments
 (0)