Found no way to check, that mapped classes were found
[hibernate4-maven-plugin] / src / main / java / de / juplo / plugins / hibernate4 / Hbm2DdlMojo.java
index 3efa185..f1b6a2c 100644 (file)
@@ -541,8 +541,11 @@ public class Hbm2DdlMojo extends AbstractMojo
     // Clear unused system-properties
     config.setProperties(new Properties());
 
     // Clear unused system-properties
     config.setProperties(new Properties());
 
+
     ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
     ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+    StandardServiceRegistryImpl registry = null;
     MavenLogAppender.startPluginLog(this);
     MavenLogAppender.startPluginLog(this);
+
     try
     {
       /** Try to read configuration from properties-file */
     try
     {
       /** Try to read configuration from properties-file */
@@ -841,20 +844,6 @@ public class Hbm2DdlMojo extends AbstractMojo
       }
 
 
       }
 
 
-      Iterator<PersistentClass> it = config.getClassMappings();
-      if (!it.hasNext())
-      {
-        throw new MojoFailureException("No mapped classes found!");
-      }
-      else
-      {
-        getLog().info("Mapped classes:");
-        while (it.hasNext())
-        {
-          getLog().debug("  " + it.next().getClassName());
-        }
-      }
-
       if (config.getProperty(DIALECT) == null)
         throw new MojoFailureException("hibernate-dialect must be set!");
 
       if (config.getProperty(DIALECT) == null)
         throw new MojoFailureException("hibernate-dialect must be set!");
 
@@ -897,7 +886,7 @@ public class Hbm2DdlMojo extends AbstractMojo
 
       Environment.verifyProperties(config.getProperties());
       ConfigurationHelper.resolvePlaceHolders(config.getProperties());
 
       Environment.verifyProperties(config.getProperties());
       ConfigurationHelper.resolvePlaceHolders(config.getProperties());
-      StandardServiceRegistryImpl registry =
+      registry =
           (StandardServiceRegistryImpl)
           new StandardServiceRegistryBuilder()
               .applySettings(config.getProperties())
           (StandardServiceRegistryImpl)
           new StandardServiceRegistryBuilder()
               .applySettings(config.getProperties())
@@ -952,6 +941,9 @@ public class Hbm2DdlMojo extends AbstractMojo
 
       /** Restore the old class-loader (TODO: is this really necessary?) */
       Thread.currentThread().setContextClassLoader(contextClassLoader);
 
       /** Restore the old class-loader (TODO: is this really necessary?) */
       Thread.currentThread().setContextClassLoader(contextClassLoader);
+
+      if (registry != null)
+        registry.destroy();
     }
 
     /** Write md5-sums for annotated classes to file */
     }
 
     /** Write md5-sums for annotated classes to file */