| <!-- |
| ~ 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="dao-hibernate-db-derby" default="gen-schemas" > |
| |
| <property name="descriptors.dir" value="${basedir}/src/main/descriptors" /> |
| <property name="sql.generate.dir" value="${basedir}/target" /> |
| <property name="target.dir" value="${basedir}/target" /> |
| <property name="database.dir" value="${basedir}/target/derby" /> |
| <property name="database.name" value="jpadb" /> |
| <property name="derby.target.sql" value="${target.dir}/derby.sql" /> |
| <property name="src.sql.dir" value="${basedir}/src/main/scripts" /> |
| |
| <target name="db" depends="depset, tarball" /> |
| |
| <target name="depset" > |
| <dependset> |
| <srcfileset dir="${descriptors.dir}" includes="**/*" /> |
| <targetfileset dir="${target.dir}" includes="tarball.tar" /> |
| </dependset> |
| |
| <available property="skip.tar" file="${target.dir}/tarball.tar" /> |
| <available property="skip.sql" file="${target.dir}/tarball.tar" /> |
| </target> |
| |
| <target name="tarball" unless="skip.tar" > |
| <antcall inheritRefs="true" target="dbload" /> |
| <copy todir="${database.dir}/${database.name}"> |
| <fileset dir="${target.dir}" includes="*.sql" /> |
| </copy> |
| <tar destfile="${basedir}/target/tarball.tar" |
| basedir="${database.dir}/"> |
| <include name="${database.name}/**" /> |
| </tar> |
| </target> |
| |
| <target name="dbload" > |
| <antcall inheritRefs="true" target="derby-shutdown" /> |
| <delete dir="${database.dir}"/> |
| <sql driver="org.apache.derby.jdbc.EmbeddedDriver" |
| url="jdbc:derby:${database.dir}/${database.name};create=true" |
| userid="sa" password="" src="${derby.target.sql}" |
| autocommit="true" onerror="abort" delimiter=";" |
| classpathref="maven.dependency.classpath"> |
| </sql> |
| |
| <antcall inheritRefs="true" target="derby-shutdown" /> |
| </target> |
| |
| <target name="derby-shutdown"> |
| <java classname="org.apache.derby.tools.ij" |
| append="true" |
| failonerror="true" |
| classpathref="maven.dependency.classpath" > |
| <arg value="${basedir}/shutdown.sql"/> |
| </java> |
| </target> |
| |
| <target name="gen-schemas"> |
| <mkdir dir="${target.dir}"/> |
| <java classname="org.apache.openjpa.jdbc.meta.MappingTool"> |
| <arg line="-p ${descriptors.dir}/persistence.derby.xml"/> |
| <arg line="-sa build"/> |
| <arg line="-sql ${derby.target.sql}"/> |
| <classpath> |
| <path refid="maven.dependency.classpath"/> |
| </classpath> |
| </java> |
| <concat destfile="${derby.target.sql}" append="true"> |
| <fileset file="${src.sql.dir}/quartz-derby.sql" /> |
| </concat> |
| </target> |
| |
| </project> |