WIP
authorKai Moritz <kai@juplo.de>
Mon, 14 Nov 2016 18:32:34 +0000 (19:32 +0100)
committerKai Moritz <kai@juplo.de>
Mon, 14 Nov 2016 18:32:34 +0000 (19:32 +0100)
src/main/java/de/juplo/plugins/hibernate/ValidateMojo.java

index 49a40c3..8c8f3e7 100644 (file)
@@ -16,13 +16,17 @@ package de.juplo.plugins.hibernate;
  * limitations under the License.
  */
 
+import java.io.File;
 import java.util.Map;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.hibernate.boot.spi.MetadataImplementor;
+import org.hibernate.engine.config.spi.ConfigurationService;
 import org.hibernate.service.ServiceRegistry;
 import org.hibernate.tool.schema.internal.ExceptionHandlerCollectingImpl;
+import org.hibernate.tool.schema.spi.ExecutionOptions;
 import org.hibernate.tool.schema.spi.SchemaManagementTool;
+import org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator;
 
 
 /**
@@ -46,17 +50,32 @@ public class ValidateMojo extends AbstractSchemaMojo
 
 
   @Override
-  ExceptionHandlerCollectingImpl build(MetadataImplementor metadata)
+  ExceptionHandlerCollectingImpl build(
+      MetadataImplementor metadata,
+      File output
+      )
       throws
         MojoExecutionException,
         MojoFailureException
   {
-    ServiceRegistry service =
+    ServiceRegistry registry =
         metadata.getMetadataBuildingOptions().getServiceRegistry();
-    SchemaManagementTool tool = service.getService(SchemaManagementTool.class);
+    SchemaManagementTool tool = registry.getService(SchemaManagementTool.class);
 
+    ExceptionHandlerCollectingImpl handler =
+        new ExceptionHandlerCollectingImpl();
+
+    ExecutionOptions options =
+        SchemaManagementToolCoordinator.buildExecutionOptions(
+            registry
+                .getService(ConfigurationService.class)
+                .getSettings(),
+            handler
+            );
     Map config = options.getConfigurationValues();
 
-    tool.getSchemaMigrator(config).doMigration(metadata, options, target);
+    tool.getSchemaValidator(config).doValidation(metadata, options);
+
+    return handler;
   }
 }