From: Kai Moritz Date: Mon, 14 Nov 2016 18:32:34 +0000 (+0100) Subject: WIP X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=b0a9136540aab84ac78db6a9ada9d5da35074e16;p=hibernate-maven-plugin WIP --- diff --git a/src/main/java/de/juplo/plugins/hibernate/ValidateMojo.java b/src/main/java/de/juplo/plugins/hibernate/ValidateMojo.java index 49a40c36..8c8f3e75 100644 --- a/src/main/java/de/juplo/plugins/hibernate/ValidateMojo.java +++ b/src/main/java/de/juplo/plugins/hibernate/ValidateMojo.java @@ -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; } }