From 5775eee44815c5dcc40be090b4773e212bd42a9f Mon Sep 17 00:00:00 2001 From: Moncef STITI Date: Thu, 6 Feb 2025 17:54:18 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20la=20gestion=20des=20timestamps=20?= =?UTF-8?q?pour=20les=20fichiers=20cibles=20et=20d=C3=A9pendances,=20avec?= =?UTF-8?q?=20des=20messages=20de=20d=C3=A9bogage=20pour=20faciliter=20le?= =?UTF-8?q?=20suivi=20des=20modifications.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fr/monlouyan/bakefile/Rule.java | 9 +++++++++ src/fr/monlouyan/bakefile/TimestampManager.java | 13 +++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/fr/monlouyan/bakefile/Rule.java b/src/fr/monlouyan/bakefile/Rule.java index 0b1b01c..a3218c2 100644 --- a/src/fr/monlouyan/bakefile/Rule.java +++ b/src/fr/monlouyan/bakefile/Rule.java @@ -101,9 +101,18 @@ public class Rule { System.out.println("Debug : Checking if target file " + name + " exist and is up to date"); } long targetTimestamp = targetFile.exists() ? TimestampManager.getTimestamp(targetFile) : 0; + + if (BakeCLI.isDebug()) { + System.out.println("Debug : Target file '" + name + "' last modified at " + TimestampManager.formatTimestamp(targetTimestamp)); + } for (String dependency : dependencies) { File depFile = new File(dependency); + long depTimestamp = depFile.exists() ? TimestampManager.getTimestamp(depFile) : 0; + + if (BakeCLI.isDebug()) { + System.out.println("Debug : Dependency '" + dependency + "' last modified at " + TimestampManager.formatTimestamp(depTimestamp)); + } if (!depFile.exists() && !dependency.isEmpty()) { System.out.println("bake: *** No rule to make target '" + dependency + "', needed by '" + name + "'. Stop."); diff --git a/src/fr/monlouyan/bakefile/TimestampManager.java b/src/fr/monlouyan/bakefile/TimestampManager.java index fc37bda..6ffac34 100644 --- a/src/fr/monlouyan/bakefile/TimestampManager.java +++ b/src/fr/monlouyan/bakefile/TimestampManager.java @@ -1,6 +1,8 @@ package fr.monlouyan.bakefile; import java.io.File; +import java.text.SimpleDateFormat; +import java.util.Date; /** * Classe utilitaire pour la gestion des timestamps des fichiers. @@ -36,4 +38,15 @@ public class TimestampManager { long time2 = getTimestamp(file2); return Long.compare(time1, time2); } + + /** + * Permet de formater un timestamp en une date lisible. + * @param timestamp Le timestamp à formater + * @return La date formatée + */ + public static String formatTimestamp(long timestamp) { + if (timestamp == 0) return "N/A"; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + return sdf.format(new Date(timestamp)); + } }