Project

General

Profile

build.xml

Atul Dalvi, 10/11/2017 05:45 AM

Download (26 KB)

 
1
<project name="hotel" default="dist" basedir=".">
2

    
3
   <description>Hotel Management</description>
4

    
5
   <property name="ant.contrib.dir" value="${basedir}/build/ant.contrib/" />
6
   <property name="ant.contrib.url" value="https://proj.goldencode.com/downloads/ant_contrib/ant-contrib-1.0b5.zip" />
7

    
8
   <!-- ANT-CONTRIB autoinstaller -->
9
   <available property="ant-contrib-exists" file="${ant.contrib.dir}/ant-contrib-1.0b5-SNAPSHOT.jar" />
10
   <target name="download-ant-contrib" unless="ant-contrib-exists">
11
      <mkdir dir="${ant.contrib.dir}" />
12
      <get src="${ant.contrib.url}"
13
           dest="${ant.contrib.dir}/ant-contrib-1.0b5.zip"
14
           username="true" />
15
      <unzip src="${ant.contrib.dir}/ant-contrib-1.0b5.zip"
16
             dest="${ant.contrib.dir}"
17
             overwrite="no" />
18
      <delete file="${ant.contrib.dir}/ant-contrib-1.0b5.zip" />
19
   </target>
20
   
21
   <target name="init-ant-contrib" depends="download-ant-contrib">
22
      <taskdef resource="net/sf/antcontrib/antcontrib.properties">
23
         <classpath>
24
            <fileset dir="${ant.contrib.dir}">
25
               <include name="*.jar"/>
26
            </fileset>
27
            <fileset dir="${ant.library.dir}">
28
               <include name="*.jar"/>
29
            </fileset>
30
         </classpath>
31
      </taskdef>
32
   </target>
33
      
34
   <property file="build.properties"/>
35
   
36
   <!-- a link named "p2j/" to the p2j project location must exist for this to work -->
37
   
38
   <!-- set global properties for this build -->
39
   
40
   <property name="build.home"           value="${basedir}/build" />
41
   <property name="dist.home"            value="${basedir}/distribution" /> 
42
   <property name="data.home"            value="${basedir}/data" />
43
   <property name="src.home"             value="${basedir}/src" />
44
   <property name="srcnew.home"          value="${basedir}/srcnew" />
45
   <property name="lib.home"             value="${basedir}/lib" />
46
   <property name="cfg.home"             value="${basedir}/cfg" />
47
   <property name="manifest.dir"         value="${basedir}/manifest" />
48

    
49
   <property name="p2j.home"             value="." />
50
   <property name="p2j.build.home"       value="${p2j.home}/p2j/build" />
51
   <property name="p2jlib.home"          value="${p2j.home}/p2j/build/lib" />
52
   <property name="p2jsrc.home"          value="${p2j.home}/p2j/src" />
53

    
54
   <property name="appname"              value="hotel" />
55
   <property name="pkgroot"              value="com/goldencode/${appname}" />   
56
   <property name="app.4gl.src"          value="./abl/" />   
57
   <property name="app.4gl.pattern"      value="*.[wp]" />   
58
   <property name="destination.package"  value="${build.home}/classes/${pkgroot}"/>
59
   <property name="deploy.home"          value="${basedir}/deploy" />
60
   <property name="deploy.home.abs"      location="${deploy.home}" />
61
   <property name="rpt.home"             value="${basedir}/rpt" />
62
   <property name="cg.home"              value="${basedir}/callgraph" />
63
   
64
   <!-- enable database type(s) -->
65
   <property name="db.h2"                value="true" />
66
   <property name="db.postgresql"        value="false" />
67
   
68
   <!-- sql global properties  -->
69
   <property name="db.home"              value="${deploy.home}/db" />
70
   <property name="db.host"              value="localhost" />
71
   <property name="db.port"              value="5433" />
72
   <property name="sql.user"             value="fwd_user" />
73
   <property name="sql.admin"            value="fwd_admin" />
74
   <property name="sql.user.pass"        value="user" />
75
   <property name="sql.admin.pass"       value="admin" />
76

    
77
   <condition property="isWindows">
78
      <os family="windows" />
79
   </condition>
80

    
81
   <condition property="isUnix">
82
      <os family="unix" />
83
   </condition>
