Skip to content

Commit 6557333

Browse files
committed
include manifest in jars
1 parent 2e7b1f2 commit 6557333

File tree

1 file changed

+53
-38
lines changed

1 file changed

+53
-38
lines changed

build.xml

Lines changed: 53 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<property name="version" value="SNAPSHOT" description="Version number to use in build files"/>
44
<property name="haltonfailure" value="true" description="Whether to halt the build if the tests fail"/>
55
<property name="debug" value="true" description="Whether to build with debug information"/>
6+
<tstamp><format property="build.timestamp" pattern="yyyy-MM-dd HH:mm:ss" timezone="GMT"/></tstamp>
67

78
<target name="all" depends="clean, package" description="Performs clean build, runs tests and packages for distribution"/>
89

@@ -12,7 +13,7 @@
1213

1314
<target name="generator" description="Build code generator tool">
1415
<java-to-jar srcdir="hamcrest-generator/src/main/java"
15-
modulename="hamcrest-generator-nodeps-${version}"
16+
modulename="hamcrest-generator-nodeps"
1617
classpath="lib/generator/qdox-1.12.jar"/>
1718

1819
<!-- Bundle QDox classes in hamcrest-generator.jar using JarJar to place classes under a different package -->
@@ -26,7 +27,7 @@
2627
</target>
2728

2829
<target name="core" depends="generator" description="Build core Hamcrest library">
29-
<java-to-jar srcdir="hamcrest-core/src/main/java" modulename="hamcrest-core-${version}"/>
30+
<java-to-jar srcdir="hamcrest-core/src/main/java" modulename="hamcrest-core"/>
3031

3132
<!-- Generate one class with all static imports -->
3233
<mkdir dir="build/temp/hamcrest-core/generated-code"/>
@@ -45,7 +46,7 @@
4546
</java>
4647
<!-- Append to core jar -->
4748
<java-to-jar srcdir="build/temp/hamcrest-core/generated-code"
48-
modulename="hamcrest-core-${version}"
49+
modulename="hamcrest-core"
4950
classpath="build/hamcrest-core-${version}.jar"/>
5051
</target>
5152

@@ -54,7 +55,7 @@
5455
description="Build library of matchers">
5556
<mkdir dir="build/temp/hamcrest-library/generated-code"/>
5657
<java-to-jar srcdir="hamcrest-library/src/main/java"
57-
modulename="hamcrest-library-${version}"
58+
modulename="hamcrest-library"
5859
classpath="build/hamcrest-core-${version}.jar"/>
5960
<!-- Generate one class with all static imports -->
6061
<java classname="org.hamcrest.generator.config.XmlConfigurator"
@@ -72,24 +73,23 @@
7273
</java>
7374
<!-- Append to library jar -->
7475
<java-to-jar srcdir="build/temp/hamcrest-library/generated-code"
75-
modulename="hamcrest-library-${version}"
76+
modulename="hamcrest-library"
7677
classpath="build/hamcrest-core-${version}.jar"/>
7778
</target>
7879

7980
<target name="integration" depends="core, library" description="Build integration with external tools">
80-
<java-to-jar srcdir="hamcrest-integration/src/main/java" modulename="hamcrest-integration-${version}"
81-
classpath="
82-
build/hamcrest-core-${version}.jar;
83-
build/hamcrest-library-${version}.jar"/>
81+
<java-to-jar srcdir="hamcrest-integration/src/main/java"
82+
modulename="hamcrest-integration"
83+
classpath="build/hamcrest-core-${version}.jar;
84+
build/hamcrest-library-${version}.jar"/>
8485
</target>
8586

8687
<target name="unit-test" depends="core, library, integration, generator" description="Build and run unit tests.">
87-
<java-to-jar srcdir="hamcrest-unit-test/src/main/java" modulename="hamcrest-unit-test-${version}"
88-
classpath="
89-
build/hamcrest-core-${version}.jar;
90-
build/hamcrest-library-${version}.jar;
91-
build/hamcrest-integration-${version}.jar;
92-
build/hamcrest-generator-${version}.jar"/>
88+
<java-to-jar srcdir="hamcrest-unit-test/src/main/java" modulename="hamcrest-unit-test"
89+
classpath="build/hamcrest-core-${version}.jar;
90+
build/hamcrest-library-${version}.jar;
91+
build/hamcrest-integration-${version}.jar;
92+
build/hamcrest-generator-${version}.jar"/>
9393
<junit printsummary="no" fork="no" haltonfailure="${haltonfailure}">
9494
<formatter type="brief" usefile="no"/>
9595
<classpath>
@@ -113,22 +113,29 @@
113113

