git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[JGIT PATCH 1/3] Make all files in our JAR have the same timestamp

From
Shawn O. Pearce <spearce@spearce.org>
Date
Sep 2, 2008, 16:28 UTC
Message-ID
<1220372892-15423-1-git-send-email-spearce@spearce.org>

When we link together our classes into a JAR we want to use the same timestamp for all entries in the archive. Using different times from the local filesystem is fairly meaningless.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../org/spearce/jgit/pgm/build/JarLinkUtil.java    |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/build/JarLinkUtil.java b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/build/JarLinkUtil.java
index 46ae0ea..929ee55 100644
--- a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/build/JarLinkUtil.java
+++ b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/build/JarLinkUtil.java
@@ -93,6 +93,8 @@ public static void main(final String[] argv) throws IOException {
 
 	private final Map<String, File> chosenSources = new HashMap<String, File>();
 
+	private long creationTime;
+
 	private ZipOutputStream zos;
 
 	private JarLinkUtil() {
@@ -109,6 +111,7 @@ private void run() throws IOException {
 		for (final Map.Entry<String, String> e : files.entrySet())
 			chosenSources.put(e.getKey(), new File(e.getValue()));
 
+		creationTime = System.currentTimeMillis();
 		zos = new ZipOutputStream(System.out);
 		zos.setLevel(9);
 
@@ -180,9 +183,8 @@ else if (chosenSources.get(pfx + e.getName()) == rootDir)
 	private void appendFile(final File path, final String name)
 			throws IOException {
 		final long len = path.length();
-		final long time = path.lastModified();
 		final InputStream is = new FileInputStream(path);
-		appendEntry(name, len, time, is);
+		appendEntry(name, len, creationTime, is);
 	}
 
 	private void appendEntry(final String name, final long len,
-- 
1.6.0.1.207.g020e5
Next: Shawn O. Pearce
Message 1 of 3 in “Make all files in our JAR have the same timestamp”
  1. 1/3 Make all files in our JAR have the same timestampShawn O. Pearce, Sep 2, 2008
  2. 2/3 Build jgit.jar and jgit_src.zip alongside jgit CLI wrapperShawn O. Pearce, Sep 2, 2008
  3. 3/3 Add a tiny "jgit version" programShawn O. Pearce, Sep 2, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.