-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.xml
More file actions
363 lines (307 loc) · 14 KB
/
build.xml
File metadata and controls
363 lines (307 loc) · 14 KB
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
<!-- $Id: build.xml,v 1.26 2007/09/10 13:51:20 kameleono Exp $ -->
<project name="acme" default="all" basedir=".">
<!-- ______________________________________________________ -->
<!-- -->
<!-- PROPERTIES -->
<!-- ______________________________________________________ -->
<!-- your environment properties are imported here and available -->
<property environment="env"/>
<!-- FOLDERS -->
<property name="build" value="${basedir}/build"/>
<property name="src" value="${basedir}/src"/>
<property name="lib" value="${basedir}/lib"/>
<property name="config" value="${basedir}/src/config"/>
<!-- WHERE WILL BE GENERATED THE CODE -->
<property name="generated-src" value="${basedir}/src/java/org/acme/sample/"/>
<property name="project-name" value="sql2java"/>
<property name="sql2java-config" value="${config}/${project-name}.properties"/>
<property file="${sql2java-config}"/>
<!-- TOMCAT -->
<property name="tomcat.host" value="localhost"/>
<property name="tomcat.port" value="8080"/>
<property name="tomcat.login" value="admin"/>
<property name="tomcat.password" value=""/>
<property name="tomcat.admin.url" value="http://localhost:8080/manager"/>
<path id="lib">
<pathelement location="${build}/classes"/>
<fileset dir="${lib}">
<include name="*.jar"/>
</fileset>
<!--
<fileset dir="${lib}/hibernate">
<include name="*.jar"/>
</fileset>
-->
<fileset dir="${lib}/jdom">
<include name="*.jar"/>
</fileset>
</path>
<!-- ______________________________________________________ -->
<!-- -->
<!-- SPECIFY PLUGINS -->
<!-- ______________________________________________________ -->
<!-- TOMCAT DEPLOYMENT CONFIG -->
<taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask" classpathref="lib"/>
<taskdef name="install" classname="org.apache.catalina.ant.InstallTask" classpathref="lib"/>
<taskdef name="remove" classname="org.apache.catalina.ant.RemoveTask" classpathref="lib"/>
<!-- SQL2JAVA CONFIG -->
<taskdef name="sql2java" classname="net.sourceforge.sql2java.ant.GenerationTask" classpathref="lib"/>
<taskdef name="sql2java-utils" classname="net.sourceforge.sql2java.ant.UtilsGenerationTask" classpathref="lib"/>
<taskdef name="sql2java-table" classname="net.sourceforge.sql2java.ant.TableGenerationTask" classpathref="lib"/>
<taskdef name="sql2java-check" classname="net.sourceforge.sql2java.ant.SchemaCheckTask" classpathref="lib"/>
<!-- ______________________________________________________ -->
<!-- -->
<!-- TOOLS TARGETS -->
<!-- ______________________________________________________ -->
<target name="prepare">
<mkdir dir="${build}"/>
<mkdir dir="${build}/classes"/>
<mkdir dir="${build}/javadoc"/>
<copy todir="${build}/classes/" overwrite="true">
<fileset dir="${src}/java" includes="**/*.properties"/>
<fileset dir="${src}/java" includes="**/*.xml"/>
</copy>
</target>
<!-- CLEAN ALL -->
<target name="clean">
<delete includeEmptyDirs="true" dir="${build}"/>
<!-- delete generated code -->
<delete includeEmptyDirs="true" dir="${generated-src}"/>
</target>
<!-- REBUILD -->
<target name="rebuild" depends="clean, generate, compile"/>
<!-- RUN THE SAMPLE USING THE GENERATED API TO ACCESS YOUR DB -->
<target name="all" depends="generate, compile, run"/>
<!-- ARE YOU SURE N-->
<target name="are.you.sure">
<input message="Are you sure you want to execute this target ? (Yes/No) " addproperty="are.you.sure"/>
<!-- check tag -->
<condition property="do.abort">
<not>
<istrue value="${are.you.sure}"/>
</not>
</condition>
<fail if="do.abort">
Aborting
</fail>
</target>
<!-- ______________________________________________________ -->
<!-- -->
<!-- DATABASE TARGETS -->
<!-- ______________________________________________________ -->
<target name="hsql.server">
<mkdir dir="${basedir}/hsql"/>
<echo message="Launching hypersonic SQL server"/>
<java classname="org.hsqldb.Server" fork="true" classpathref="lib">
<arg value="-url"/>
<arg value="${jdbc.url}"/>
<arg value="-driver"/>
<arg value="${jdbc.driver}"/>
<arg value="-database"/>
<arg value="${basedir}/hsql/${project-name}"/>
</java>
</target>
<!-- CREATE SCHEMA -->
<target name="database.create">
<sql driver="${jdbc.driver}"
url="${jdbc.url}"
userid="${jdbc.username}"
password="${jdbc.password}"
src="${src}/sql/${jdbc.type}/jpetstore-${jdbc.type}-schema.sql"
classpathref="lib">
</sql>
</target>
<!-- INIT DATA -->
<target name="database.init">
<sql driver="${jdbc.driver}"
url="${jdbc.url}"
userid="${jdbc.username}"
password="${jdbc.password}"
src="${src}/sql/${jdbc.type}/jpetstore-${jdbc.type}-dataload.sql"
classpathref="lib">
</sql>
</target>
<!-- RECREATE SCHEMA -->
<target name="database.recreate" depends="are.you.sure, database.create, database.init"/>
<!-- HSQL GRAPHICAL MANAGER -->
<target name="database.manager">
<echo message="Please launch server (ant hsql.server)"/>
<java classname="org.hsqldb.util.DatabaseManager" fork="true" classpathref="lib">
<arg value="-url"/>
<arg value="${jdbc.url}"/>
<arg value="-driver"/>
<arg value="${jdbc.driver}"/>
</java>
</target>
<!-- ______________________________________________________ -->
<!-- -->
<!-- GENERATION -->
<!-- ______________________________________________________ -->
<!-- CHECK IF A GENERATED FILE IS OLDER THAN SQL FILE OR THE TEMPLATES SQL2JAVA -->
<target name="generate.check">
<uptodate property="doNotGenerate"
targetfile="${build}/classes/org/acme/sample/users/SignonBean.class">
<srcfiles dir="${src}/sql/${jdbc.type}/" includes="**/*.sql"/>
<srcfiles dir="${src}/templates/velocity/" includes="**/*.vm"/>
<srcfiles dir="${lib}/" includes="sql2java.jar"/>
</uptodate>
</target>
<!-- GENERATE THE SOURCE CODE API TO ACCESS YOUR DB -->
<target name="generate.code" depends="generate.check" unless="doNotGenerate">
<!-- launch generation -->
<sql2java propertyFile="${sql2java-config}"/>
</target>
<target name="generate.graphs.check">
<available classname="${src}/web/database/graphviz/build.xml" property="hasGraphs"></available>
</target>
<target name="generate.graphs" depends="generate.graphs.check" if="hasGraphs">
<!-- generate graphs -->
<ant dir="${src}/web/database/graphviz"/>
</target>
<target name="generate" depends="generate.code, generate.graphs">
</target>
<!-- GENERATE SPECIFIC TABLES -->
<target name="generate-table" depends="generate.check" unless="doNotGenerate">
<input message="Please enter the tables you want to generate" addproperty="tables"/>
<!-- launch generation -->
<sql2java-table propertyFile="${sql2java-config}" tables="${tables}"/>
</target>
<!-- GENERATE NON RELATION TABLES FILES -->
<target name="generate-utils" depends="generate.check" unless="doNotGenerate">
<!-- launch generation -->
<sql2java-utils propertyFile="${sql2java-config}"/>
</target>
<!-- CHECK THE DATABASE STRUCTURE ACCORDING TO SQL2JAVA CONSTRAINTS -->
<target name="check-schema" depends="generate.check">
<!-- launch generation -->
<sql2java-check propertyFile="${sql2java-config}"/>
</target>
<!-- ______________________________________________________ -->
<!-- -->
<!-- COMPILATION -->
<!-- ______________________________________________________ -->
<!-- COMPILE THE SOURCE CODE API TO ACCESS YOUR DB -->
<target name="compile" depends="prepare">
<javac fork="yes"
destdir="${build}/classes"
srcdir="${src}/java"
memoryInitialSize="64M"
memoryMaximumSize="512M">
<classpath refid="lib" />
</javac>
</target>
<!-- GENERATE JAVADOC FOR THE GENERATED API -->
<target name="javadoc">
<javadoc packagenames="*"
destdir="build/javadoc"
sourcepath="${src}/java"
author="true"
version="true"
use="true"
link="http://java.sun.com/j2se/1.4.2/docs/api"
maxmemory="512M"
windowtitle="Documentation API">
<classpath refid="lib" />
<bottom><![CDATA[<i><a href="http://www.sourceforge.net/projects/sql2java" target="new">http://www.sourceforge.net/projects/sql2java</a></i>]]></bottom>
</javadoc>
</target>
<!-- RUN THE SAMPLE USING THE GENERATED API TO ACCESS YOUR DB -->
<target name="run" depends="compile">
<property file="sql2java.properties"/>
<java classname ="org.acme.Main" fork="true">
<classpath refid="lib" />
<arg value="${jdbc.driver}"/>
<arg value="${jdbc.url}"/>
<arg value="${jdbc.username}"/>
<arg value="${jdbc.password}"/>
</java>
</target>
<!-- ______________________________________________________ -->
<!-- -->
<!-- WEBAPP -->
<!-- ______________________________________________________ -->
<target name="war" depends="compile, prepare">
<!-- add build time -->
<tstamp>
<format property="build.time" pattern="MM/dd/yyyy HH:MM" offset="1" unit="hour"/>
</tstamp>
<echo file="build_info.txt">Build done on ${build.time} by ${env.USERNAME}</echo>
<war
destfile="${build}/sample.war"
webxml = "${src}/web/WEB-INF/web.xml"
excludes= "WEB-INF/web.xml">
<!-- <fileset file="build_info.txt"/> -->
<!-- include web source in / -->
<fileset dir="${src}/web/">
<exclude name="**/web.xml"/>
</fileset>
<!-- include libs in WEB-INF/lib -->
<lib dir="${lib}">
<exclude name="**/servlet.jar"/>
<exclude name="**/velocity*"/>
</lib>
<!-- include compiled classed in WEB-INF/classes -->
<classes dir="${build}/classes"/>
<classes dir="${src}/java">
<include name="**/*.properties"/>
</classes>
</war>
<delete file="build_info.txt" failonerror="false"/>
</target>
<!-- ______________________________________________________ -->
<!-- -->
<!-- TOMCAT DEPLOYMENT -->
<!-- ______________________________________________________ -->
<!-- TOMCAT DEPLOY -->
<target name="deploy" depends="war">
<echo message="Deploying sample on Tomcat."/>
<install url="${tomcat.admin.url}" username="${tomcat.login}" password="${tomcat.password}"
path="/sample" war="file://${build}/sample.war"/>
<echo message="Tomcat sample deployed."/>
</target>
<!-- TOMCAT UNDEPLOY -->
<target name="undeploy">
<echo message="Undeploying sample from Tomcat."/>
<remove url="${tomcat.admin.url}" username="${tomcat.login}" password="${tomcat.password}"
path="/sample"/>
<echo message="Tomcat sample undeployed."/>
</target>
<!-- REDEPLOY -->
<target name="redeploy" depends="undeploy, deploy">
<echo message="Tomcat sample reployment."/>
</target>
<!-- ______________________________________________________ -->
<!-- -->
<!-- HELP TARGET -->
<!-- ______________________________________________________ -->
<target name="help">
<echo>
___Main_____________________________
all : generate the code, compile it, then run it
help : this message
javadoc : create the javadoc
rebuild : clean, then recompile the project
run : execute the Main example
___Database_________________________
database.create : create the database schema using src/sql/[database]/jpetstore-[database]-schema.sql
database.init : load in the database data using src/sql/[database]/jpetstore-[database]-dataload.sql
database.manager : run an external application for a visual interaction with the database
database.recreate : create the database schema and load the database data
hsql.server : run the hypersonic sql server
___Generation_______________________
check-schema : check the schema for sql2java hints/recommandations
generate : generate using sql2java
generate-table : generate using sql2java a set of tables
generate-utils : generate using sql2java a set of utils
___Compilation______________________
clean : remove all files generated by sql2java and classes
compile : compile java files
___Webapp___________________________
war : create the war file
___Tomcat___________________________
deploy : deploy on tomcat
redeploy : undeploy, then deploy on tomcat
undeploy : undeploy from tomcat
</echo>
</target>
</project>