84

    
85
   <condition property="escaped.quotes" value="&quot;&quot;&quot;" else="&quot;">
86
      <isset property="isWindows"  />
87
   </condition>
88

    
89
   
90
   <!--  ==================== Compilation Control Options ==================== -->
91

    
92
   <!--
93

94
     These properties control option settings on the Javac compiler when it
95
     is invoked using the <javac> task.
96

97
     compile.debug        Should compilation include the debug option?
98
     compile.deprecation  Should compilation include the deprecation option?
99
     compile.optimize     Should compilation include the optimize option?
100

101
   -->
102

    
103
   <property name="compile.debug"       value="true"/>
104
   <property name="compile.deprecation" value="false"/>
105
   <property name="compile.optimize"    value="true"/>
106
   
107
   <!-- path used when compiling Java classes -->
108
   <path id="compile.classpath">
109
      <fileset dir="${p2jlib.home}">
110
        <include name="*.jar"/>
111
     </fileset>
112
   </path>
113
   
114
   <!-- path used when running application related tasks-->
115
   <path id="app.classpath">
116
      <fileset dir="${deploy.home}/lib">
117
         <include name="*.jar"/>
118
      </fileset>
119
   </path>
120
   
121
   <!-- create the time stamp -->
122
   <target name="init">
123
      <tstamp/>
124
      <tstamp>
125
         <format property="LOG_STAMP" pattern="yyyyMMdd_HHmmss" />
126
      </tstamp>
127
   </target>
128

    
129
   <!-- generate call graph -->
130
   <target name="callgraph" depends="convert.front, convert.front.list" description="Parse the project and create the call graph.">
131
      <record name="callgraph_${LOG_STAMP}.log" action="start"/>
132
      <java classname="com.goldencode.p2j.uast.CallGraphGenerator"
133
            fork="true"
134
            failonerror="true"
135
            dir="${basedir}" >
136
         <jvmarg value="-server"/>
137
         <jvmarg value="-Xmx2G"/>
138
         <jvmarg value="-DP2J_HOME=${p2j.home}"/>
139
         <arg value ="-d2"/>
140
         <classpath refid="compile.classpath"/>
141
      </java>
142
      <record name="callgraph_${LOG_STAMP}.log" action="stop"/>
143
   </target>
144
   
145
   <!-- generate all reports -->
146
   <target name="rpt-no-front"
147
           depends="init, init-ant-contrib"
148
           description="Generate code and schema reports from the already parsed project.">
149
      <record name="rpt_schema_${LOG_STAMP}.log" action="start"/>
150
      <var name="db.schema.files" value=""/>
151
      <for list="${db.names}" param="db.name">
152
         <sequential>
153
            <var name="db.schema.files" value="${db.schema.files} data/namespace/@{db.name}.dict"/>
154
         </sequential>
155
      </for>
156
      
157
      <java classname="com.goldencode.p2j.report.ReportDriver"
158
            fork="true"
159
            failonerror="true"
160
            dir="${basedir}" >
161
         <jvmarg value="-server"/>
162
         <jvmarg value="-Xmx4G"/>
163
         <jvmarg value="-DP2J_HOME=${p2j.home}"/>
164
         <jvmarg value="-DappAdminPass=${appname}"/>
165
         <arg value="-Td2"/>
166
         <arg value="reports/schema"/>
167
         <arg value="${app.4gl.src}"/>
168
         <arg value="*.dict"/>
169
         <arg line="${db.schema.files}"/>
170
         <classpath refid="compile.classpath"/>
171
      </java>
172
      <record name="rpt_schema_${LOG_STAMP}.log" action="stop"/>
173
      <record name="rpt_code_${LOG_STAMP}.log" action="start"/>
174
      <java classname="com.goldencode.p2j.report.ReportDriver"
175
            fork="true"
176
            failonerror="true"
177
            dir="${basedir}" >
178
         <jvmarg value="-server"/>
179
         <jvmarg value="-Xmx4G"/>
180
         <jvmarg value="-DP2J_HOME=${p2j.home}"/>
181
         <arg value="-Sd2"/>
182
         <arg value="reports/profile"/>
183
         <arg value="${app.4gl.src}"/>
184
         <arg value="*.ast"/>
185
         <classpath refid="compile.classpath"/>
186
      </java>
187
      <record name="rpt_code_${LOG_STAMP}.log" action="stop"/>
