From 9c867bbe1a7916dd06da945406693d19ef8b4778 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 7 Sep 2013 22:56:10 +0200 Subject: [PATCH] Cleaned up code (formatting and logical code-order) --- .../juplo/plugins/hibernate4/Hbm2DdlMojo.java | 57 ++++++++++--------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java b/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java index 246f5852..a7eab4ce 100644 --- a/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java +++ b/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java @@ -199,6 +199,13 @@ public class Hbm2DdlMojo extends AbstractMojo */ private String hibernateDialect; + /** + * Generate envers schema for auditing tables. + * + * @parameter expression="${hibernate.export.envers}" default-value="false" + */ + private Boolean envers; + /** * Path to Hibernate configuration file. * @@ -251,12 +258,6 @@ public class Hbm2DdlMojo extends AbstractMojo */ private boolean format; - /** - * Generate envers schema for auditing tables. - * - * @parameter expression="${hibernate.export.envers}" default-value="false" - */ - private Boolean envers; @Override public void execute() @@ -492,6 +493,19 @@ public class Hbm2DdlMojo extends AbstractMojo getLog().debug("Using the value " + hibernateDialect); properties.setProperty(DIALECT, hibernateDialect); } + if (envers != null) + { + if (properties.containsKey(ENVERS)) + getLog().debug( + "Overwriting property " + + ENVERS + "=" + properties.getProperty(ENVERS) + + " with the value " + envers + ); + else + getLog().debug("Using the value " + envers); + properties.setProperty(ENVERS, envers.toString()); + } + /** The generated SQL varies with the dialect! */ if (md5s.containsKey(DIALECT)) @@ -512,14 +526,15 @@ public class Hbm2DdlMojo extends AbstractMojo md5s.put(DIALECT, properties.getProperty(DIALECT)); } + /** The generated SQL varies with the envers-configuration! */ if (md5s.containsKey(ENVERS)) { String envers = properties.getProperty(ENVERS); if (md5s.get(ENVERS).equals(envers)) - getLog().debug("Envers unchanged."); + getLog().debug("Envers-configuration unchanged."); else { - getLog().debug("Envers changed: " + envers); + getLog().debug("Envers-configuration changed: " + envers); modified = true; md5s.put(ENVERS, envers.toString()); } @@ -530,18 +545,6 @@ public class Hbm2DdlMojo extends AbstractMojo md5s.put(ENVERS, properties.getProperty(ENVERS)); } - if (envers != null) { - if (properties.containsKey(ENVERS)) - getLog().debug( - "Overwriting property " + - ENVERS + "=" + properties.getProperty(ENVERS) + - " with the value " + envers - ); - else - getLog().debug("Using the value " + envers); - properties.setProperty(ENVERS, envers.toString()); - } - if (properties.isEmpty()) { getLog().error("No properties set!"); @@ -556,6 +559,13 @@ public class Hbm2DdlMojo extends AbstractMojo getLog().debug("Class " + annotatedClass); config.addAnnotatedClass(annotatedClass); } + if ("true".equals(properties.getProperty(ENVERS))) + { + config.buildMappings(); + getLog().debug("Using envers"); + AuditConfiguration.getFor(config); + } + Target target = null; try @@ -663,13 +673,6 @@ public class Hbm2DdlMojo extends AbstractMojo */ Thread.currentThread().setContextClassLoader(classLoader); - config.buildMappings(); - if ("true".equals(properties.getProperty(ENVERS))) - { - getLog().debug("Using envers"); - AuditConfiguration.getFor(config); - } - SchemaExport export = new SchemaExport(config, connection); export.setOutputFile(outputFile); export.setDelimiter(delimiter); -- 2.20.1