Created attachment 34985 [details] patch to implement this To enable reproducible builds of various java packages, ant should allow to override the timestamps it inserts (such as 'TODAY')
Thanks Bernhard Traditionally Ant would use "magic" (system) properties for something like this rather than environment variables. This would also allow us to easily test the change.
How would one use the magic properties? And would that work without patching all ~100 packages individually that call ant during build in openSUSE? (we already have a patch for rpm to set the SOURCE_DATE_EPOCH variable globally to the latest changelog date of a package)
The magic properties would be something like -Dant.fixed.now=SOME_TS for each and every invocation. Ant's java code doesn't really use getEnv anywhere and we really want to keep it that way. By packages I assume you are talking about SUSE packages that execute Ant to build, right? Ant's wrapper shell script reacts to environment variables, in particular ANT_OPTS for parameters to send to the JVM (like max memory and so on) and ANT_ARGS for Ant itself. In a build farm like yours you'd set ANT_ARGS to contain the property call above.
I tried to build jcodings with an added export ANT_ARGS="-Dant.fixed.now=123456789" but still get in META-INF/MANIFEST.MF Built-Date: 2018-06-14 Built-Time: 05:07:50 and google is not good at finding any examples for how to use this
Oh, I'm sorry, we've been talking past each other. I was referring to your patch and wanted to ask you to rewrite it to use a project property rather than an environment variable. The example I gave was for a time after a modified version of your patch had been applied (and ant.fixed.time would be the name of the hypothetical magic property). I should be able to free up a bit of time tonight to add the feature to tstamp, don't bother with modifying the patch, I'll do so myself. The result will become available once 1.9.10 or 1.10.2 get released.
ah, now I got it. Thanks for doing the patch (I did not do much java coding after 1.0.x). would be nice, if you could then link the patch here, so that I can also test it before the official release.
The property's name is ant.tstamp.now - added with git commit 966708a to master, will be in 1.9.10 and 1.10.2.
many thanks
I tested your patch and it works great. Thanks a lot.
You use "seconds sind epoch" to define 'now'. <target name="testMagicProperty"> <local name="ant.tstamp.now"/> <property name="ant.tstamp.now" value="100000"/> <tstamp/> <au:assertPropertyEquals name="DSTAMP" value="19700102"/> </target> Would it be more user friendly to use the ISO format instead/additionally? <target name="testMagicProperty"> <local name="ant.tstamp.now.iso"/> <property name="ant.tstamp.now" value="2017-05-09T08:07"/> <tstamp/> <au:assertPropertyEquals name="DSTAMP" value="20170509"/> </target>
yes, sounds reasonable.
I added a second MagicProperty 'ant.tstamp.now.iso'. I used Java8 features, to a backport would require a little more work ;)