188

    
189
      <echo message="Report generation finished."/>
190
   </target>
191

    
192
   <target name="rpt"
193
           depends="convert.front, convert.front.list, rpt-no-front"
194
           description="Parse the project and generate code and schema reports.">
195
   </target>
196
   
197
   <!-- generate everything that the report server can support -->
198
   <target name="report_server" depends="rpt, callgraph" description="Parse the project, generate schema/code reports and create the call graph." />
199
   
200
   <target name="check-file-cvt-list">
201
      <available file="file-cvt-list.txt" property="file-cvt-list"/>
202
   </target>
203

    
204
   <!-- convert Progress code from ${app.4gl.src} into ${src}, using ${app.4gl.pattern} pattern -->
205
   <target name="convert"
206
           depends="init, check-file-cvt-list"
207
           description="Convert the Progress ABL source code to Java source code, using a pattern as input."
208
           unless="file-cvt-list">
209
      <record name="cvt_${LOG_STAMP}.log" action="start"/>
210
      <java classname="com.goldencode.p2j.convert.ConversionDriver"
211
            fork="true"
212
            failonerror="true"
213
            dir="${basedir}">
214
         <jvmarg value="-server"/>
215
         <jvmarg value="-Xmx4G"/>
216
         <jvmarg value="-DP2J_HOME=${p2j.home}"/>
217
         <arg value="-Sd2"/>
218
         <arg value="f2+m0+cb"/>
219
         <arg value="${app.4gl.src}"/>
220
         <arg value="${app.4gl.pattern}"/>
221
         <classpath refid="compile.classpath"/>
222
      </java>
223
      <record name="cvt_${LOG_STAMP}.log" action="stop"/>
224
   </target>
225
        
226
   <!-- convert Progress code from ${app.4gl.src} into ${src}, using an explicit file list, in file-cvt-list.txt -->
227
   <target name="convert.list"
228
           depends="init, check-file-cvt-list"
229
           description="Convert the Progress ABL source code to Java source code, using a file-cvt-list.txt as input."
230
           if="file-cvt-list">
231
      <record name="cvt_${LOG_STAMP}.log" action="start"/>
232
      <java classname="com.goldencode.p2j.convert.ConversionDriver"
233
            fork="true"
234
            failonerror="true"
235
            dir="${basedir}">
236
         <jvmarg value="-server"/>
237
         <jvmarg value="-Xmx4G"/>
238
         <jvmarg value="-DP2J_HOME=${p2j.home}"/>
239
         <arg value="-Fd2"/>
240
         <arg value="f2+m0+cb"/>
241
         <arg value="file-cvt-list.txt"/>
242
         <classpath refid="compile.classpath"/>
243
      </java>
244
      <record name="cvt_${LOG_STAMP}.log" action="stop"/>
245
   </target>
246
   
247
   <target name="convert.front" depends="init, check-file-cvt-list" description="Execute the parse phase of the conversion process, using a pattern as input." unless="file-cvt-list">
248
      <record name="cvt_f2_${LOG_STAMP}.log" action="start"/>
249
      <java classname="com.goldencode.p2j.convert.ConversionDriver"
250
            fork="true"
251
            failonerror="true"
252
            dir="${basedir}">
253
         <jvmarg value="-server"/>
254
         <jvmarg value="-Xmx4G"/>
255
         <jvmarg value="-XX:-OmitStackTraceInFastThrow"/>
256
         <jvmarg value="-DP2J_HOME=${p2j.home}"/>
257
         <arg value="-Sd2"/>
258
         <arg value="f2"/>
259
         <arg value="${app.4gl.src}"/>
260
         <arg value="${app.4gl.pattern}"/>
261
         <classpath refid="compile.classpath"/>
262
      </java>
263
      <record name="cvt_f2_${LOG_STAMP}.log" action="stop"/>
264
   </target>
265

    
266
   <target name="convert.front.list" depends="init, check-file-cvt-list" description="Execute the parse phase of the conversion process, using the file named 'file-cvt-list.txt' as input." if="file-cvt-list">
267
      <record name="cvt_f2_${LOG_STAMP}.log" action="start"/>
268
      <java classname="com.goldencode.p2j.convert.ConversionDriver"
269
            fork="true"
270
            failonerror="true"
271
            dir="${basedir}">
272
         <jvmarg value="-server"/>
