svn commit: r615709 - /db/ojb/branches/OJB_1_0_RELEASE/build-ddlutils.xml

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r615709 - /db/ojb/branches/OJB_1_0_RELEASE/build-ddlutils.xml

Armin Waibel
Author: arminw
Date: Sun Jan 27 18:12:46 2008
New Revision: 615709

URL: http://svn.apache.org/viewvc?rev=615709&view=rev
Log:
DdlUtil ant tasks

Added:
    db/ojb/branches/OJB_1_0_RELEASE/build-ddlutils.xml

Added: db/ojb/branches/OJB_1_0_RELEASE/build-ddlutils.xml
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/build-ddlutils.xml?rev=615709&view=auto
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/build-ddlutils.xml (added)
+++ db/ojb/branches/OJB_1_0_RELEASE/build-ddlutils.xml Sun Jan 27 18:12:46 2008
@@ -0,0 +1,139 @@
+<?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 name="DDLUtils OJB tasks" default="create-db" basedir=".">
+    <description>
+        DDLUtils ant task file
+    </description>
+
+    <!-- Allow any user specific values to override the defaults -->
+ <property environment="env"/>
+ <property file="${user.home}/build.properties" />
+    <property file="${basedir}/build.properties"/>
+
+    <property name="ojb.properties.file" value="${basedir}"/>
+    <property name="lib.dir" value=""/>
+    <property name="target.dir" value="${basedir}/ojb"/>
+    <property name="schema.src.dir" value="${basedir}"/>
+    <property name="schema.target.dir" value="${basedir}"/>
+    <property name="project.name" value=""/>
+    <property name="database.driver" value=""/>
+    <property name="database.url" value=""/>
+    <property name="database.user" value=""/>
+    <property name="database.password" value=""/>
+    <!-- If the database profile didn't specify that the database needs a shutdown, we won't do so -->
+    <property name="ddlutils.shutdownDatabase" value="false"/>
+
+    <path id="runtime-classpath">
+        <fileset dir="${lib.dir}">
+            <include name="**/*.jar"/>
+            <include name="**/*.zip"/>
+        </fileset>
+    </path>
+
+    <!-- ============================================================================= -->
+    <!-- create database tables based on xml files named '...schema.xml'               -->
+    <!-- ============================================================================= -->
+    <target name="setup-tables"
+            description="setup the DB tables"
+            depends="copy-xml">
+
+        <taskdef name="ddlToDatabase"
+                 classname="org.apache.ddlutils.task.DdlToDatabaseTask"
+                 classpathref="runtime-classpath"/>
+
+        <ddlToDatabase usedelimitedsqlidentifiers="false"
+                      shutdowndatabase="${ddlutils.shutdownDatabase}">
+            <database driverclassname="${database.driver}"
+                      url="${database.url}"
+                      username="${database.user}"
+                      password="${database.password}"/>
+            <fileset dir="${target.dir}"
+                     includes="*schema.xml"/>
+
+            <createdatabase failonerror="false"/>
+            <writeschemasqltofile alterdatabase="false" outputfile="${target.dir}/ojbtest-schema.sql"/>
+            <writeschematodatabase alterdatabase="false"/>
+
+        </ddlToDatabase>
+    </target>
+
+    <!-- ============================================================================= -->
+    <!-- insert the test data based on torque/ddlutils data xml files                  -->
+    <!-- ============================================================================= -->
+    <target name="insert-data"
+            description="insert xml based data to DB"
+            depends="copy-xml">
+
+        <taskdef name="dataToDatabase"
+             classname="org.apache.ojb.broker.ant.RepositoryDataTask"
+             classpathref="runtime-classpath"/>
+
+        <dataToDatabase  usedelimitedsqlidentifiers="false"
+                 shutdowndatabase="${ddlutils.shutdownDatabase}"
+                 ojbpropertiesfile="${ojb.properties.file}" >
+            <database driverclassname="${database.driver}"
+                      url="${database.url}"
+                      username="${database.user}"
+                      password="${database.password}"/>
+            <fileset dir="${target.dir}"
+                     includes="*schema.xml"/>
+            <writedatatodatabase datafile="${target.dir}/ojbtest-data-new.xml"/>
+        </dataToDatabase>
+    </target>
+
+    <target name="copy-xml"
+            description="copy the xml (sql schema, data) files to target dir"
+            depends="">
+        <mkdir dir="${schema.target.dir}"/>
+        <copy todir="${schema.target.dir}">
+            <fileset dir="${schema.src.dir}" includes="*.xml,*.dtd"/>
+            <filterset>
+                <filter token="DATABASE_DEFAULT" value="${project.name}" />
+            </filterset>
+        </copy>
+    </target>
+
+    <!-- ================================================================== -->
+    <!-- create and prepare the database using DdlUtils                     -->
+    <!-- ================================================================== -->
+    <target name="create-db"
+            description="create and prepare the database"
+            depends="">
+
+        <echo message="Used Database properties:"/>
+        <echo message=" --> project.name: ${project.name}"/>
+        <echo message=" --> database.driver: ${database.driver}"/>
+        <echo message=" --> database.url: ${database.url}"/>
+        <echo message=" --> database.user: ${database.user}"/>
+        <echo message=" --> ddlutils.shutdownDatabase: ${ddlutils.shutdownDatabase}"/>
+
+        <antcall target="setup-tables" inheritrefs="true">
+            <reference refid="runtime-classpath"/>
+        </antcall>
+        <antcall target="insert-data" inheritrefs="true">
+            <reference refid="runtime-classpath"/>
+        </antcall>
+
+    </target>
+</project>
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]