114114
<target name="examples" depends="core, library, integration" description="Build and run unit tests.">
115115
<java-to-jar srcdir="hamcrest-examples/src/main/java"
116-
modulename="hamcrest-examples-${version}"
117-
classpath="
118-
build/hamcrest-core-${version}.jar;
119-
build/hamcrest-library-${version}.jar;
120-
build/hamcrest-integration-${version}.jar"/>
116+
modulename="hamcrest-examples"
117+
classpath="build/hamcrest-core-${version}.jar;
118+
build/hamcrest-library-${version}.jar;
119+
build/hamcrest-integration-${version}.jar"/>
121120
</target>
122121

123122
<target name="bigjar" depends="core, library, integration, generator"
124123
description="Build a single Jar (hamcrest-all.jar) that contains core, library, generator and integration.">
125-
<jar jarfile="build/hamcrest-all-${version}.jar" duplicate="preserve">
124+
<mkdir dir="build/temp/hamcrest-all-${version}.jar.manifest"/>
125+
<manifest file="build/temp/hamcrest-all-${version}.jar.manifest/MANIFEST.MF">
126+
<attribute name="Implementation-Title" value="hamcrest-all"/>
127+
<attribute name="Implementation-Vendor" value="hamcrest.org"/>
128+
<attribute name="Implementation-Version" value="${version}"/>
129+
<attribute name="Built-By" value="${user.name}"/>
130+
<attribute name="Built-Date" value="${build.timestamp}"/>
131+
</manifest>
132+
<jar jarfile="build/hamcrest-all-${version}.jar" duplicate="preserve" manifest="build/temp/hamcrest-all-${version}.jar.manifest/MANIFEST.MF">
126133
<zipfileset src="build/hamcrest-core-${version}.jar"/>
127134
<zipfileset src="build/hamcrest-library-${version}.jar"/>
128135
<zipfileset src="build/hamcrest-generator-${version}.jar"/>
129136
<zipfileset src="build/hamcrest-integration-${version}.jar"/>
130137
</jar>
131-
<jar jarfile="build/hamcrest-all-${version}-sources.jar" duplicate="preserve">
138+
<jar jarfile="build/hamcrest-all-${version}-sources.jar" duplicate="preserve" manifest="build/temp/hamcrest-all-${version}.jar.manifest/MANIFEST.MF">
132139
<zipfileset src="build/hamcrest-core-${version}-sources.jar"/>
133140
<zipfileset src="build/hamcrest-library-${version}-sources.jar"/>
134141
<zipfileset src="build/hamcrest-generator-${version}-sources.jar"/>
@@ -137,10 +144,10 @@
137144
</target>
138145

139146
<target name="javadoc" description="build javadoc jars">
140-
<java-to-javadoc-jar modulename="hamcrest-generator-nodeps-${version}"/>
141-
<java-to-javadoc-jar modulename="hamcrest-core-${version}"/>
142-
<java-to-javadoc-jar modulename="hamcrest-library-${version}"/>
143-
<java-to-javadoc-jar modulename="hamcrest-integration-${version}"/>
147+
<java-to-javadoc-jar modulename="hamcrest-generator-nodeps"/>
148+
<java-to-javadoc-jar modulename="hamcrest-core"/>
149+
<java-to-javadoc-jar modulename="hamcrest-library"/>
150+
<java-to-javadoc-jar modulename="hamcrest-integration"/>
144151
<copy file="build/hamcrest-generator-nodeps-${version}-javadoc.jar" tofile="build/hamcrest-generator-${version}-javadoc.jar"/>
145152

