From 8a2e08b6409034fd692c4bea72058f785e6802ad Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Fri, 14 Dec 2012 02:13:05 +0100 Subject: [PATCH] The Targets EXPORT and NONE force excecution Otherwise, an explicitly requestes SQL-export or mapping-test-run would be skipped, if no annotated class was modified. If the export is skipped, this is signaled via the maven-property hibernate.export.skipped. Refactored name of the skip-property to an public final static String --- .../juplo/plugins/hibernate4/Hbm2DdlMojo.java | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java b/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java index bc0bc73a..7a5e0af0 100644 --- a/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java +++ b/src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java @@ -70,6 +70,8 @@ import org.scannotation.AnnotationDB; */ public class Hbm2DdlMojo extends AbstractMojo { + public final static String EXPORT_SKIPPED_PROPERTY = "hibernate.export.skipped"; + public final static String DRIVER_CLASS = "hibernate.connection.driver_class"; public final static String URL = "hibernate.connection.url"; public final static String USERNAME = "hibernate.connection.username"; @@ -205,6 +207,7 @@ public class Hbm2DdlMojo extends AbstractMojo if (skip) { getLog().info("Exectuion of hibernate4-maven-plugin:export was skipped!"); + project.getProperties().setProperty(EXPORT_SKIPPED_PROPERTY, "true"); return; } @@ -458,22 +461,11 @@ public class Hbm2DdlMojo extends AbstractMojo md5s.put(DIALECT, properties.getProperty(DIALECT)); } - if (!modified) - { - getLog().info("No modified annotated classes found and dialect unchanged."); - getLog().info("Skipping schema generation!"); - project.getProperties().setProperty("hibernate.export.skipped", "true"); - return; - } - - getLog().info("Gathered hibernate-configuration (turn on debugging for details):"); if (properties.isEmpty()) { getLog().error("No properties set!"); throw new MojoFailureException("Hibernate-Configuration is missing!"); } - for (Entry entry : properties.entrySet()) - getLog().info(" " + entry.getKey() + " = " + entry.getValue()); Configuration config = new Configuration(); config.setProperties(properties); @@ -507,6 +499,26 @@ public class Hbm2DdlMojo extends AbstractMojo throw new MojoExecutionException("Invalid value for configuration-option \"type\""); } + if (target.equals(Target.SCRIPT) || target.equals(Target.NONE)) + { + project.getProperties().setProperty(EXPORT_SKIPPED_PROPERTY, "true"); + } + if ( + !modified + && !target.equals(Target.SCRIPT) + && !target.equals(Target.NONE) + ) + { + getLog().info("No modified annotated classes found and dialect unchanged."); + getLog().info("Skipping schema generation!"); + project.getProperties().setProperty(EXPORT_SKIPPED_PROPERTY, "true"); + return; + } + + getLog().info("Gathered hibernate-configuration (turn on debugging for details):"); + for (Entry entry : properties.entrySet()) + getLog().info(" " + entry.getKey() + " = " + entry.getValue()); + Connection connection = null; try { -- 2.20.1