273
         <jvmarg value="-Xmx4G"/>
274
         <jvmarg value="-XX:-OmitStackTraceInFastThrow"/>
275
         <jvmarg value="-DP2J_HOME=${p2j.home}"/>
276
         <arg value="-Fd2"/>
277
         <arg value="f2"/>
278
         <arg value="file-cvt-list.txt"/>
279
         <classpath refid="compile.classpath"/>
280
      </java>
281
      <record name="cvt_f2_${LOG_STAMP}.log" action="stop"/>
282
   </target>
283
   
284
   <target name="convert.middle" depends="init, check-file-cvt-list" description="Execute the parse and schema conversion phases of the conversion process, using a pattern as input." unless="file-cvt-list">
285
      <record name="cvt_f2m0_${LOG_STAMP}.log" action="start"/>
286
      <java classname="com.goldencode.p2j.convert.ConversionDriver"
287
            fork="true"
288
            failonerror="true"
289
            dir="${basedir}">
290
         <jvmarg value="-server"/>
291
         <jvmarg value="-Xmx4G"/>
292
         <jvmarg value="-XX:-OmitStackTraceInFastThrow"/>
293
         <jvmarg value="-DP2J_HOME=${p2j.home}"/>
294
         <arg value="-Sd2"/>
295
         <arg value="f2+m0"/>
296
         <arg value="${app.4gl.src}"/>
297
         <arg value="${app.4gl.pattern}"/>
298
         <classpath refid="compile.classpath"/>
299
      </java>
300
      <record name="cvt_f2m0_${LOG_STAMP}.log" action="stop"/>
301
   </target>
302
   
303
   <target name="convert.middle.list" depends="init, check-file-cvt-list" description="Execute the parse and schema conversion phases of the conversion process, using the file named 'file-cvt-list.txt' as input." if="file-cvt-list">
304
      <record name="cvt_f2m0_${LOG_STAMP}.log" action="start"/>
305
      <java classname="com.goldencode.p2j.convert.ConversionDriver"
306
            fork="true"
307
            failonerror="true"
308
            dir="${basedir}">
309
         <jvmarg value="-server"/>
310
         <jvmarg value="-Xmx4G"/>
311
         <jvmarg value="-XX:-OmitStackTraceInFastThrow"/>
312
         <jvmarg value="-DP2J_HOME=${p2j.home}"/>
313
         <arg value="-Fd2"/>
314
         <arg value="f2+m0"/>
315
         <arg value="file-cvt-list.txt"/>
316
         <classpath refid="compile.classpath"/>
317
      </java>
318
      <record name="cvt_f2m0_${LOG_STAMP}.log" action="stop"/>
319
   </target>
320

    
321
   <!-- make sure the p2j project code is compiled -->
322
   <target name="p2j-build" depends="check.p2j.dir" description="Compile the P2J project." >
323
      <!-- compile the java code from ${src} into ${build} 
324
      <ant antfile="build.xml" target="all" dir="p2j" inheritall="false" inheritrefs="false"/>
325
      -->
326
   </target>
327
  
328
   <!-- compile -->
329
   <target name="compile"
330
           depends="init, check.p2j.dir, clean.build, p2j-build, prepare"
331
           description="Compiles the converted application Java source code.  Does NOT convert, create jars or deploy." >
332
           
333
      <record name="build_${LOG_STAMP}.log" action="start"/>
334
      <!-- Compile DMO and UI classes only -->
335
      <javac srcdir="${src.home}"
336
             destdir="${build.home}/classes"
337
             includes="${pkgroot}/dmo/**
