X-Git-Url: https://juplo.de/gitweb/?p=hibernate4-maven-plugin;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fde%2Fjuplo%2Fplugins%2Fhibernate%2FModificationTracker.java;h=02820693a9b431648a69d76810731aa9a01c7c9d;hp=e03f78e9ab96bcb6a43d75b5541b15427ce577b9;hb=6dff3bfb0f9ea7a1d0cc56398aaad29e31a17b91;hpb=b316a5b4122c3490047b68e1e4a6df205645aad5 diff --git a/src/main/java/de/juplo/plugins/hibernate/ModificationTracker.java b/src/main/java/de/juplo/plugins/hibernate/ModificationTracker.java index e03f78e9..02820693 100644 --- a/src/main/java/de/juplo/plugins/hibernate/ModificationTracker.java +++ b/src/main/java/de/juplo/plugins/hibernate/ModificationTracker.java @@ -26,8 +26,6 @@ import org.apache.maven.plugin.logging.Log; */ public class ModificationTracker { - public final static String MD5S = "hibernate-generatedschema.md5s"; - private Map properties; private Map classes; @@ -41,13 +39,23 @@ public class ModificationTracker private final Log log; - ModificationTracker(String buildDirectory, Log log) + ModificationTracker(String buildDirectory, String filename, Log log) throws NoSuchAlgorithmException { propertyNames = new HashSet(); classNames = new HashSet(); - saved = new File(buildDirectory + File.separator + MD5S); + File output = new File(filename + ".md5s"); + if (output.isAbsolute()) + { + saved = output; + } + else + { + // Interpret relative file path relative to build directory + saved = new File(buildDirectory, output.getPath()); + log.debug("Adjusted relative path, resulting path is " + saved.getPath()); + } digest = java.security.MessageDigest.getInstance("MD5"); this.log = log; } @@ -79,7 +87,7 @@ public class ModificationTracker } - boolean check(String name, InputStream is) throws IOException + boolean track(String name, InputStream is) throws IOException { boolean result = check(classes, name, calculate(is)); classNames.add(name); @@ -87,23 +95,34 @@ public class ModificationTracker return result; } + boolean check(String name, String property) { - boolean result = check(properties, name, property); propertyNames.add(name); + return check(properties, name, property); + } + + boolean track(String name, String property) + { + boolean result = check(name, property); modified |= result; return result; } - boolean check(Properties properties) + boolean track(Properties properties) { boolean result = false; for (String name : properties.stringPropertyNames()) - result |= check(name, properties.getProperty(name)); + result |= track(name, properties.getProperty(name)); return result; } + void touch() + { + modified = true; + } + boolean modified() { modified |= !propertyNames.containsAll(properties.keySet());