WIP 2.0
authorKai Moritz <kai@juplo.de>
Sat, 2 May 2015 20:26:32 +0000 (22:26 +0200)
committerKai Moritz <kai@juplo.de>
Sat, 2 May 2015 20:26:32 +0000 (22:26 +0200)
src/it/dependency test/h4mp/pom.xml
src/it/hib-test/pom.xml
src/it/hibernate4-maven-plugin-envers-sample/pom.xml
src/it/ignored-dependency/main/pom.xml
src/it/properties/pom.xml
src/it/schemaexport-example/schemaexport-example-persistence-impl/pom.xml
src/main/java/de/juplo/plugins/hibernate4/Hbm2DdlMojo.java

index 4e179d2..a02802d 100644 (file)
                                        </execution>
                                </executions>
                                <configuration>
-                                       <target>NONE</target>
+                                       <export>false</export>
                                        <envers>true</envers>
                                        <format>true</format>
                                        <delimiter>;</delimiter>
                                        <force>true</force>
-                                       <type>CREATE</type>
+                                       <drop>false</drop>
                                        <hibernateDialect>org.hibernate.dialect.PostgreSQL9Dialect</hibernateDialect>
                                </configuration>
                        </plugin>
index fe46e32..5b34a02 100644 (file)
         <artifactId>hibernate4-maven-plugin</artifactId>
         <version>@project.version@</version>
         <configuration>
-          <!-- Target of none generates schema only, no DB connection -->
-          <target>none</target>
-          <!-- Generate both CREATE and DROP statements in scripts -->
-          <type>both</type>
+          <!-- Generat schema only, no DB connection needed -->
+          <export>false</export>
         </configuration>
         <executions>
           <execution>
index 3ca641d..2eda723 100644 (file)
@@ -82,8 +82,8 @@
                         <configuration>
                             <outputFile>${project.build.sourceDirectory}/../scripts/sql/create-tables-hsqldb.sql
                             </outputFile>
-                            <target>SCRIPT</target>
-                            <type>CREATE</type>
+                            <export>false</export>
+                            <drop>false</drop>
                         </configuration>
                         <dependencies>
                             <dependency>
index d198fc9..ce06ae0 100644 (file)
@@ -40,9 +40,9 @@
           </execution>
         </executions>
         <configuration>
-          <target>NONE</target>
+          <export>false</export>
           <format>true</format>
-          <type>CREATE</type>
+          <drop>false</drop>
           <hibernateDialect>org.hibernate.dialect.PostgreSQL9Dialect</hibernateDialect>
           <scanDependencies>none</scanDependencies>
         </configuration>
index f3a6fc7..a4d4e9f 100644 (file)
         <artifactId>hibernate4-maven-plugin</artifactId>
         <version>@project.version@</version>
         <configuration>
-          <!-- Target of none generates schema only, no DB connection -->
-          <target>none</target>
-          <!-- Generate both CREATE and DROP statements in scripts -->
-          <type>both</type>
+          <!-- Gnerate schema only, no DB connection needed -->
+          <export>false</export>
         </configuration>
         <executions>
           <execution>
index e7c7419..f5e467d 100644 (file)
@@ -56,7 +56,7 @@
                                <artifactId>hibernate4-maven-plugin</artifactId>\r
                                <version>@project.version@</version>\r
                                <configuration>\r
-                                       <target>SCRIPT</target>\r
+                                       <export>false</export>\r
                                        <driverClassName>org.hsqldb.jdbcDriver</driverClassName>\r
                                        <hibernateDialect>org.hibernate.dialect.HSQLDialect</hibernateDialect>\r
                                        <!-- \r
@@ -74,4 +74,4 @@
                        </plugin>\r
                </plugins>\r
        </build>\r
-</project>
\ No newline at end of file
+</project>\r
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());