338
                       ${pkgroot}/ui/**"
339
             debug="${compile.debug}"
340
             deprecation="${compile.deprecation}"
341
             memoryMaximumSize="4G"
342
             fork="true"
343
             optimize="${compile.optimize}"
344
             includeantruntime="false" >   
345
         <classpath refid="compile.classpath"/>
346
      </javac>
347

    
348
      <!-- Compile all other classes -->
349
      <javac srcdir="${src.home}"
350
             destdir="${build.home}/classes"
351
             debug="${compile.debug}"
352
             deprecation="${compile.deprecation}"
353
             memoryMaximumSize="4G"
354
             fork="true"
355
             optimize="${compile.optimize}"
356
             includeantruntime="false" >   
357
         <classpath refid="compile.classpath"/>
358
      </javac>
359

    
360
      <record name="build_${LOG_STAMP}.log" action="stop"/>
361
      <echo message="Compiling Java Sources Done."/>
362
   </target>
363
   
364
   <target name="prepare">
365

    
366
      <!-- create build directories as needed -->
367
      
368
      <mkdir dir="${build.home}" />
369
      <mkdir dir="${build.home}/lib" />
370
      <mkdir dir="${build.home}/classes" />
371
      
372
      <!-- create distribution directory as needed -->
373
      
374
      <mkdir dir="${dist.home}" />
375
      <mkdir dir="${dist.home}/docs/api" />
376
      
377
      <!-- copy external jars -->
378
      
379
      <mkdir dir="${lib.home}" />
380
      <copy todir="${build.home}/lib">
381
         <fileset dir="${lib.home}" />
382
      </copy>
383
      
384
      <!-- create src dir -->
385
      <mkdir dir="${src.home}" />
386
      
387
      <!-- copy application graphics -->
388
      <copy todir="${build.home}/classes/${pkgroot}">
389
         <fileset dir="${app.4gl.src}" includes="**/*.png **/*.jpg **/*.bmp **/*.ico" />
390
      </copy>
391

    
392
      <!-- copy all XML documents -->
393
      <copy todir="${build.home}/classes">
394
         <fileset dir="${src.home}" includes="**/*.xml" />
395
      </copy>
396
      
397
      <!-- Copy ehcache production config file into classpath -->
398
      <copy file="${cfg.home}/ehcache.xml"
399
            tofile="${build.home}/classes/ehcache.xml" />   
400

    
401
      <!-- Copy SQL scripts from src to equivalent location in build -->
402
      <copy todir="${build.home}/classes">
403
         <fileset dir="${src.home}" includes="**/*.sql" />
404
      </copy>
405

    
406
      <!-- Copy name_map.cache file to root of build -->
407
      <copy file="${basedir}/name_map.cache"
408
            tofile="${build.home}/classes" />
409

    
410
      <!-- Copy p2j.cfg.xml* from src to equivalent location in build -->
411
      <copy todir="${build.home}/classes/cfg">
412
         <fileset dir="${cfg.home}" includes="p2j.cfg.xml* registry.xml" />
413
      </copy>
414

    
415
      <!-- Copy data/ from src to equivalent location in build -->
416
      <copy todir="${build.home}/classes/data">
417
         <fileset dir="${data.home}" includes="**/*.dict" />
418
         <fileset dir="${data.home}" includes="**/*.p2o" />
419
      </copy>
420

    
421
      <!-- Copy data ASTs to equivalent location in build -->
422
      <copy todir="${build.home}/classes">
423
         <fileset dir="${data.home}" includes="**/*.dict, **/*.schema, **/*.p2o" />
424
      </copy>
425

    
426
   </target>
427
   
428
   <!-- jar -->  
429
   <target name="jar" depends="check.p2j.dir,compile" description="Compiles and Jars the converted application Java source code.  Does NOT convert or deploy." >
430
      <jar jarfile="${build.home}/lib/${appname}.jar"
431
           basedir="${build.home}/classes"
432
           includes="**/${pkgroot}/**
433
                     dmo-index*.dtd
434
                     dir_schema_ext.xml
435
                     ehcache.xml
436
                     *.jasper
437
                     **.xml
438
                     cfg/**
439
                     data/**
440
                     **/*.png
441
                     **/*.jpg
442
                     **/*.bmp
