forked from nloyola/biobank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-db.xml
142 lines (129 loc) · 5.17 KB
/
build-db.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?xml version="1.0" encoding="UTF-8"?>
<project name="db" basedir=".">
<property file="build.properties" />
<path id="schemaupdate.classpath">
<pathelement location="${schema.dir}/log4j.properties" />
<pathelement location="${codegen.biobank.src}" />
<fileset dir="${req.jars.dir}" >
<include name="**/*.jar" />
</fileset>
</path>
<property name="model.classpath" value="${eclipse.proj.dir.common}/output" />
<path id="sql.classpath">
<fileset dir="${lib.dir}/build">
<include name="*.jar" />
</fileset>
</path>
<path id="hibernatetool.lib">
<path location="${lib.dir}/messages.jar" />
<path location="${hibernatetool.lib.dir}/${jdbc.driver.jar}" />
<path location="${hibernatetool.lib.dir}/hibernate-envers.jar" />
<path location="${hibernatetool.lib.dir}/c3p0.jar" />
<path location="${hibernatetool.lib.dir}/commons-logging.jar" />
<path location="${hibernatetool.lib.dir}/dom4j.jar" />
<path location="${hibernatetool.lib.dir}/freemarker.jar" />
<path location="${hibernatetool.lib.dir}/gettext-commons.jar" />
<path location="${hibernatetool.lib.dir}/hibernate-jpa-2.0-api.jar" />
<path location="${hibernatetool.lib.dir}/hibernate-tools.jar" />
<path location="${hibernatetool.lib.dir}/hibernate-validator.jar" />
<path location="${hibernatetool.lib.dir}/hibernate-core.jar" />
<path location="${hibernatetool.lib.dir}/hibernate-commons-annotations.jar" />
<path location="${hibernatetool.lib.dir}/ognl.jar" />
<path location="${hibernatetool.lib.dir}/slf4j-api.jar" />
<path location="${hibernatetool.lib.dir}/slf4j-nop.jar" />
<path location="${hibernatetool.lib.dir}/validation-api.jar" />
<!-- uncomment following line for debug output -->
<!--<path location="${lib.dir}/slf4j-simple.jar" />-->
</path>
<!-- hibernatetool is much faster and more powerful than schemaexport and
works with jpa annotations -->
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.EnversHibernateToolTask"
classpathref="hibernatetool.lib"
onerror="ignore" />
<!-- was to generate java files from hbm.xml files
<target name="hbm2java">
<mkdir dir="gen" />
<hibernatetool destdir="gen" classpath="${model.classpath}">
<configuration configurationfile="${eclipse.proj.dir.common}/src/hibernate.cfg.xml"/>
<hbm2java jdk5="true" ejb3="true" />
</hibernatetool>
</target>
-->
<target name="create-db" if="db.missing">
</target>
<target name="create-db-user">
</target>
<target name="schemaupdate"
depends="check-db,build-common-project">
<tempfile property="temp.sql.path"
deleteonexit="true"
prefix="schema-export"
suffix=".sql"
createfile="true" />
<basename property="temp.sql.file" file="${temp.sql.path}" />
<hibernatetool destdir="." classpath="${model.classpath}" >
<annotationconfiguration configurationfile="${eclipse.proj.dir.common}/output/hibernate.cfg.xml"/>
<hbm2ddl export="false"
drop="false"
create="true"
outputfilename="${temp.sql.file}" />
</hibernatetool>
<sql driver="${database.driver}"
url="${database.url}"
userid="${database.exec.username}"
password="${database.exec.password}"
classpathref="sql.classpath">
<transaction src="${temp.sql.file}" />
</sql>
</target>
<target name="dbcreate-add-tables"
depends="check-db,resolve">
<sql driver="${database.driver}"
url="${database.url}"
userid="${database.exec.username}"
password="${database.exec.password}"
classpathref="sql.classpath">
DROP DATABASE IF EXISTS ${database.name};
CREATE DATABASE ${database.name};
ALTER DATABASE `${database.name}` DEFAULT CHARACTER SET latin1 COLLATE latin1_general_cs;
</sql>
<antcall target="schemaupdate" />
<sql driver="${database.driver}"
url="${database.url}"
userid="${database.exec.username}"
password="${database.exec.password}"
classpathref="sql.classpath">
<path>
<fileset dir="${db.import.dir}">
<include name="**/*.sql"/>
</fileset>
</path>
<transaction>commit;</transaction>
</sql>
</target>
<target name="dbcreate-add-testuser"
depends="check-db"
if="debug">
<sql driver="${database.driver}"
url="${database.url}"
userid="${database.exec.username}"
password="${database.exec.password}"
classpathref="sql.classpath">
<transaction src="${secu-log.dir}/addTestUser.sql" />
</sql>
</target>
<target name="dbcreate"
depends="dbcreate-add-tables,dbcreate-add-testuser"
description="creates the default tables">
</target>
<target name="dbbackup"
description="exports the current database to a file"
depends="check-db">
<echo message="running scripts/dbbackup..." />
<exec executable="scripts/dbbackup"
failonerror="true">
<arg line="${database.host} ${database.exec.username} ${database.exec.password} ${database.name}" />
</exec>
</target>
</project>