/
build-hibernate.xml
148 lines (134 loc) · 6.4 KB
/
build-hibernate.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
143
144
145
146
147
148
<?xml version="1.0" encoding="gb2312"?>
<?xml-stylesheet type="text/xsl" href="./ant2html.xsl"?>
<!-- $Id: build-common.xml,v 1.4 2004/03/09 15:14:32 l_walker Exp $ -->
<!-- l_walker(walker@skyinn.org) of Skyinn Group http://www.skyinn.org -->
<!--
This file defined some base task to build and package java application:
'build' for compile source code,and
'jar' and 'war' for generate .jar and .war file
Notes:
Don't run these task immediately,please create your build.xml
in your project,then define some targetes to call these.
You can reference the file under the project which generated
by the task defind in 'build-newapp.xml' file.
-->
<project name="build-hibernate" default="usage">
<!--load properties-->
<property file="ant.properties"/>
<property file="default-build.properties"/>
<!-- ============================================== -->
<!-- Help infomation for key targets -->
<!-- ============================================== -->
<target name="usage"
description="Print Ant build file usage information">
<echo>+ ===================================================== +</echo>
<echo>+ +</echo>
<echo>+ ant usage Show this usage information. +</echo>
<echo>+ ant hibernate Generate Hibernate class descriptor files.</echo>
<echo>+ ant schema.export Export Schema to Database. +</echo>
<echo>+ ant schema.update Update Schema to Database. +</echo>
<echo>+ +</echo>
<echo>+ Notes: +</echo>
<echo>+ This build file DO NOT call immediately, +</echo>
<echo>+ Please create your build.xml in your project, +</echo>
<echo>+ Then define some targetes to call these. +</echo>
<echo>+ +</echo>
<echo>+ ===================================================== +</echo>
</target>
<!-- Path -->
<path id="project.class.path">
<pathelement path="${java.class.path}" />
<pathelement location="${app.build.classes}" />
<fileset dir="${app.lib.dir}">
<include name="**/*.jar" />
<include name="**/*.zip" />
</fileset>
</path>
<!-- ============================================== -->
<!-- Initialization -->
<!-- ============================================== -->
<target name="-init"
description="Initialize for the project.">
<tstamp />
</target>
<!-- ============================================== -->
<!-- -->
<!-- Hibernate Generating *.hbm.xml files... -->
<!-- -->
<!-- ============================================== -->
<target name="hibernate" depends="-init"
description="Generates Hibernate class descriptor files.">
<!-- Execute the hibernatedoclet task -->
<echo>+ ===================================================== +</echo>
<echo>+ +</echo>
<echo>+ Hibernatedoclet Executing +</echo>
<echo>+ Generating *.hbm.xml files... +</echo>
<echo>+ +</echo>
<echo>+ ===================================================== +</echo>
<taskdef name="hibernatedoclet"
classname="xdoclet.modules.hibernate.HibernateDocletTask">
<classpath refid="project.class.path"/>
</taskdef>
<hibernatedoclet destdir = "${app.src.hibernate}"
excludedtags = "@version,@author,@todo"
force = "true"
verbose = "true"
mergedir = "${app.src.hibernate}">
<fileset dir="${app.src.java}">
<!-- Include the hibernate object classes. -->
<include name="**/*.java" />
</fileset>
<hibernate version="2.0" />
</hibernatedoclet>
</target>
<!-- ============================================== -->
<!-- -->
<!-- Export Schema to Database -->
<!-- -->
<!-- ============================================== -->
<target name="exportschema" depends="hibernate"
description="Export schema and create database tables." >
<echo>+ ===================================================== +</echo>
<echo>+ +</echo>
<echo>+ Export Schema to Database(Execute Schema!) +</echo>
<echo>+ +</echo>
<echo>+ ===================================================== +</echo>
<taskdef name="exportschema"
classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask"
classpathref="project.class.path"/>
<exportschema
properties = "${app.conf.hibernate}/hibernate.properties"
quiet = "no"
text = "no"
drop = "no"
delimiter = ";"
output = "${app.conf.db}/schema.sql">
<fileset dir="${app.src.hibernate}">
<include name="**/*.hbm.xml"/>
</fileset>
</exportschema>
</target>
<!-- ============================================== -->
<!-- -->
<!-- Update Schema to Database -->
<!-- -->
<!-- ============================================== -->
<target name="updateschema" depends="hibernate"
description="Update schema and database tables.">
<echo>+ ===================================================== +</echo>
<echo>+ +</echo>
<echo>+ Update Schema to Database(Execute Schema!) +</echo>
<echo>+ +</echo>
<echo>+ ===================================================== +</echo>
<taskdef name="updateschema"
classname="net.sf.hibernate.tool.hbm2ddl.SchemaUpdateTask"
classpathref="project.class.path"/>
<updateschema
properties="${app.conf.hibernate}/hibernate.properties"
quiet="no">
<fileset dir="${app.src.hibernate}">
<include name="**/*.hbm.xml"/>
</fileset>
</updateschema>
</target>
</project>