443
                     **/*.ico"
444
           manifest="${manifest.dir}/${appname}.mf"
445
           index="true"   />
446
   </target>      
447

    
448
   <!-- deploy the application jars and database -->
449
   <target name="deploy.all"
450
           depends="clean, clean.dist, convert, convert.list, jar, deploy.prepare, import.db "
451
           description="Convert, compile the converted Java sources, create jars, deploys the jars and creates/imports the database." >
452
   </target>
453
   
454
   <!-- deploy the application jars and database -->
455
   <target name="deploy"
456
           depends="clean, clean.dist, convert, convert.list, jar, deploy.prepare"
457
           description="Convert, compile the converted Java sources, create jars, deploys the jars.  Does NOT create/import the database." >
458
   </target>
459

    
460
   <!-- deploy the application jars and database -->
461
   <target name="deploy.prepare"
462
           description="Deploys the generated jars by copying them to the location expected by the runtime scripts." >
463
           
464
      <!-- create the deploy lib folder -->
465
      <mkdir dir="${deploy.home}/lib"/>
466
      
467
      <!-- copy the required jars to the distibution directory -->
468
      <copy file="${build.home}/lib/${appname}.jar" tofile="${deploy.home}/lib/${appname}.jar"/>
469

    
470
      <!-- Copy external jars -->
471
      <copy todir="${deploy.home}/lib">
472
        <!--  exclude the AspectJ tools -->
473
        <fileset dir="${p2jlib.home}" excludes="aspectjtools.jar"/>
474
      </copy>
475
   </target>
476
   
477
   <target name="dist" depends="deploy.all" description="Does a deploy.all and then tars the result." >
478
      <mkdir dir="${dist.home}"/>
479
      <tar destfile="${dist.home}/${appname}-${DSTAMP}.tar" basedir="${deploy.home}" />
480
   </target>
481
   
482
   <target name="dist.abl" depends="init" description="Create a zip archive with the files needed to run the sample on OpenEdge" >
483
      <mkdir dir="${dist.home}/"/>
484
      <zip destfile="${dist.home}/${appname}-abl-${DSTAMP}.zip" basedir="${basedir}" 
485
           includes="abldb/
486
                     *.bat
487
                     *.ini
488
                     *.pf
489
                     start_*_abl.cmd
490
                     abl/**/*
491
                     data/*.df
492
                     data/dump/**/*.d"/>
493
   </target>
494
   
495
   <target name="clean.build" description="Remove all built files from the conversion process." >
496
      <delete includeemptydirs="true" failonerror="false">
497
         <fileset dir="${build.home}">
498
            <include name="**/*"/>
499
            <exclude name="ant.contrib/**"/>
500
         </fileset>
501
      </delete>
502

    
503
      <delete dir="${deploy.home}/spawner"/>
504
      <delete>
505
         <fileset dir="${deploy.home}/lib" includes="*" />
506
      </delete>
507
      <delete>
508
         <fileset dir="${deploy.home}/client/" includes="*.log" />
509
      </delete>
510
      <delete>
511
         <fileset dir="${deploy.home}/server/" includes="*.log" />
512
      </delete>
513
      <delete dir="${dist.home}"/>
514
   </target>
515
   
516
   <target name="clean" description="Remove all generated files from the conversion process." >
517
      <delete includeemptydirs="true" failonerror="false">
518
         <fileset dir="${basedir}/src"
519
            includes="**/*"
520
            excludes="text-metrics.xml
521
                      font-metrics.xml" /> 
522
      </delete>
523
      <!-- only delete the src dir if it is empty -->
524
      <delete includeemptydirs="true" failonerror="false">
525
        <fileset dir="${src.home}" excludes="**/*" />
526
      </delete>
527
      <delete dir="${basedir}/ddl"/>
528
      <delete dir="${basedir}/local"/>
529
      <delete dir="${basedir}/com"/>
530
      <delete dir="${basedir}/lib"/>
531
      <delete dir="${basedir}/rptdb"/>
532
      <delete>
533
         <fileset dir="${app.4gl.src}" 
534
                  includes="**/*.pphints 
535
                            **/*.cache
536
                            **/*.lexer 
537
                            **/*.parser 
538
                            **/*.ast
539
                            **/*.ast.original
540
                            **/*.jast 
541
                            **/*.dict
542
                            **/*.p2o
543
                            **/*.schema
544
                            **/*.log" />
545
      </delete>
546
      <delete>
547
         <fileset dir="${basedir}/data/namespace" includes="*.dict *.p2o *.schema" />
548
      </delete>
549
      <delete>
550
         <fileset dir="${basedir}" includes="schema_names*.rpt *.log " />
551
      </delete>
552
      <delete file="ui_strings.txt"/>
553
      <delete file="orphan-frames.dat"/>
554
      <delete file="schema-triggers.xml"/>
555
      <delete file="internal_procedures.xml"/>
556
      <delete file="name_map.cache"/>
557
      <delete file="file_sys.xml"/>
558
      <delete file="name_map.xml"/>
559
      <delete file="function_return_types.xml"/>
560
      <delete file="duplicate_function_return_types.xml"/>
561
      <delete file="cfg/registry.xml"/>
