All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.torque.mojo.SchemaSqlMojo Maven / Gradle / Ivy

Go to download

Maven plugin for converting database agnostic XML files into platform specific SQL files and for examining proprietary databases via JDBC to generate database agnostic XML files

There is a newer version: 1.1.13
Show newest version
/**
 * Copyright 2004-2012 The Kuali Foundation
 *
 * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
 *
 * 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.
 */
package org.apache.torque.mojo;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.torque.util.ChangeDetector;

/**
 * Generates platform specific SQL from database agnostic XML files.
*
* There are two types of SQL files created by this goal:
*
* Type 1: DDL statements for creating tables, primary keys, indexes, and unique constraints. Does not contain DDL for * enforcing relationships between tables.
* Type 2: DDL statements for creating and enforcing relationships between tables
*
* This allows data to be imported into multiple tables concurrently. Running the first type of SQL file will create the * empty tables without any foreign key constraints. Data can then be loaded concurrently into the tables (using * optimized high speed tools if desired) without needing to worry about the order in which the tables are loaded. After * data has been loaded, the second type of SQL file can be run to add the relationships between the tables. As long as * the data set is consistent and correct, all the relationships will get created correctly.
*
* The database platform to generate SQL for is determined by ${targetDatabase}. See also impex:datasql * * @goal schemasql * @phase generate-sources */ public class SchemaSqlMojo extends SqlMojoBase { /** * The directory in which the SQL will be generated. * * @parameter property="outputDir" expression="${outputDir}" default-value="${project.build.directory}/classes/sql" */ @SuppressWarnings("unused") private String dummy1; /** * The location where the report file will be generated. * * @parameter property="reportFile" expression="${reportFile}" default-value= * "../../../reports/report.${project.artifactId}.sql.generation" */ @SuppressWarnings("unused") private String dummy2; /** * The location where the context property file for velocity will be generated. * * @parameter property="contextPropertiesPath" expression="${contextPropertiesPath}" * default-value="${project.build.directory}/reports/context.sql.properties" */ @SuppressWarnings("unused") private String dummy3; /** * The suffix of the generated sql files. * * @parameter property="suffix" expression="${suffix}" */ @SuppressWarnings("unused") private String dummy4; protected void showConfig() { getLog().info("Schema Dir: " + getSchemaDir()); getLog().info("Includes: " + getSchemaIncludes()); getLog().info("Excludes: " + getSchemaExcludes()); } /** * Generate SQL from schema XML files */ @Override public void executeMojo() throws MojoExecutionException { updateConfiguration(); validateConfiguration(); generateContextProperties(); configureTask(); addTargetDatabaseToOutputDir(); addTargetDatabaseToReportFile(); showConfig(); ChangeDetector detector = new ChangeDetector(getCanonicalReportFile(), getSchemaFiles()); if (!detector.isChanged() && isRunOnlyOnSchemaChange()) { getLog().info("Schema has not changed. Skipping generation"); return; } getLog().info("------------------------------------------------------------------------"); getLog().info("Generating SQL for " + getTargetDatabase() + " from schema XML files"); getLog().info("------------------------------------------------------------------------"); getAntTask().execute(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy