X-Git-Url: https://juplo.de/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fde%2Fjuplo%2Fplugins%2Fhibernate%2FUpdateMojo.java;h=a97982ebc76d19e35e9f7a1adf61dfe715bb138e;hb=bec99c73fea6edf073dcf885ef07defee1ed8608;hp=09b74a3ea626a9e904e79b92e217ba8eeb32cf24;hpb=4ab00d5dbf8f4263d867726607ce84d4107ef1c6;p=hibernate4-maven-plugin diff --git a/src/main/java/de/juplo/plugins/hibernate/UpdateMojo.java b/src/main/java/de/juplo/plugins/hibernate/UpdateMojo.java index 09b74a3e..a97982eb 100644 --- a/src/main/java/de/juplo/plugins/hibernate/UpdateMojo.java +++ b/src/main/java/de/juplo/plugins/hibernate/UpdateMojo.java @@ -16,8 +16,9 @@ package de.juplo.plugins.hibernate; * limitations under the License. */ +import java.io.File; +import java.security.NoSuchAlgorithmException; import java.util.EnumSet; -import java.util.HashMap; import java.util.Map; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -65,22 +66,31 @@ public class UpdateMojo extends AbstractSchemaMojo MojoFailureException, MojoExecutionException { - super.execute(outputFile); + try + { + super.execute(new MD5ModificationTracker(buildDirectory, outputFile, getLog())); + } + catch (NoSuchAlgorithmException e) + { + throw new MojoFailureException("Digest-Algorithm MD5 is missing!", e); + } } @Override - ExceptionHandlerCollectingImpl build(MetadataImplementor metadata) + ExceptionHandlerCollectingImpl build(final MetadataImplementor metadata) throws MojoExecutionException, MojoFailureException { - final ServiceRegistry service = + final ServiceRegistry registry = metadata.getMetadataBuildingOptions().getServiceRegistry(); - SchemaManagementTool tool = service.getService(SchemaManagementTool.class); + final Map settings = + registry.getService(ConfigurationService.class).getSettings(); + SchemaManagementTool tool = registry.getService(SchemaManagementTool.class); final EnumSet targetTypes = EnumSet.of(TargetType.SCRIPT); - if (execute) + if ((Boolean)settings.get(EXECUTE)) targetTypes.add(TargetType.DATABASE); TargetDescriptor target = new TargetDescriptor() @@ -94,25 +104,27 @@ public class UpdateMojo extends AbstractSchemaMojo @Override public ScriptTargetOutput getScriptTargetOutput() { - String charset - = (String) service - .getService(ConfigurationService.class) - .getSettings() - .get(AvailableSettings.HBM2DDL_CHARSET_NAME); - return new ScriptTargetOutputToFile(output, charset); + String charset = + (String)settings.get(AvailableSettings.HBM2DDL_CHARSET_NAME); + return new ScriptTargetOutputToFile(new File(outputFile), charset); } }; + ExceptionHandlerCollectingImpl handler = + new ExceptionHandlerCollectingImpl(); + ExecutionOptions options = SchemaManagementToolCoordinator.buildExecutionOptions( - service + registry .getService(ConfigurationService.class) .getSettings(), - new ExceptionHandlerCollectingImpl() + handler ); Map config = options.getConfigurationValues(); tool.getSchemaMigrator(config).doMigration(metadata, options, target); + + return handler; } }