Skip to content

Commit 5879cc1

Browse files
committed
build hamcrest-core module
1 parent f4e73d9 commit 5879cc1

1 file changed

Lines changed: 43 additions & 35 deletions

File tree

‎build.xml‎

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<path id="cp-hamcrest-generator-main" path="lib/generator/qdox-1.12.jar;build/hamcrest-api-${version}.jar"/>
2323
<path id="cp-hamcrest-generator-test" path="lib/integration/junit-dep-4.10.jar"/>
2424
<compile-module modulename="hamcrest-generator"/>
25+
<test-module modulename="hamcrest-generator"/>
2526

2627
<!-- Bundle QDox classes in hamcrest-generator.jar using JarJar to place classes under a different package -->
2728
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="lib/generator/jarjar-1.3.jar"/>
@@ -33,9 +34,23 @@
3334
</jarjar>
3435
</target>
3536

37+
<target name="core" depends="generator" description="Build core Hamcrest library">
38+
<path id="cp-hamcrest-core-main" path="build/hamcrest-api-${version}.jar"/>
39+
<path id="cp-hamcrest-core-test" path="lib/integration/junit-dep-4.10.jar"/>
40+
<compile-module modulename="hamcrest-core"/>
41+
<test-module modulename="hamcrest-core"/>
42+
<generate-module-factory modulename="hamcrest-core" configurationfile="core-matchers.xml" targetclass="org.hamcrest.CoreMatchers"/>
43+
44+
<!-- Bundle api into core jar -->
45+
<copy file="build/hamcrest-core-${version}.jar" tofile="build/hamcrest-core-${version}-nodep.jar"/>
46+
<jar jarfile="build/hamcrest-core-${version}.jar" duplicate="preserve">
47+
<zipfileset src="build/hamcrest-api-${version}.jar"/>
48+
<zipfileset src="build/hamcrest-core-${version}-nodep.jar"/>
49+
</jar>
50+
</target>
51+
3652
<macrodef name="compile-module">
3753
<attribute name="modulename" description="Name of the module to jar"/>
38-
<attribute name="classpathref" description="Anything additional to add on the classpath" default=""/>
3954

4055
<sequential>
4156
<mkdir dir="build/temp/@{modulename}-${version}.jar.contents"/>
@@ -64,41 +79,33 @@
6479
</sequential>
6580
</macrodef>
6681

67-
<target name="core" depends="generator" description="Build core Hamcrest library">
68-
<java-to-jar srcdir="hamcrest-core/src/main/java" modulename="hamcrest-core"/>
69-
70-
<!-- Generate one class with all static imports -->
71-
<mkdir dir="build/temp/hamcrest-core/generated-code"/>
72-
<java classname="org.hamcrest.generator.config.XmlConfigurator"
73-
fork="yes"
74-
failonerror="yes"
75-
classpath="
76-
build/hamcrest-api-${version}.jar;
77-
build/hamcrest-core-nodeps-${version}.jar;
78-
build/hamcrest-generator-${version}.jar;
79-
">
80-
<arg value="core-matchers.xml"/>
81-
<arg value="hamcrest-core/src/main/java"/>
82-
<arg value="org.hamcrest.CoreMatchers"/>
83-
<arg value="build/temp/hamcrest-core/generated-code"/>
84-
</java>
85-
86-
<!-- Append generated code to core jar -->
87-
<java-to-jar srcdir="build/temp/hamcrest-core/generated-code"
88-
modulename="hamcrest-core-nodeps"
89-
classpath="build/hamcrest-api-${version}.jar;
90-
build/hamcrest-core-nodeps-${version}.jar"/>
82+
<macrodef name="generate-module-factory" description="Generate one class with all static imports">
83+
<attribute name="modulename" description="Name of the module to jar"/>
84+
<attribute name="configurationfile" description="xml configuration file"/>
85+
<attribute name="targetclass" description="factory class to generate"/>
86+
<sequential>
87+
<mkdir dir="build/temp/@{modulename}/generated-code"/>
88+
<java classname="org.hamcrest.generator.config.XmlConfigurator" fork="yes" failonerror="yes">
89+
<classpath path="build/hamcrest-generator-${version}.jar"/>
90+
<classpath refid="cp-@{modulename}-main"/>
91+
<classpath path="build/@{modulename}-${version}.jar"/>
92+
<arg value="@{configurationfile}"/>
93+
<arg value="@{modulename}/src/main/java"/>
94+
<arg value="@{targetclass}"/>
95+
<arg value="build/temp/@{modulename}/generated-code"/>
96+
</java>
9197

92-
<!-- Bundle api into core jar -->
93-
<jar jarfile="build/hamcrest-core-${version}.jar" duplicate="preserve">
94-
<zipfileset src="build/hamcrest-api-${version}.jar"/>
95-
<zipfileset src="build/hamcrest-core-nodeps-${version}.jar"/>
96-
</jar>
97-
<jar jarfile="build/hamcrest-core-${version}-sources.jar" duplicate="preserve">
98-
<zipfileset src="build/hamcrest-api-${version}-sources.jar"/>
99-
<zipfileset src="build/hamcrest-core-nodeps-${version}-sources.jar"/>
100-
</jar>
101-
</target>
98+
<!-- Append generated code to core jar -->
99+
<javac srcdir="build/temp/@{modulename}/generated-code"
100+
destdir="build/temp/@{modulename}-${version}.jar.contents"
101+
debug="${debug}" source="1.5" target="1.5" includeantruntime="false">
102+
<classpath refid="cp-@{modulename}-main"/>
103+
</javac>
104+
<jar jarfile="build/@{modulename}-${version}.jar" manifest="build/temp/@{modulename}-${version}.jar.manifest/MANIFEST.MF">
105+
<fileset dir="build/temp/@{modulename}-${version}.jar.contents"/>
106+
</jar>
107+
</sequential>
108+
</macrodef>
102109

103110
<target name="library"
104111
depends="core,generator"
@@ -398,6 +405,7 @@
398405
<batchtest fork="yes" todir="${build.dir}/testreport">
399406
<zipfileset src="build/@{modulename}-${version}-test.jar">
400407
<include name="org/hamcrest/**/*Test.class"/>
408+
<exclude name="**/Abstract*.class"/>
401409
</zipfileset>
402410
</batchtest>
403411
</junit>

0 commit comments

Comments
 (0)