root/branches/1.3/generator/build-propel.xml

Revision 1061, 21.3 kB (checked in by hans, 6 months ago)

Refs #642 - Adding databaseUser and databasePassword attribs to <propel-data-dump> task.

  • Property svn:keywords set to Id Rev Date Author HeadURL Revision
Line 
1 <project name="propel" default="main" basedir=".">
2
3   <!--
4     Note - You should not have to edit this file.
5
6     Instead, if calling build-propel.xml directly, edit the build.properties
7     that is in the same directory. If calling build-propel.xml via another
8     build file, you can also use the build.properties in the same directory,
9     or set the property propel.contextProperties to the file
10     to use in place of build.properties (e.g. project.properties).
11   -->
12
13   <property name="build.properties" value="build.properties"/>
14   <property name="propel.contextProperties" value="./${build.properties}"/>
15   <property name="propel.home" value="."/>
16
17   <available file="${propel.home}/build.properties" property="globalBuildPopertiesExists"/>
18
19   <if>
20         <and>
21                 <isset property="globalBuildPopertiesExists"/>
22         </and>
23         <then>
24             <property file="${propel.home}/build.properties"/>
25         </then>
26   </if>
27
28   <!--
29     The default.properties file will map old properties to the new ones along
30     with setting the corret defaults.
31   -->
32   <property file="${propel.home}/default.properties"/>
33
34   <!--
35     Do forward declarations of all of our tasks to
36     centralize them and clean up the targets.
37   -->
38
39   <path id="propelclasses">
40     <pathelement dir="${propel.home}/classes/"/>
41   </path>
42
43   <taskdef
44     name="propel-data-model"
45     classname="propel.phing.PropelDataModelTemplateTask" classpathRef="propelclasses"/>
46   <taskdef
47     name="propel-om"
48     classname="propel.phing.PropelOMTask" classpathRef="propelclasses"/>
49   <taskdef
50     name="propel-data-dtd"
51     classname="propel.phing.PropelDataDTDTask" classpathRef="propelclasses"/>
52   <taskdef
53     name="propel-data-dump"
54     classname="propel.phing.PropelDataDumpTask" classpathRef="propelclasses"/>
55   <taskdef
56     name="propel-data-sql"
57     classname="propel.phing.PropelDataSQLTask" classpathRef="propelclasses"/>
58    <taskdef
59     name="propel-creole-transform"
60     classname="propel.phing.PropelCreoleTransformTask" classpathRef="propelclasses"/>
61    <taskdef
62     name="propel-schema-reverse"
63     classname="propel.phing.PropelSchemaReverseTask" classpathRef="propelclasses"/>
64
65   <taskdef
66     name="propel-sql"
67     classname="propel.phing.PropelSQLTask" classpathRef="propelclasses"/>
68   <taskdef
69     name="propel-sql-exec"
70     classname="propel.phing.PropelSQLExec" classpathRef="propelclasses"/>
71   <taskdef
72     name="propel-graphviz"
73     classname="propel.phing.PropelGraphvizTask" classpathRef="propelclasses"/>
74   <taskdef
75     name="propel-convert-conf"
76     classname="propel.phing.PropelConvertConfTask" classpathRef="propelclasses"/>
77
78   <!-- ================================================================ -->
79   <!-- M A I N  T A R G E T                                             -->
80   <!-- ================================================================ -->
81   <!-- This default target will run all the targets that generate       -->
82   <!-- source. You will probably only run this target once then         -->
83   <!-- call individual targets as necessary to update your sources      -->
84   <!-- when you change your XML schema.                                 -->
85   <!-- ================================================================ -->
86
87   <target
88     name="main"
89         depends="mysqli-check"
90     description="==> generates sql + om classes">
91
92     <phingcall target="sql"/>
93     <phingcall target="om"/>
94     <phingcall target="convert-conf"/>
95   </target>
96
97   <!-- ================================================================ -->
98   <!-- C H E C K  R U N  O N L Y  O N  S C H E M A  C H A N G E         -->
99   <!-- ================================================================ -->
100   <!-- Maps the propel.runOnlyOnSchemaChange to                         -->
101   <!-- propel.internal.runOnlyOnSchemaChange                            -->
102   <!-- ================================================================ -->
103
104   <target name="check-run-only-on-schema-change">
105     <condition property="propel.internal.runOnlyOnSchemaChange">
106       <equals arg1="${propel.runOnlyOnSchemaChange}" arg2="true"/>
107     </condition>
108   </target>
109
110   <!-- ================================================================ -->
111   <!-- G E N E R A T E  P R O J E C T  S Q L                            -->
112   <!-- ================================================================ -->
113   <!-- Generate the SQL for your project, These are in addition         -->
114   <!-- to the base Turbine tables! The tables you require for your      -->
115   <!-- project should be specified in project-schema.xml.               -->
116   <!-- ================================================================ -->
117
118   <target
119     name="sql-check"
120     depends="check-run-only-on-schema-change"
121     if="propel.internal.runOnlyOnSchemaChange">
122     <uptodate
123       property="propel.internal.sql.uptodate"
124       targetfile="${propel.sql.dir}/${propel.schema.default.basename}.sql">
125       <srcfiles dir="${propel.schema.dir}" includes="**/${propel.schema.default.basename}.xml" />
126     </uptodate>
127   </target>
128
129   <!--  temporary target to check whether postgres is being used with identifier quoting ON.
130                 If so, a warning is issued, since identifier quoting is only paritally implemented & this point.  -->
131   <target name="pgsql-quoting-check">
132         <if>
133                 <and>
134                         <equals arg1="${propel.database}" arg2="pgsql"/>
135                         <equals arg1="${propel.disableIdentifierQuoting}" arg2=""/>
136                 </and>
137                 <then>
138                         <warn>ATTENTION: It appears you are using PostgreSQL and you have identifier-quoting turned on.</warn>
139                         <warn>It is suggested that you disable identifier quoting when using PostgreSQL -- especially if you</warn>
140                         <warn>have case-sensitive columns in your database.</warn>
141                         <warn></warn>
142                         <warn>To disable identifier quoting, add the following property to your build.properties (or specify</warn>
143                         <warn>it using -D on commandline):</warn>
144                         <warn></warn>
145                         <warn>propel.disableIdentifierQuoting=true</warn>
146                         <warn></warn>
147                         <warn>You can ignore this warning if you understand the issues related to case-sensitivity and Propel's</warn>
148                         <warn>DDL-only implementation of identifier quoting.</warn>
149                 </then>
150         </if>
151   </target>
152
153           <!--  temporary target to check whether mysqli is being used
154                         If so, a warning is issued, since this is deprecated  -->
155           <target name="mysqli-check">
156                 <if>
157                         <and>
158                                 <equals arg1="${propel.database}" arg2="mysqli"/>
159                         </and>
160                         <then>
161                                 <warn>ATTENTION: It appears you are using the mysqli driver.</warn>
162                                 <warn></warn>
163                                 <warn>This driver is no longer supported by Propel because Propel now uses PDO for database connections.</warn>
164                                 <warn>Please use mysqli driver instead.</warn>
165                                 <fail>Use 'mysql' instead of 'mysqli' for your propel.database property.</fail>
166                         </then>
167                 </if>
168           </target>
169        
170   <target
171     name="sql"
172     depends="sql-check,pgsql-quoting-check,mysqli-check"
173     unless="propel.internal.sql.uptodate"
174     description="==> generates the SQL for your project">
175
176     <echo message="+------------------------------------------+"/>
177     <echo message="|                                          |"/>
178     <echo message="| Generating SQL for YOUR Propel project!  |"/>
179     <echo message="|                                          |"/>
180     <echo message="+------------------------------------------+"/>
181
182     <phingcall target="sql-template"/>
183
184   </target>
185
186   <target name="sql-template">
187     <propel-sql
188           validate="${propel.schema.validate}"
189           xsd="${propel.schema.xsd.file}"
190           xsl="${propel.schema.xsl.file}"
191       outputDirectory="${propel.sql.dir}"
192       sqldbmap="${propel.sql.dir}/sqldb.map"
193       targetDatabase="${propel.database}"
194       packageObjectModel="${propel.packageObjectModel}"
195       url="${propel.database.url}"
196       userId="${propel.database.user}"
197       password="${propel.database.password}"
198       >
199       <mapper type="glob" from="${propel.sql.mapper.from}" to="${propel.sql.mapper.to}"/>
200       <schemafileset dir="${propel.schema.dir}"
201         includes="${propel.schema.sql.includes}"
202         excludes="${propel.schema.sql.excludes}"
203       />
204     </propel-sql>
205   </target>
206
207   <!-- ================================================================ -->
208   <!-- C R E A T E  T A R G E T  D A T A B A S E                        -->
209   <!-- ================================================================ -->
210   <!-- Create the target database by executing a generated script       -->
211   <!-- that is capable of performing the task.                          -->
212   <!-- ================================================================ -->
213
214   <target name="create-db-check">
215     <condition property="propel.internal.manualCreation">
216       <equals arg1="${propel.database.manualCreation}" arg2="true"/>
217     </condition>
218   </target>
219
220   <target
221     name="create-db"
222     unless="propel.internal.manualCreation"
223     depends="create-db-check,mysqli-check"
224     description="==> generates the target database">
225
226         <fail message="create-db target temporarily disabled, while we replace creole components."/>
227
228         <!--
229     <propel-data-model
230           validate="${propel.schema.validate}"
231           xsd="${propel.schema.xsd.file}"
232           xsl="${propel.schema.xsl.file}"
233       controlTemplate="${propel.template.sqlDbInit}"
234       outputDirectory="${propel.sql.dir}"
235       outputFile="create-db.sql"
236       targetDatabase="${propel.database}"
237       dbEncoding="${propel.database.encoding}"
238       templatePath="${propel.templatePath}"
239       packageObjectModel="${propel.packageObjectModel}"
240       >
241       <schemafileset dir="${propel.schema.dir}"
242         includes="${propel.schema.create-db.includes}"
243         excludes="${propel.schema.create-db.excludes}"
244       />
245     </propel-data-model>
246
247     <echo message="Executing the create-db.sql script ..."/>
248
249     <sql
250       autocommit="true"
251       driver="${propel.database.driver}"
252       onerror="continue"
253       src="${propel.sql.dir}/create-db.sql"
254       url="${propel.database.createUrl}"
255     />
256     -->
257   </target>
258
259   <!-- ================================================================ -->
260   <!-- I N S E R T  S I N G L E  S Q L  F I L E S                       -->
261   <!-- ================================================================ -->
262
263   <target
264     name="insert-sql"
265     description="==> inserts the generated sql ">
266
267     <propel-sql-exec
268       autocommit="true"
269       onerror="continue"
270       sqldbmap="${propel.sql.dir}/sqldb.map"
271       srcDir="${propel.sql.dir}"
272       url="${propel.database.buildUrl}"
273       userId="${propel.database.user}"
274       password="${propel.database.password}"
275     />
276   </target>
277
278   <!-- ================================================================ -->
279   <!-- C R E O L E   T O   X M L                                        -->
280   <!-- ================================================================ -->
281
282   <target
283     name="creole"
284     description="==> generate xml schema from Creole metadata">
285
286     <echo message="+-----------------------------------------------+"/>
287     <echo message="|                                               |"/>
288     <echo message="| Generating XML from Creole connection !       |"/>
289     <echo message="|                                               |"/>
290     <echo message="+-----------------------------------------------+"/>
291
292     <propel-creole-transform
293       dbDriver="${propel.database.creole.driver}"
294       dbSchema="${propel.database.schema}"
295       dbEncoding="${propel.database.encoding}"
296       dbUrl="${propel.database.creole.url}"
297       outputFile="${propel.schema.dir}/${propel.default.schema.basename}.xml"
298       samePhpName="${propel.samePhpName}"
299       addVendorInfo="${propel.addVendorInfo}"
300       addValidators="${propel.addValidators}"
301     />
302
303   </target>
304  
305   <!-- ================================================================ -->
306   <!-- N E W   R E V E R S E   T O   X M L                              -->
307   <!-- ================================================================ -->
308
309   <target
310     name="reverse"
311     description="==> generate xml schema from reverse-engineered database (new)">
312
313     <echo message="+-----------------------------------------------+"/>
314     <echo message="|                                               |"/>
315     <echo message="| Generating XML from PDO connection !          |"/>
316     <echo message="|                                               |"/>
317     <echo message="+-----------------------------------------------+"/>
318
319     <propel-schema-reverse
320       databaseName="${propel.project}"
321       dbSchema="${propel.database.schema}"
322       dbEncoding="${propel.database.encoding}"
323       url="${propel.database.buildUrl}"
324       userId="${propel.database.user}"
325       password="${propel.database.password}"
326       outputFile="${propel.schema.dir}/${propel.default.schema.basename}.xml"
327       samePhpName="${propel.samePhpName}"
328       addVendorInfo="${propel.addVendorInfo}"
329       addValidators="${propel.addValidators}"
330     />
331
332   </target>
333
334
335   <!-- ================================================================ -->
336   <!-- Generate SQL from XML data file                                  -->
337   <!-- ================================================================ -->
338
339   <target
340     name="datasql"
341     description="==> generates sql from data xml">
342
343     <echo message="+-----------------------------------------------+"/>
344     <echo message="|                                               |"/>
345     <echo message="| Generating SQL from data XML !                |"/>
346     <echo message="|                                               |"/>
347     <echo message="+-----------------------------------------------+"/>
348
349     <propel-data-sql
350           validate="${propel.schema.validate}"
351           xsd="${propel.schema.xsd.file}"
352           xsl="${propel.schema.xsl.file}"
353       outputDirectory="${propel.sql.dir}"
354       sqldbmap="${propel.sql.dir}/sqldb.map"
355       dbEncoding="${propel.database.encoding}"
356       targetDatabase="${propel.database}"
357       datadbmap="${propel.schema.dir}/datadb.map"
358       srcDir="${propel.schema.dir}"
359       >
360       <mapper type="glob" from="${propel.datasql.mapper.from}" to="${propel.datasql.mapper.to}"/>
361       <schemafileset dir="${propel.schema.dir}"
362         includes="${propel.schema.datadtd.includes}"
363         excludes="${propel.schema.datadtd.excludes}"
364       />
365     </propel-data-sql>
366   </target>
367
368   <!-- ================================================================ -->
369   <!-- Dump data from database into xml file                            -->
370   <!-- ================================================================ -->
371
372   <target
373     name="datadump"
374     description="==> dump data from database into xml file">
375
376     <echo message="+-----------------------------------------------+"/>
377     <echo message="|                                               |"/>
378     <echo message="| Dumping the data from database into XML       |"/>
379     <echo message="|                                               |"/>
380     <echo message="+-----------------------------------------------+"/>
381
382     <propel-data-dump
383           validate="${propel.schema.validate}"
384           xsd="${propel.schema.xsd.file}"
385           xsl="${propel.schema.xsl.file}"
386       targetDatabase="${propel.database}"
387       datadbmap="${propel.schema.dir}/datadb.map"
388       databaseDriver="${propel.database.driver}"
389       dbEncoding="${propel.database.encoding}"
390       databaseUrl="${propel.database.url}"
391       databaseUser="${propel.database.user}"
392       databasePassword="${propel.database.password}"
393       outputDirectory="${propel.schema.dir}">
394       <mapper type="glob" from="${propel.datadump.mapper.from}" to="${propel.datadump.mapper.to}"/>
395       <schemafileset dir="${propel.schema.dir}"
396         includes="${propel.schema.datadtd.includes}"
397         excludes="${propel.schema.datadtd.excludes}"
398       />
399      </propel-data-dump>
400   </target>
401
402   <!-- ================================================================ -->
403   <!-- G E N E R A T E  P R O J E C T  D A T A  D T D                   -->
404   <!-- ================================================================ -->
405   <!-- Generate the DATA DTD for your project                           -->
406   <!-- ================================================================ -->
407
408   <target
409     name="datadtd"
410     description="==> generates the DATA DTD for your project">
411
412     <echo message="+-----------------------------------------------+"/>
413     <echo message="|                                               |"/>
414     <echo message="| Generating Data DTD for YOUR Propel project!  |"/>
415     <echo message="|                                               |"/>
416     <echo message="+-----------------------------------------------+"/>
417
418     <propel-data-dtd
419           validate="${propel.schema.validate}"
420           xsd="${propel.schema.xsd.file}"
421           xsl="${propel.schema.xsl.file}"
422       targetDatabase="${propel.database}"
423       outputDirectory="${propel.output.dir}"
424       templatePath="${propel.templatePath}">
425       <!-- TODO: add properties for the mapper type, from, and to -->
426       <mapper type="glob" from="${propel.datadtd.mapper.from}" to="${propel.datadtd.mapper.to}"/>
427       <schemafileset dir="${propel.schema.dir}"
428         includes="${propel.schema.datadtd.includes}"
429         excludes="${propel.schema.datadtd.excludes}"
430       />
431     </propel-data-dtd>
432   </target>
433
434   <!-- ================================================================ -->
435   <!-- G E N E R A T E  P R O J E C T  P E E R  B A S E D  O M          -->
436   <!-- ================================================================ -->
437   <!-- Generate the Peer-based object model for your project.           -->
438   <!-- These are in addition to the base Propel OM!                     -->
439   <!-- ================================================================ -->
440
441   <target
442     name="om-check"
443     depends="check-run-only-on-schema-change"
444     if="propel.internal.runOnlyOnSchemaChange">
445     <uptodate
446       property="propel.internal.om.uptodate"
447       targetfile="${propel.php.dir}/report.${propel.project}.om.generation">
448       <srcfiles dir="${propel.schema.dir}" includes="**/${propel.schema.om.includes}.xml" />
449     </uptodate>
450   </target>
451
452   <target
453     name="om"
454     depends="om-check,mysqli-check"
455     unless="propel.internal.om.uptodate"
456     description="==> generates the Peer-based object model for your project">
457
458     <echo message="+------------------------------------------+"/>
459     <echo message="|                                          |"/>
460     <echo message="| Generating Peer-based Object Model for   |"/>
461     <echo message="| YOUR Propel project!                     |"/>
462     <echo message="|                                          |"/>
463     <echo message="+------------------------------------------+"/>
464
465     <phingcall target="om-template"/>
466     <!--<phingcall target="om-tar"/>-->
467   </target>
468
469   <target name="om-template">
470     <propel-om
471           validate="${propel.schema.validate}"
472           xsd="${propel.schema.xsd.file}"
473           xsl="${propel.schema.xsl.file}"
474       outputDirectory="${propel.php.dir}"
475       targetDatabase="${propel.database}"
476       targetPackage="${propel.targetPackage}"
477       targetPlatform="${propel.targetPlatform}"
478       packageObjectModel="${propel.packageObjectModel}"
479       >
480       <schemafileset dir="${propel.schema.dir}"
481         includes="${propel.schema.om.includes}"
482         excludes="${propel.schema.om.excludes}"
483       />
484     </propel-om>
485   </target>
486
487   <!-- ================================================================== -->
488   <!-- X M L   R U N T I M E   C O N F   T O   P H P   A R R A Y          -->
489   <!-- ================================================================== -->
490
491   <target
492     name="convert-conf"
493     description="==> converts properties file to PHP array">
494
495     <echo message="+------------------------------------------+"/>
496     <echo message="|                                          |"/>
497     <echo message="| Converting runtime config file to an     |"/>
498     <echo message="| array dump for improved performance.     |"/>
499     <echo message="|                                          |"/>
500     <echo message="+------------------------------------------+"/>
501
502
503         <echo>Output file: ${propel.runtime.phpconf.file}</echo>
504         <echo>XMLFile: ${propel.conf.dir}/${propel.runtime.conf.file}</echo>
505
506     <propel-convert-conf
507       targetDatabase="${propel.database}"
508       xsd="${propel.schema.xsd.file}"
509           xsl="${propel.schema.xsl.file}"
510       xmlConfFile="${propel.conf.dir}/${propel.runtime.conf.file}"
511       outputDirectory="${propel.phpconf.dir}"
512       outputFile="${propel.runtime.phpconf.file}"
513       packageObjectModel="${propel.packageObjectModel}"
514       outputClassmapFile="${propel.runtime.phpconf-classmap.file}">
515       <schemafileset dir="${propel.schema.dir}"
516         includes="${propel.schema.sql.includes}"
517         excludes="${propel.schema.sql.excludes}"
518       />
519      </propel-convert-conf>
520
521   </target>
522
523   <target
524     name="graphviz"
525     depends="sql-check"
526     description="==> generates Graphviz file for your project">
527
528     <echo message="+------------------------------------------+"/>
529     <echo message="|                                          |"/>
530     <echo message="| Generating Graphiz for YOUR Propel       |"/>
531     <echo message="| project!                                 |"/>
532     <echo message="|                                          |"/>
533     <echo message="+------------------------------------------+"/>
534
535     <propel-graphviz
536       outputDirectory="${propel.graph.dir}"
537       targetDatabase="${propel.database}"
538       sqldbmap="${propel.sql.dir}/sqldb.map"
539       packageObjectModel="${propel.packageObjectModel}">
540       <mapper type="glob" from="${propel.sql.mapper.from}" to="${propel.sql.mapper.to}"/>
541       <schemafileset dir="${propel.schema.dir}"
542         includes="${propel.schema.sql.includes}"
543         excludes="${propel.schema.sql.excludes}"
544       />
545     </propel-graphviz>
546   </target>
547
548
549 </project>
Note: See TracBrowser for help on using the browser.