Ajout de la détection des timestamps futurs dans le système de build et mise à jour des messages d'avertissement
This commit is contained in:
@@ -2,6 +2,7 @@ package fr.monlouyan.bakefile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
|
||||
public class Rule {
|
||||
private String name;
|
||||
@@ -97,6 +98,8 @@ public class Rule {
|
||||
System.out.println("Debug : Target file '" + name + "' last modified at " + TimestampManager.formatTimestamp(targetTimestamp));
|
||||
}
|
||||
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
for (String dependency : dependencies) {
|
||||
// Skip dependencies with tilde in path
|
||||
if (dependency.startsWith("~")) {
|
||||
@@ -104,7 +107,22 @@ public class Rule {
|
||||
}
|
||||
|
||||
File depFile = new File(dependency);
|
||||
long depTimestamp = depFile.exists() ? TimestampManager.getTimestamp(depFile) : 0;
|
||||
if (!depFile.exists()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
long depTimestamp = TimestampManager.getTimestamp(depFile);
|
||||
|
||||
// Vérifier si le timestamp de la dépendance est dans le futur
|
||||
if (depTimestamp > currentTime) {
|
||||
// Avertissement similaire à make
|
||||
System.out.println("bake: Warning: File '" + dependency + "' has modification time "
|
||||
+ ((depTimestamp - currentTime) / 1000) + " s in the future");
|
||||
if (BakeCLI.isDebug()) {
|
||||
System.out.println("Debug : Dependency " + dependency + " has a timestamp in the future, needs update");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (BakeCLI.isDebug()) {
|
||||
System.out.println("Debug : Dependency '" + dependency + "' last modified at " + TimestampManager.formatTimestamp(depTimestamp));
|
||||
@@ -120,13 +138,14 @@ public class Rule {
|
||||
}
|
||||
|
||||
// Vérifier les timestamps seulement si le fichier existe
|
||||
if (depFile.exists() && TimestampManager.getTimestamp(depFile) > targetTimestamp) {
|
||||
if (depTimestamp > targetTimestamp) {
|
||||
if (BakeCLI.isDebug()) {
|
||||
System.out.println("Debug : Dependency " + dependency + " is newer than target file " + name + ", needs update");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user