146153
<javadoc packagenames="org.hamcrest.*" defaultexcludes="yes"
@@ -268,35 +275,43 @@
268275
<attribute name="modulename" description="Name of the module to jar"/>
269276
<attribute name="classpath" description="Anything additional to add on the classpath" default=""/>
270277
<sequential>
271-
<mkdir dir="build/temp/@{modulename}.jar.contents"/>
272-
<javac srcdir="@{srcdir}" destdir="build/temp/@{modulename}.jar.contents" debug="${debug}" target="1.5" includeantruntime="false">
278+
<mkdir dir="build/temp/@{modulename}-${version}.jar.manifest"/>
279+
<manifest file="build/temp/@{modulename}-${version}.jar.manifest/MANIFEST.MF">
280+
<attribute name="Implementation-Title" value="@{modulename}"/>
281+
<attribute name="Implementation-Vendor" value="hamcrest.org"/>
282+
<attribute name="Implementation-Version" value="${version}"/>
283+
<attribute name="Built-By" value="${user.name}"/>
284+
<attribute name="Built-Date" value="${build.timestamp}"/>
285+
</manifest>
286+
<mkdir dir="build/temp/@{modulename}-${version}.jar.contents"/>
287+
<javac srcdir="@{srcdir}" destdir="build/temp/@{modulename}-${version}.jar.contents" debug="${debug}" target="1.5" includeantruntime="false">
273288
<classpath>
274289
<fileset dir="lib/integration">
275290
<include name="*.jar"/>
276291
</fileset>
277292
<pathelement path="@{classpath}"/>
278293
</classpath>
279294
</javac>
280-
<copy file="LICENSE.txt" todir="build/temp/@{modulename}.jar.contents"/>
281-
<jar jarfile="build/@{modulename}.jar">
282-
<fileset dir="build/temp/@{modulename}.jar.contents"/>
295+
<copy file="LICENSE.txt" todir="build/temp/@{modulename}-${version}.jar.contents"/>
296+
<jar jarfile="build/@{modulename}-${version}.jar" manifest="build/temp/@{modulename}-${version}.jar.manifest/MANIFEST.MF">
297+
<fileset dir="build/temp/@{modulename}-${version}.jar.contents"/>
283298
</jar>
284299

285300
<!-- Build sources jar -->
286-
<copy todir="build/temp/@{modulename}-sources.jar.contents">
301+
<copy todir="build/temp/@{modulename}-${version}-sources.jar.contents">
287302
<fileset dir="@{srcdir}"/>
288303
</copy>
289-
<jar jarfile="build/@{modulename}-sources.jar">
290-
<fileset dir="build/temp/@{modulename}-sources.jar.contents"/>
304+
<jar jarfile="build/@{modulename}-${version}-sources.jar" manifest="build/temp/@{modulename}-${version}.jar.manifest/MANIFEST.MF">
305+
<fileset dir="build/temp/@{modulename}-${version}-sources.jar.contents"/>
291306
</jar>
292307
</sequential>
293308
</macrodef>
294309

295310
<macrodef name="java-to-javadoc-jar" description="Generate javadoc for a module and build a Jar">
296311
<attribute name="modulename" description="Name of the module to document"/>
297312
<sequential>
298-
<javadoc packagenames="org.hamcrest.*" sourcepath="build/temp/@{modulename}-sources.jar.contents" defaultexcludes="yes"
299-
destdir="build/temp/@{modulename}-javadoc.jar.contents" author="true" version="true" use="true"
313+
<javadoc packagenames="org.hamcrest.*" sourcepath="build/temp/@{modulename}-${version}-sources.jar.contents" defaultexcludes="yes"
314+
destdir="build/temp/@{modulename}-${version}-javadoc.jar.contents" author="true" version="true" use="true"
300315
windowtitle="Hamcrest" source="1.6" failonerror="yes">
301316
<classpath>
302317
<fileset dir="lib/integration">
@@ -309,8 +324,8 @@
309324
<fileset file="build/hamcrest-integration-${version}.jar"/>
310325
</classpath>
311326
</javadoc>
312-
<jar jarfile="build/@{modulename}-javadoc.jar">
313-
<fileset dir="build/temp/@{modulename}-javadoc.jar.contents"/>
327+
<jar jarfile="build/@{modulename}-${version}-javadoc.jar">
328+
<fileset dir="build/temp/@{modulename}-${version}-javadoc.jar.contents"/>
314329
</jar>
315330
</sequential>
316331
</macrodef>

0 commit comments

Comments
 (0)