562
   </target>
563
   
564
   <!-- delete the ${build} and ${dist} directory trees -->
565
   <target name="clean.dist" description="Remove the distribution (docs and tar files) directories." >
566
      <delete dir="${dist.home}"/>
567
   </target>   
568
   
569
   <target name="dir.check">
570
      <condition property="dir.exists">
571
         <available file="${p2j.home}" type="dir"/>
572
      </condition>
573
   </target>
574
     
575
   <target name="check.p2j.dir" depends="dir.check" unless="dir.exists">
576
      <echo>"${p2j.home} directory is missing.  Please add a link to the P2J directory location."</echo>
577
   </target>
578

    
579
   <!-- delete the ${rpt.home} directory trees -->
580
   <target name="clean.rpt" description="Remove generated reports directory.">
581
      <delete dir="${rpt.home}" /> 
582
   </target>
583
   
584
   <!-- delete the ${cg.home} directory trees -->
585
   <target name="clean.cg" description="Remove generated call graph.">
586
      <delete dir="${cg.home}" /> 
587
      <delete file="callgraph.graphml" /> 
588
   </target>
589
   
590
   <!-- Remove all traces of conversion, import or execution of the result (generated files, logs, imported dbs). -->
591
   <target name="clean.all"
592
           depends="clean, clean.build, clean.db, clean.rpt, clean.cg"
593
           description="Remove all traces of conversion, reporting, callgraph analysis, import or execution of the result (generated files, logs, imported dbs)." >
594
   </target>
595
   
596
   <target name="clean.db" description="Drop all databases."
597
           depends="clean.db.h2, clean.db.pg" />
598

    
599
   <target name="create.db" depends="create.db.h2, create.db.pg"
600
           description="Create empty database instance for all enabled database types." />
601
   
602
   <target name="import.db" depends="import.db.h2, import.db.pg"
603
           description="Create empty database instance and import data for all enabled database types." />
604

    
605
   <target name="db.task" depends="init-ant-contrib">
606
      <for list="${db.names}" param="db.name">
607
         <sequential>
608
            <ant antfile="build_db.xml" inheritRefs="true" target="${db.task}">
609
               <property name="db.name" value="@{db.name}"/>
610
            </ant>
611
         </sequential>
612
      </for>
613
   </target>
614

    
615
   <!-- drop the H2 database by deleting the ${db.home} directory -->
616
   <target name="clean.db.h2" description="Remove generated database directory." if="${db.h2}">
617
      <antcall target="db.task" inheritRefs="true">
618
         <param name="db.task" value="clean.db.h2"/>
619
      </antcall>
620
   </target>
621

    
622
   <target name="create.db.h2" depends="check.p2j.dir, init, clean.db.h2"
623
           description="Creates an empty H2 database instance using the DDL generated during conversion."
624
           if="${db.h2}">
625
      <antcall target="db.task" inheritRefs="true">
626
         <param name="db.task" value="create.db.h2"/>
627
      </antcall>
628
   </target>
629
   
630
   <target name="import.db.h2" depends="create.db.h2"
631
           description="Import data (.d files) into database."
632
           if="${db.h2}">
633
      <antcall target="db.task" inheritRefs="true">
634
         <param name="db.task" value="import.db.h2"/>
635
      </antcall>
636
   </target>
637

    
638
   <!-- drop the PostgreSQL database -->
639
   <target name="clean.db.pg" description="Drop PostgreSQL database." if="${db.postgresql}">
640
      <antcall target="db.task" inheritRefs="true">
641
         <param name="db.task" value="clean.db.pg"/>
642
      </antcall>
643
   </target>
644
   
645
   <target name="create.db.pg" depends="check.p2j.dir, init, clean.db.pg"
646
           description="Create an empty PostgreSQL database instance using the DDL generated during conversion."
647
           if="${db.postgresql}">
648
      <antcall target="db.task" inheritRefs="true">
649
         <param name="db.task" value="create.db.pg"/>
650
      </antcall>
651
   </target>
652
   
653
   <target name="import.db.pg" depends="create.db.pg"
654
           description="Import data (.d files) into PostgreSQL database."
655
           if="${db.postgresql}">
656
      <antcall target="db.task" inheritRefs="true">
657
         <param name="db.task" value="import.db.pg"/>
658
      </antcall>
659
   </target>
660
</project>