if (tasks != null && !tasks.isEmpty())
{
final Map tasksMap = (Map)SchemaMojo.tasksCache.get(this.taskType);
if (tasksMap == null)
{
throw new MojoExecutionException("'" + taskType +
"' is not a valid task type, valid task types are: " + tasksMap.keySet());
}
this.properties.putAll(this.project.getProperties());
for (final Iterator iterator = this.getTasks().iterator(); iterator.hasNext();)
{
final String task = ObjectUtils.toString(iterator.next()).trim();
if (this.propertyFiles != null)
{
final int numberOfPropertyFiles = propertyFiles.length;
for (int ctr2 = 0; ctr2 < numberOfPropertyFiles; ctr2++)
{
final URL propertyFileUri = ResourceUtils.toURL(propertyFiles[ctr2]);
if (propertyFileUri != null)
{
final InputStream stream = propertyFileUri.openStream();
this.properties.load(stream);
stream.close();
}
}
}
// - load all the fields of this class into the properties
final Field[] fields = this.getClass().getDeclaredFields();
if (fields != null)
{
final int numberOfFields = fields.length;
for (int ctr = 0; ctr < numberOfFields; ctr++)
{
final Field field = fields[ctr];
final Object value = field.get(this);
if (value != null)
{
this.properties.put(
field.getName(),
value);
}
}
}
final Set classpathElements = new LinkedHashSet(this.project.getRuntimeClasspathElements());
classpathElements.addAll(this.getProvidedClasspathElements());
this.initializeClasspathFromClassPathElements(classpathElements);
final Class type = (Class)tasksMap.get(task);
if (type == null)
{
throw new MojoExecutionException("'" + task + "' is not a valid task, valid types are: " +
tasksMap.keySet());
}
final SchemaManagement schemaManagement = (SchemaManagement)ClassUtils.newInstance(type);
connection = executeScripts ? this.getConnection() : null;
this.executeSql(
connection,
schemaManagement.execute(
connection,
this.properties));
}
}
// - execute any additional scripts
this.executeScripts(connection);
}
catch (final Throwable throwable)
{
throw new MojoExecutionException("An error occured while attempting to create the schema", throwable);
}
finally
{
if (connection != null)
{