build-propel.xml 20 KB

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