X-Git-Url: http://juplo.de/gitweb/?p=hibernate4-maven-plugin;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fde%2Fjuplo%2Fplugins%2Fhibernate%2FValidateMojo.java;fp=src%2Fmain%2Fjava%2Fde%2Fjuplo%2Fplugins%2Fhibernate%2FValidateMojo.java;h=ed31fdd9c61e7f128503f50c145e6e3ab6286f6c;hp=0000000000000000000000000000000000000000;hb=4ab00d5dbf8f4263d867726607ce84d4107ef1c6;hpb=653ab8054c9232471c3c1192d5074010f378a067 diff --git a/src/main/java/de/juplo/plugins/hibernate/ValidateMojo.java b/src/main/java/de/juplo/plugins/hibernate/ValidateMojo.java new file mode 100644 index 00000000..ed31fdd9 --- /dev/null +++ b/src/main/java/de/juplo/plugins/hibernate/ValidateMojo.java @@ -0,0 +1,64 @@ +package de.juplo.plugins.hibernate; + +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +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.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.TargetDescriptor; + + +/** + * Validate a database-schema against the configured mappings. + * + * @goal validate + * @phase process-classes + * @threadSafe + * @requiresDependencyResolution runtime + */ +public class ValidateMojo extends AbstractSchemaMojo +{ + @Override + public final void execute() + throws + MojoFailureException, + MojoExecutionException + { + super.execute(null); + } + + + @Override + ExceptionHandlerCollectingImpl build(MetadataImplementor metadata) + throws + MojoExecutionException, + MojoFailureException + { + ServiceRegistry service = + metadata.getMetadataBuildingOptions().getServiceRegistry(); + SchemaManagementTool tool = service.getService(SchemaManagementTool.class); + + Map config = options.getConfigurationValues(); + + tool.getSchemaMigrator(config).doMigration(metadata, options, target); + } +}