1 package org.apache.torque.mojo;
2
3 import org.apache.cxf.common.util.StringUtils;
4 import org.apache.maven.plugin.MojoExecutionException;
5 import org.apache.maven.plugin.descriptor.PluginDescriptor;
6 import org.apache.torque.util.JdbcConfigurer;
7 import org.kuali.core.db.torque.DumpTask;
8 import org.kuali.core.db.torque.PropertyHandlingException;
9 import org.kuali.core.db.torque.StringFilter;
10
11
12
13
14 public abstract class ExportMojo extends AntTaskMojo {
15
16
17
18
19
20
21 private boolean antCompatibilityMode;
22
23
24
25
26
27
28
29
30 private String artifactId;
31
32
33
34
35
36
37
38
39
40 private boolean includeVersionInComment;
41
42
43
44
45
46
47
48
49 private String comment;
50
51
52
53
54
55
56 private String includes;
57
58
59
60
61
62
63 private String excludes;
64
65
66
67
68
69
70
71
72 private String targetDatabase;
73
74
75
76
77
78
79
80
81
82
83
84 private String schema;
85
86
87
88
89
90
91
92
93
94 private String driver;
95
96
97
98
99
100
101
102 private String url;
103
104
105
106
107
108
109
110
111
112
113 private String username;
114
115
116
117
118
119
120
121
122
123
124 private String password;
125
126
127
128
129 public String getDriver() {
130 return driver;
131 }
132
133
134
135
136
137
138
139 public void setDriver(final String driver) {
140 this.driver = driver;
141 }
142
143
144
145
146
147
148 public String getPassword() {
149 return password;
150 }
151
152
153
154
155
156
157
158 public void setPassword(final String password) {
159 this.password = password;
160 }
161
162
163
164
165
166
167 public String getUrl() {
168 return url;
169 }
170
171
172
173
174
175
176
177 public void setUrl(final String url) {
178 this.url = url;
179 }
180
181 public String getUsername() {
182 return username;
183 }
184
185 public void setUsername(final String username) {
186 this.username = username;
187 }
188
189 public String getSchema() {
190 return schema;
191 }
192
193 public void setSchema(final String schema) {
194 this.schema = schema;
195 }
196
197 public String getTargetDatabase() {
198 return targetDatabase;
199 }
200
201 public void setTargetDatabase(final String targetDatabase) {
202 this.targetDatabase = targetDatabase;
203 }
204
205 public String getIncludes() {
206 return includes;
207 }
208
209 public void setIncludes(final String includePatterns) {
210 this.includes = includePatterns;
211 }
212
213 public String getExcludes() {
214 return excludes;
215 }
216
217 public void setExcludes(final String excludePatterns) {
218 this.excludes = excludePatterns;
219 }
220
221 public String getComment() {
222 return comment;
223 }
224
225 public void setComment(final String comment) {
226 this.comment = comment;
227 }
228
229 protected String getUpdatedComment() {
230 PluginDescriptor descriptor = (PluginDescriptor) this.getPluginContext().get("pluginDescriptor");
231 if (descriptor == null) {
232
233 return " Auto-generated by the maven-impex-plugin " + getComment();
234 }
235 String name = descriptor.getName();
236 String version = descriptor.getVersion();
237 String comment = " Auto-generated by the " + name;
238 if (isIncludeVersionInComment()) {
239 comment += " v" + version + " ";
240 }
241 if (!StringUtils.isEmpty(getComment())) {
242 comment += getComment();
243 }
244 return comment;
245 }
246
247 @Override
248 protected void configureTask() throws MojoExecutionException {
249 setComment(getUpdatedComment());
250 try {
251 JdbcConfigurer configurer = new JdbcConfigurer();
252 configurer.updateConfiguration(this);
253 configurer.validateConfiguration(this);
254 } catch (PropertyHandlingException e) {
255 throw new MojoExecutionException("Error handling properties", e);
256 }
257 super.configureTask();
258 DumpTask task = (DumpTask) super.getAntTask();
259 task.setIncludePatterns(StringFilter.getListFromCSV(getIncludes()));
260 task.setExcludePatterns(StringFilter.getListFromCSV(getExcludes()));
261 }
262
263 public String getArtifactId() {
264 return artifactId;
265 }
266
267 public void setArtifactId(final String artifactId) {
268 this.artifactId = artifactId;
269 }
270
271 public boolean isAntCompatibilityMode() {
272 return antCompatibilityMode;
273 }
274
275 public void setAntCompatibilityMode(final boolean antCompatibilityMode) {
276 this.antCompatibilityMode = antCompatibilityMode;
277 }
278
279
280
281
282 public boolean isIncludeVersionInComment() {
283 return includeVersionInComment;
284 }
285
286
287
288
289
290 public void setIncludeVersionInComment(final boolean includeVersionInComment) {
291 this.includeVersionInComment = includeVersionInComment;
292 }
293 }