1 package de.juplo.plugins.hibernate;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import java.util.Map;
20 import org.apache.maven.plugin.MojoExecutionException;
21 import org.apache.maven.plugin.MojoFailureException;
22 import org.hibernate.boot.spi.MetadataImplementor;
23 import org.hibernate.service.ServiceRegistry;
24 import org.hibernate.tool.schema.spi.ExecutionOptions;
25 import org.hibernate.tool.schema.spi.SchemaManagementTool;
26 import org.hibernate.tool.schema.spi.TargetDescriptor;
27
28
29
30
31
32
33
34
35
36
37
38 public class UpdateMojo extends AbstractSchemaMojo
39 {
40
41
42
43
44
45
46
47
48
49
50 private String outputFile;
51
52
53 @Override
54 public final void execute()
55 throws
56 MojoFailureException,
57 MojoExecutionException
58 {
59 super.execute(outputFile);
60 }
61
62
63 @Override
64 void build(
65 MetadataImplementor metadata,
66 ExecutionOptions options,
67 TargetDescriptor target
68 )
69 throws
70 MojoExecutionException,
71 MojoFailureException
72 {
73 ServiceRegistry service =
74 metadata.getMetadataBuildingOptions().getServiceRegistry();
75 SchemaManagementTool tool = service.getService(SchemaManagementTool.class);
76
77 Map config = options.getConfigurationValues();
78
79 tool.getSchemaMigrator(config).doMigration(metadata, options, target);
80 }
81 }