WIP
[hibernate4-maven-plugin] / src / main / java / de / juplo / plugins / hibernate4 / Hbm2DdlMojo.java
index b85c601..0ba4673 100644 (file)
@@ -262,36 +262,30 @@ public class Hbm2DdlMojo extends AbstractMojo
   private String hibernateMapping;
 
   /**
-   * Do not output the script to stdout.
-   *
-   * @parameter property="hibernate.export.quiet" default-value="true"
-   * @since 1.0.6
-   */
-  private boolean quiet;
-
-  /**
-   * Only drop the tables.
+   * Create drop-statements for the generated tables.
+   * At least one of {@link #drop} and {@link #create} must be set.
    *
    * @parameter property="hibernate.export.drop" default-value="true"
-   * @since 1.0.6
+   * @since 2.0
    */
   private boolean drop;
 
   /**
-   * Only create the tables.
+   * Create create-statements for the generated tables.
+   * At least one of {@link #drop} and {@link #create} must be set.
    *
    * @parameter property="hibernate.export.create" default-value="true"
-   * @since 1.0.6
+   * @since 2.0
    */
   private boolean create;
 
   /**
-   * Do not export to the database.
+   * Only create the database schema. Do not export it to the database.
    *
-   * @parameter property="hibernate.export.text" default-value="false"
-   * @since 1.0.6
+   * @parameter property="hibernate.export.export" default-value="true"
+   * @since 2.0
    */
-  private boolean text;
+  private boolean export;
 
   /**
    * Output file.
@@ -339,6 +333,11 @@ public class Hbm2DdlMojo extends AbstractMojo
       return;
     }
 
+    if (!create && !drop)
+      throw new MojoFailureException(
+          "At least one of drop and create must be set!"
+          );
+
     Map<String,String> md5s;
     boolean modified = false;
     File saved = new File(buildDirectory + File.separator + MD5S);
@@ -791,10 +790,12 @@ public class Hbm2DdlMojo extends AbstractMojo
       if (!modified)
       {
         getLog().info(
-          "No modified annotated classes or mapping-files found and dialect " +
-          "unchanged."
-          );
-        if (!force)
+            "No modified annotated classes or mapping-files found and " +
+            "dialect unchanged."
+            );
+        if (force)
+          getLog().info("Schema generation is forced!");
+        else
         {
           getLog().info("Skipping schema generation!");
           project.getProperties().setProperty(EXPORT_SKIPPED_PROPERTY, "true");
@@ -809,7 +810,7 @@ public class Hbm2DdlMojo extends AbstractMojo
          * hibernate does not use the context-classloader of the current
          * thread and, hence, would not be able to resolve the driver-class!
          */
-        if (!text && (create || drop))
+        if (export)
         {
           Class driverClass = classLoader.loadClass(properties.getProperty(DRIVER_CLASS));
           getLog().debug("Registering JDBC-driver " + driverClass.getName());
@@ -882,7 +883,7 @@ public class Hbm2DdlMojo extends AbstractMojo
       }
 
       export.setOutputFile(outF.getPath());
-      export.execute(!quiet, !text, drop, create);
+      export.execute(false, this.export, drop && !create, create && !drop);
 
       for (Object exception : export.getExceptions())
         getLog().debug(exception.toString());