<!--
    Use this file to faciliate easy per-project building using 
	PEAR-installed Propel-generator.

	This Phing script is invoked via the shell script propel-gen (.bat
	for Windows).  Normally you should not need to edit this script or
	be aware of it in any way.
	
    Normal use:
    $> propel-gen /path/to/my/project
    
    Specific target: 
    $> propel-gen insert-sql /path/to/my/project 

-->
<project name="propel-project-builder" default="main" basedir=".">

<!-- set a default target if none provided -->
<property name="target" value="main"/>

<property name="propel.project.dir" value="${project.dir}"/>
<resolvepath propertyName="propel.project.dir" file="${propel.project.dir}" dir="${application.startdir}"/>

<target name="projdircheckExists">
  <condition property="projDirExists">
  	<and>
		<not>
			<equals arg1="${propel.project.dir}" arg2="" trim="true"/>
		</not>
		<available file="${propel.project.dir}/build.properties"/>
	</and>
  </condition>
</target>

<target name="projdircheck" depends="projdircheckExists" unless="projDirExists">
	<echo message="====================================================="/>
	<echo message="Project directory not specified or invalid. You must "/>
	<echo message="specify the path to your project directory and your "/>
	<echo message="project directory must contain your build.properties "/>
	<echo message="and schema.xml files.                                "/>
	<echo message=" "/>
	<echo message="Usage: "/>
	<echo message=" "/>
	<echo message="$&gt; propel-gen /path/to/projectdir [target]"/>
	<echo message=" "/>
	<echo message="====================================================="/>	
	<fail message="No project directory specified."/>
</target>

<target name="configure" depends="projdircheck">
	<echo msg="Loading project-specific props from ${project.dir}/build.properties"/>
	<property file="${propel.project.dir}/build.properties"/>
</target>

<target name="main" depends="configure" 
  description="The main target. Includes project-specific build.properties and calls the build-propel.xml script">	

 <!--<property file="${project.dir}/build.properties"/>-->
 <phing phingfile="build-propel.xml" target="${target}"/>
 
</target>


<!-- 
 Convenience mappings to build-propel.xml main targets 
 
 This makes it possible to use this buildfile w/o needing to specify
 target as a property, e.g.:
 
 $> phing -Dproject=bookstore insert-sql
 
 The main reason for this is just consistency w/ old build-propel.xml file
 (primarily for documentation & user confusion avoidance reasons).  There are relatively
 few & infrequently changing main targets of build-propel.xml, so it's a non-
 issue as far as maintenance is concerned.
-->

<target name="convert-props" depends="configure">
	<phing phingfile="build-propel.xml" target="convert-props"/>
</target>

<target name="create-db" depends="configure">
	<phing phingfile="build-propel.xml" target="create-db"/>
</target>

<target name="creole" depends="configure">
	<phing phingfile="build-propel.xml" target="creole"/>
</target>

<target name="datadtd" depends="configure">
	<phing phingfile="build-propel.xml" target="datadtd"/>
</target>

<target name="datadump" depends="configure">
	<phing phingfile="build-propel.xml" target="datadump"/>
</target>

<target name="datasql" depends="configure">
	<phing phingfile="build-propel.xml" target="datasql"/>
</target>

<target name="insert-sql" depends="configure">
	<phing phingfile="build-propel.xml" target="insert-sql"/>
</target>

<target name="om" depends="configure">
	<phing phingfile="build-propel.xml" target="om"/>
</target>

<target name="sql" depends="configure">
	<phing phingfile="build-propel.xml" target="sql"/>
</target>

</project>