Skip to content

Commit 39b7371

Browse files
committed
build.xml: Add SOURCE_DATE_EPOCH support
Set the "timestamp" attribute to the current time. When using Ant >= 1.10.8, it can be overridden with the SOURCE_DATE_EPOCH environment variable. With Ant >= 1.10.2, the ant.tstamp.now property does the same thing. Use <jar modificationtime="${timestamp}"> to set file timestamps inside JARs. Reproducible builds should now be possible by setting SOURCE_DATE_EPOCH to a known value. Timestamps in JARs are in local timezone, thus setting also TZ=UTC0 can be useful. For example, the committer date of the latest commit provides a reasonable timestamp: $ SOURCE_DATE_EPOCH=$(git log -n1 --pretty=%ct) TZ=UTC0 ant
1 parent 5689e64 commit 39b7371

File tree

2 files changed

+34
-9
lines changed

2 files changed

+34
-9
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ Building with Apache Ant
3232

3333
Notes about old build environments:
3434

35+
* If you are using Ant older than 1.10.2:
36+
37+
Edit `build.xml` and remove the `modificationtime="${timestamp}"`
38+
attributes from the `<jar>` elements.
39+
3540
* If you are using Ant older than 1.9.8:
3641

3742
Edit `build.xml` and remove the release attributes from the

build.xml

+29-9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
<property file="build.properties"/>
1010

11+
<tstamp>
12+
<format property="timestamp" pattern="yyyy-MM-dd'T'HH:mm:ssXXX"/>
13+
</tstamp>
14+
1115
<target name="clean"
1216
description="Deletes all generated files">
1317
<delete dir="${build_dir}"/>
@@ -71,7 +75,7 @@
7175
description="Creates JAR packages">
7276
<mkdir dir="${jar_dir}"/>
7377

74-
<jar destfile="${jar_dir}/xz.jar">
78+
<jar destfile="${jar_dir}/xz.jar" modificationtime="${timestamp}">
7579
<fileset dir="${classes_dir}" includes="org/tukaani/xz/**"/>
7680
<zipfileset prefix="META-INF/versions/9/" dir="${classes9_dir}"
7781
unless:true="${java8only}"/>
@@ -95,55 +99,69 @@
9599
</manifest>
96100
</jar>
97101

98-
<jar destfile="${jar_dir}/TestAllocSpeed.jar" basedir="${classes_dir}"
102+
<jar destfile="${jar_dir}/TestAllocSpeed.jar"
103+
modificationtime="${timestamp}"
104+
basedir="${classes_dir}"
99105
includes="TestAllocSpeed.class">
100106
<manifest>
101107
<attribute name="Main-Class" value="TestAllocSpeed"/>
102108
<attribute name="Class-Path" value="xz.jar"/>
103109
</manifest>
104110
</jar>
105111

106-
<jar destfile="${jar_dir}/XZEncDemo.jar" basedir="${classes_dir}"
112+
<jar destfile="${jar_dir}/XZEncDemo.jar"
113+
modificationtime="${timestamp}"
114+
basedir="${classes_dir}"
107115
includes="XZEncDemo.class">
108116
<manifest>
109117
<attribute name="Main-Class" value="XZEncDemo"/>
110118
<attribute name="Class-Path" value="xz.jar"/>
111119
</manifest>
112120
</jar>
113121

114-
<jar destfile="${jar_dir}/XZDecDemo.jar" basedir="${classes_dir}"
122+
<jar destfile="${jar_dir}/XZDecDemo.jar"
123+
modificationtime="${timestamp}"
124+
basedir="${classes_dir}"
115125
includes="XZDecDemo.class">
116126
<manifest>
117127
<attribute name="Main-Class" value="XZDecDemo"/>
118128
<attribute name="Class-Path" value="xz.jar"/>
119129
</manifest>
120130
</jar>
121131

122-
<jar destfile="${jar_dir}/XZSeekEncDemo.jar" basedir="${classes_dir}"
132+
<jar destfile="${jar_dir}/XZSeekEncDemo.jar"
133+
modificationtime="${timestamp}"
134+
basedir="${classes_dir}"
123135
includes="XZSeekEncDemo.class">
124136
<manifest>
125137
<attribute name="Main-Class" value="XZSeekEncDemo"/>
126138
<attribute name="Class-Path" value="xz.jar"/>
127139
</manifest>
128140
</jar>
129141

130-
<jar destfile="${jar_dir}/XZSeekDecDemo.jar" basedir="${classes_dir}"
142+
<jar destfile="${jar_dir}/XZSeekDecDemo.jar"
143+
modificationtime="${timestamp}"
144+
basedir="${classes_dir}"
131145
includes="XZSeekDecDemo.class">
132146
<manifest>
133147
<attribute name="Main-Class" value="XZSeekDecDemo"/>
134148
<attribute name="Class-Path" value="xz.jar"/>
135149
</manifest>
136150
</jar>
137151

138-
<jar destfile="${jar_dir}/LZMAEncDemo.jar" basedir="${classes_dir}"
152+
<jar destfile="${jar_dir}/LZMAEncDemo.jar"
153+
modificationtime="${timestamp}"
154+
basedir="${classes_dir}"
139155
includes="LZMAEncDemo.class">
140156
<manifest>
141157
<attribute name="Main-Class" value="LZMAEncDemo"/>
142158
<attribute name="Class-Path" value="xz.jar"/>
143159
</manifest>
144160
</jar>
145161

146-
<jar destfile="${jar_dir}/LZMADecDemo.jar" basedir="${classes_dir}"
162+
<jar destfile="${jar_dir}/LZMADecDemo.jar"
163+
modificationtime="${timestamp}"
164+
basedir="${classes_dir}"
147165
includes="LZMADecDemo.class">
148166
<manifest>
149167
<attribute name="Main-Class" value="LZMADecDemo"/>
@@ -176,9 +194,11 @@
176194
preservelastmodified="true" overwrite="true"/>
177195

178196
<jar destfile="${maven_dir}/xz-${version}-javadoc.jar"
197+
modificationtime="${timestamp}"
179198
basedir="${doc_dir}"/>
180199

181-
<jar destfile="${maven_dir}/xz-${version}-sources.jar">
200+
<jar destfile="${maven_dir}/xz-${version}-sources.jar"
201+
modificationtime="${timestamp}">
182202
<fileset dir="${src_dir}" includes="org/tukaani/xz/**"/>
183203
<zipfileset prefix="META-INF/versions/9/" dir="${src9_dir}"/>
184204
</jar>

0 commit comments

Comments
 (0)