blob: bd70406baa3b80bad82fcfa104083bf3775e06d5 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache 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.apache.org/licenses/LICENSE-2.0
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.
-->
<project default="writeSchemaSqlToFile"
name="DdlUtils"
basedir=".">
<!-- Allow values set at the commandline or in the environment to override the defaults -->
<property environment="env"/>
<!-- Load the jdbc properties as specified by the jdbc.properties.file variable-->
<property file="${jdbc.properties.file}"/>
<!-- Load the build properties -->
<property file="build.properties"/>
<!-- These properties can be overriden on the commandline using -D -->
<property name="schemafiles" value="testmodel.xml"/>
<property name="schemafile" value="testmodel.xml"/>
<property name="datafile" value="testdata.xml"/>
<property name="catalogpattern" value=""/>
<property name="schemapattern" value=""/>
<property name="sqloutputfile" value="schema.sql"/>
<property name="platform" value=""/>
<property name="alterdatabase" value="true"/>
<property name="delimitedsqlidentifiers" value="false"/>
<property name="verbosity" value="info"/>
<property name="useexplicitidentityvalues" value="false"/>
<!-- The classpath used for running the tasks -->
<path id="project-classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
<include name="**/*.zip"/>
</fileset>
<pathelement path="${build.java.dir}"/>
</path>
<taskdef classname="org.apache.ddlutils.task.DdlToDatabaseTask"
name="ddlToDatabase"
classpathref="project-classpath"/>
<taskdef classname="org.apache.ddlutils.task.DatabaseToDdlTask"
name="databaseToDdl"
classpathref="project-classpath"/>
<target name="createDb">
<ddlToDatabase usedelimitedsqlidentifiers="${delimitedsqlidentifiers}"
catalogpattern="${catalogpattern}"
schemapattern="${schemapattern}"
databasetype="${platform}"
verbosity="${verbosity}">
<database driverclassname="${datasource.driverClassName}"
url="${datasource.url}"
username="${datasource.username}"
password="${datasource.password}"/>
<createdatabase failonerror="false"/>
</ddlToDatabase>
</target>
<target name="writeSchemaToDb">
<ddlToDatabase validatexml="false"
usedelimitedsqlidentifiers="${delimitedsqlidentifiers}"
catalogpattern="${catalogpattern}"
schemapattern="${schemapattern}"
databasetype="${platform}"
verbosity="${verbosity}">
<database driverclassname="${datasource.driverClassName}"
url="${datasource.url}"
username="${datasource.username}"
password="${datasource.password}"/>
<fileset dir=".">
<include name="${schemafiles}"/>
</fileset>
<writeschematodatabase alterdatabase="${alterdatabase}"
dodrops="true"
failonerror="false"/>
</ddlToDatabase>
</target>
<target name="readSchemaFromDb">
<databaseToDdl usedelimitedsqlidentifiers="${delimitedsqlidentifiers}"
catalogpattern="${catalogpattern}"
schemapattern="${schemapattern}"
databasetype="${platform}"
verbosity="${verbosity}">
<database driverclassname="${datasource.driverClassName}"
url="${datasource.url}"
username="${datasource.username}"
password="${datasource.password}"/>
<writeschematofile outputfile="${schemafile}"/>
</databaseToDdl>
</target>
<target name="writeSchemaSqlToFile">
<ddlToDatabase validatexml="false"
usedelimitedsqlidentifiers="${delimitedsqlidentifiers}"
catalogpattern="${catalogpattern}"
schemapattern="${schemapattern}"
databasetype="${platform}"
verbosity="${verbosity}">
<database driverclassname="${datasource.driverClassName}"
url="${datasource.url}"
username="${datasource.username}"
password="${datasource.password}"/>
<fileset dir=".">
<include name="${schemafiles}"/>
</fileset>
<writeschemasqltofile alterdatabase="${alterdatabase}"
dodrops="true"
failonerror="false"
outputfile="${sqloutputfile}"/>
</ddlToDatabase>
</target>
<target name="writeDataToDb">
<ddlToDatabase validatexml="false"
usedelimitedsqlidentifiers="${delimitedsqlidentifiers}"
catalogpattern="${catalogpattern}"
schemapattern="${schemapattern}"
databasetype="${platform}"
verbosity="${verbosity}">
<database driverclassname="${datasource.driverClassName}"
url="${datasource.url}"
username="${datasource.username}"
password="${datasource.password}"/>
<fileset dir=".">
<include name="${schemafiles}"/>
</fileset>
<writedatatodatabase datafile="${datafile}"
usebatchmode="false"
useexplicitidentityvalues="${useexplicitidentityvalues}"/>
</ddlToDatabase>
</target>
<target name="readDataFromDb">
<databaseToDdl usedelimitedsqlidentifiers="${delimitedsqlidentifiers}"
catalogpattern="${catalogpattern}"
schemapattern="${schemapattern}"
databasetype="${platform}"
verbosity="${verbosity}">
<database driverclassname="${datasource.driverClassName}"
url="${datasource.url}"
username="${datasource.username}"
password="${datasource.password}"/>
<writedatatofile outputfile="${datafile}"/>
</databaseToDdl>
</target>
</project>