Improved log-messages
[hibernate4-maven-plugin] / src / main / java / de / juplo / plugins / hibernate4 / Hbm2DdlMojo.java
index a2306ac..e7aa154 100644 (file)
@@ -110,6 +110,16 @@ public class Hbm2DdlMojo extends AbstractMojo
    */
   private boolean skip;
 
+  /**
+   * Force execution
+   * <p>
+   * Force execution, even if no modified or newly added annotated classes
+   * where found. <code>skip</code> takes precedence over <code>force</code>.
+   *
+   * @parameter expression="${hibernate.export.force}" default-value="false"
+   */
+  private boolean force;
+
   /**
    * SQL-Driver name.
    *
@@ -352,7 +362,7 @@ public class Hbm2DdlMojo extends AbstractMojo
         properties.load(new FileInputStream(file));
       }
       else
-        getLog().info("No hibernate-properties-file found! Checked path: " + hibernateProperties);
+        getLog().info("No hibernate-properties-file found! (Checked path: " + hibernateProperties + ")");
     }
     catch (IOException e)
     {
@@ -367,14 +377,10 @@ public class Hbm2DdlMojo extends AbstractMojo
         getLog().debug(
             "Overwriting property " +
             DRIVER_CLASS + "=" + properties.getProperty(DRIVER_CLASS) +
-            " with the value " + driverClassName +
-            " from the plugin-configuration-parameter driverClassName!"
+            " with the value " + driverClassName
           );
       else
-        getLog().debug(
-            "Using the value " + driverClassName +
-            " from the plugin-configuration-parameter driverClassName!"
-          );
+        getLog().debug("Using the value " + driverClassName);
       properties.setProperty(DRIVER_CLASS, driverClassName);
     }
     if (url != null)
@@ -383,14 +389,10 @@ public class Hbm2DdlMojo extends AbstractMojo
         getLog().debug(
             "Overwriting property " +
             URL + "=" + properties.getProperty(URL) +
-            " with the value " + url +
-            " from the plugin-configuration-parameter url!"
+            " with the value " + url
           );
       else
-        getLog().debug(
-            "Using the value " + url +
-            " from the plugin-configuration-parameter url!"
-          );
+        getLog().debug("Using the value " + url);
       properties.setProperty(URL, url);
     }
     if (username != null)
@@ -399,14 +401,10 @@ public class Hbm2DdlMojo extends AbstractMojo
         getLog().debug(
             "Overwriting property " +
             USERNAME + "=" + properties.getProperty(USERNAME) +
-            " with the value " + username +
-            " from the plugin-configuration-parameter username!"
+            " with the value " + username
           );
       else
-        getLog().debug(
-            "Using the value " + username +
-            " from the plugin-configuration-parameter username!"
-          );
+        getLog().debug("Using the value " + username);
       properties.setProperty(USERNAME, username);
     }
     if (password != null)
@@ -415,14 +413,10 @@ public class Hbm2DdlMojo extends AbstractMojo
         getLog().debug(
             "Overwriting property " +
             PASSWORD + "=" + properties.getProperty(PASSWORD) +
-            " with the value " + password +
-            " from the plugin-configuration-parameter password!"
+            " with the value " + password 
           );
       else
-        getLog().debug(
-            "Using the value " + password +
-            " from the plugin-configuration-parameter password!"
-          );
+        getLog().debug("Using the value " + password);
       properties.setProperty(PASSWORD, password);
     }
     if (hibernateDialect != null)
@@ -431,14 +425,10 @@ public class Hbm2DdlMojo extends AbstractMojo
         getLog().debug(
             "Overwriting property " +
             DIALECT + "=" + properties.getProperty(DIALECT) +
-            " with the value " + hibernateDialect +
-            " from the plugin-configuration-parameter hibernateDialect!"
+            " with the value " + hibernateDialect
           );
       else
-        getLog().debug(
-            "Using the value " + hibernateDialect +
-            " from the plugin-configuration-parameter hibernateDialect!"
-          );
+        getLog().debug("Using the value " + hibernateDialect);
       properties.setProperty(DIALECT, hibernateDialect);
     }
 
@@ -507,6 +497,7 @@ public class Hbm2DdlMojo extends AbstractMojo
         !modified
         && !target.equals(Target.SCRIPT)
         && !target.equals(Target.NONE)
+        && !force
       )
     {
       getLog().info("No modified annotated classes found and dialect unchanged.");
@@ -590,7 +581,8 @@ public class Hbm2DdlMojo extends AbstractMojo
       /** Close the connection */
       try
       {
-        connection.close();
+        if (connection != null)
+          connection.close();
       }
       catch (SQLException e)
       {