The build file for newapps updated to support Windows XP.
 
--Amin--
<?xml version="1.0"?>

<!-- Build file for application -->
<project name="peer" default="compile" basedir=".">

  <!-- Build classpath -->
  <path id="classpath">
    <fileset dir="../lib">
      <include name="**/*.jar"/>
    </fileset>
    <fileset dir="../../../../bin">
      <include name="**/servlet*.jar"/>
    </fileset>
  </path>

  <!-- Give user a chance to override without editing this file 
  (and without typing -D each time it compiles it) -->    
  
  <property file="build.properties"/>
  <property file="${user.home}/build.properties"/>
  <property name="build.properties" value="build.properties"/>
  
  <property name="final.name" value="${project}-${version}"/>
  <property name="final.dir" value="../${final.name}/"/>
  
  <!-- ================================================================ -->
  <!-- I N I T  T A S K  T A R G E T                                    -->
  <!-- ================================================================ -->
  <!-- Taskdefs are defined inside this target as Ant seems to have     -->
  <!-- problems defining them at the top level.                         -->
  <!-- ================================================================ -->

  <target name="init-tasks">
    
    <taskdef name="torque-sql" 
      classname="org.apache.turbine.torque.TorqueSQLTask">
      <classpath refid="classpath"/>
    </taskdef>
    
    <taskdef name="torque-om" 
      classname="org.apache.turbine.torque.TorqueObjectModelTask">
      <classpath refid="classpath"/>
    </taskdef>

    <taskdef name="torque-create-db"
      classname="org.apache.turbine.torque.TorqueCreateDatabase">
      <classpath refid="classpath"/>
    </taskdef>

    <taskdef name="sql-xml" 
      classname="org.apache.turbine.torque.TorqueSQLTransformTask">
      <classpath refid="classpath"/>
    </taskdef>
    
    <taskdef name="texen" 
      classname="org.apache.velocity.texen.ant.TexenTask">
      <classpath refid="classpath"/>
    </taskdef>
  
  </target>

  <!-- ================================================================ -->
  <!-- I N I T  T A R G E T                                             -->
  <!-- ================================================================ -->
  <!-- You will probably only run this target once. It will generate    -->
  <!-- your sources for you and compile them.                           -->
  <!-- ================================================================ -->

  <target name="init" description="--> generates the full application">

    <antcall target="create-database"/>
    
    <antcall target="turbine-sql"/>
    <antcall target="turbine-id-table-sql"/>
    <antcall target="turbine-id-table-init-sql"/>
    <antcall target="turbine-security-sql"/>
    <antcall target="turbine-insert-sql"/>
    
    <antcall target="project-sql"/>
    <antcall target="project-id-table-init-sql"/>
    <antcall target="project-insert-sql"/>
    <antcall target="project-om"/>
    
    <antcall target="update-tr-props"/>
    <antcall target="compile"/>
  
  </target>

  <!-- ================================================================ -->
  <!-- C R E A T E  T A R G E T  D A T A B A S E                        -->
  <!-- ================================================================ -->
  <!-- Create the target database by executing a generated script       -->
  <!-- that is capable of performing the task.                          -->
  <!-- ================================================================ -->
  
  <target name="create-database" depends="init-tasks,ext" 
          unless="database.manual.creation"
          description="--> generates the target database">
    
    <property name="script" value="create-database.${ext}"/>
    
    <echo message="${script}"/>
    
    <torque-create-db
      controlTemplate="sql/db-init/Control.vm"
      outputDirectory="${outputDirectory}/sql"
      templatePath="${templatePath}"
      outputFile="${script}"
      targetPlatform="${platform}"
      targetDatabase="${database}"
      databaseName="${project}"
      databaseUser="${databaseUser}"
      databasePassword="${databasePassword}"
      databaseHost="${databaseHost}"
    />
    
    <chmod file="${outputDirectory}/sql/${script}" perm="+x"/>
    <exec executable="${fullPathOutputDirectory}/sql/${script}" 
          failonerror="yes"/>
    
  </target>

  <!-- ================================================================ -->
  <!-- G E N E R A T E  P R O J E C T  S Q L                            -->
  <!-- ================================================================ -->
  <!-- Generate the SQL for your project, these are in addition         -->
  <!-- to the base Turbine tables! The tables you require for your      -->
  <!-- project should be specified in project-schema.xml.               -->
  <!-- ================================================================ -->

  <target name="project-sql" depends="init-tasks"
          description="--> generates the sql-script for your project">

    <echo message="+------------------------------------------+"/>
    <echo message="|                                          |"/>
    <echo message="| Generating SQL for YOUR Turbine project! |"/>
    <echo message="| Woo hoo!                                 |"/>
    <echo message="|                                          |"/>
    <echo message="+------------------------------------------+"/>

    <torque-sql
      contextProperties="${build.properties}"
      controlTemplate="${SQLControlTemplate}"
      outputDirectory="${outputDirectory}/sql"
      templatePath="${templatePath}"
      outputFile="report.${project}.sql.generation"
      xmlFile="${schemaDirectory}/${project}-schema.xml"
      targetDatabase="${database}"
    />

  </target>

  <!-- ================================================================ -->
  <!-- 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          -->
  <!-- ================================================================ -->
  <!-- Generate the Peer-based object model for your project.           -->
  <!-- These are in addition to the base Turbine OM!                    -->
  <!-- ================================================================ -->

  <target name="project-om" depends="init-tasks"
          description="--> generates the peer-based object model for your project">

    <echo message="+------------------------------------------+"/>
    <echo message="|                                          |"/>
    <echo message="| Generating Peer-based Object Model for   |"/>
    <echo message="| YOUR Turbine project! Woo hoo!           |"/>
    <echo message="|                                          |"/>
    <echo message="+------------------------------------------+"/>

    <torque-om
      contextProperties="${build.properties}"
      controlTemplate="${OMControlTemplate}"
      outputDirectory="${outputDirectory}/java"
      templatePath="${templatePath}"
      outputFile="report.${project}.om.generation"
      targetPackage="${targetPackage}.om"
      xmlFile="${schemaDirectory}/${project}-schema.xml"
    />

  </target>
  
  <!-- ================================================================ -->
  <!-- G E N E R A T E  T U R B I N E  S Q L                            -->
  <!-- ================================================================ -->
  <!-- Generate the SQL required for the Turbine base system.           -->
  <!-- You will probably do this once for your development, but         -->
  <!-- may do this repeatedly when you deploy and want your app         -->
  <!-- app to run with multiple DBs.                                    -->
  <!-- ================================================================ -->

  <target name="turbine-sql" depends="init-tasks"
          description="--> generates the sql-script for the Turbine base system">

    <echo message="+------------------------------------------+"/>
    <echo message="|                                          |"/>
    <echo message="| Generating SQL for Turbine base system!  |"/>
    <echo message="|                                          |"/>
    <echo message="+------------------------------------------+"/>

    <torque-sql
      controlTemplate="${SQLControlTemplate}"
      outputDirectory="${outputDirectory}/sql"
      templatePath="${templatePath}"
      outputFile="turbine-schema.sql"
      xmlFile="${schemaDirectory}/turbine-schema.xml"
      targetDatabase="${database}"
    />

  </target>

  <!-- ================================================================ -->
  <!-- G E N E R A T E  P R O J E C T  S Q L                            -->
  <!-- ================================================================ -->
  <!-- Generate the SQL for your project, these are in addition         -->
  <!-- to the base Turbine tables! The tables you require for your      -->
  <!-- project should be specified in project-schema.xml.               -->
  <!-- ================================================================ -->

  <target name="turbine-id-table-sql" depends="init-tasks">

    <echo message="+------------------------------------------+"/>
    <echo message="|                                          |"/>
    <echo message="| Generating SQL for YOUR Turbine project! |"/>
    <echo message="| Woo hoo!                                 |"/>
    <echo message="|                                          |"/>
    <echo message="+------------------------------------------+"/>

    <torque-sql
      controlTemplate="${SQLControlTemplate}"
      outputDirectory="${outputDirectory}/sql"
      templatePath="${templatePath}"
      outputFile="id-table-schema.sql"
      xmlFile="${schemaDirectory}/id-table-schema.xml"
      targetDatabase="${database}"
    />

  </target>

  <!-- ================================================================ -->
  <!-- G E N E R A T E  T U R B I N E  I D  B R O K E R  I N I T  S Q L -->
  <!-- ================================================================ -->

  <target name="turbine-id-table-init-sql" depends="init-tasks">

    <echo message="+------------------------------------------+"/>
    <echo message="|                                          |"/>
    <echo message="| Generating TURBINE initialization SQL    |"/>
    <echo message="| for ID Broker system!                    |"/>
    <echo message="|                                          |"/>
    <echo message="+------------------------------------------+"/>

    <torque-sql
      contextProperties="bin/torque/templates/sql/id-table/turbine.props"
      controlTemplate="${idTableControlTemplate}"
      outputDirectory="${outputDirectory}/sql"
      templatePath="${templatePath}"
      outputFile="turbine-id-table-init.sql"
      xmlFile="${schemaDirectory}/turbine-schema.xml"
      targetDatabase="${database}"
    />

  </target>

  <!-- ================================================================ -->
  <!-- G E N E R A T E  P R O J E C T  I D  B R O K E R  I N I T  S Q L -->
  <!-- ================================================================ -->

  <target name="project-id-table-init-sql" depends="init-tasks">

    <echo message="+------------------------------------------+"/>
    <echo message="|                                          |"/>
    <echo message="| Generating PROJECT initialization SQL    |"/>
    <echo message="| for ID Broker system!                    |"/>
    <echo message="|                                          |"/>
    <echo message="+------------------------------------------+"/>

    <torque-sql
      contextProperties="bin/torque/templates/sql/id-table/project.props"
      controlTemplate="${idTableControlTemplate}"
      outputDirectory="${outputDirectory}/sql"
      templatePath="${templatePath}"
      outputFile="${project}-id-table-init.sql"
      xmlFile="${schemaDirectory}/${project}-schema.xml"
      targetDatabase="${database}"
    />

  </target>

  <!-- ================================================================ -->
  <!-- T U R B I N E  S E C U R I T Y  S Y S T E M  S Q L               -->
  <!-- ================================================================ -->

  <target name="turbine-security-sql" depends="init-tasks">

    <echo message="+------------------------------------------+"/>
    <echo message="|                                          |"/>
    <echo message="| Generating Turbine security system SQL!  |"/>
    <echo message="|                                          |"/>
    <echo message="+------------------------------------------+"/>
    
    <!-- This could probably be a simple texen task -->
    
    <torque-sql
      contextProperties="bin/torque/templates/sql/id-table/project.props"
      controlTemplate="${securityControlTemplate}"
      outputDirectory="${outputDirectory}/sql"
      templatePath="${templatePath}"
      outputFile="turbine-security.sql"
      xmlFile="${schemaDirectory}/${project}-schema.xml"
      targetDatabase="${database}"
    />

  </target>

  <!-- ================================================================ -->
  <!-- I N S E R T  T U R B I N E  S Q L                                -->
  <!-- ================================================================ -->

  <target name="turbine-insert-sql" description="--> insert turbine sql">
    
    <antcall target="insert-sql-file">
      <param name="sqlFile" value="${outputDirectory}/sql/turbine-schema.sql"/>
    </antcall>

    <antcall target="insert-sql-file">
      <param name="sqlFile" value="${outputDirectory}/sql/turbine-security.sql"/>
    </antcall>

    <antcall target="insert-sql-file">
      <param name="sqlFile" value="${outputDirectory}/sql/id-table-schema.sql"/>
    </antcall>

    <antcall target="insert-sql-file">
      <param name="sqlFile" value="${outputDirectory}/sql/turbine-id-table-init.sql"/>
    </antcall>

  </target>

  <!-- ================================================================ -->
  <!-- I N S E R T  P R O J E C T  S Q L                                -->
  <!-- ================================================================ -->
  
  <target name="project-insert-sql" description="--> insert project sql">
    
    <antcall target="insert-sql-file">
      <param name="sqlFile" value="${outputDirectory}/sql/${project}-schema.sql"/>
    </antcall>
    
    <antcall target="insert-sql-file">
      <param name="sqlFile" value="${outputDirectory}/sql/${project}-id-table-init.sql"/>
    </antcall>
  
  </target>

  <!-- ================================================================ -->
  <!-- INSERT SINGLE SQL FILE                                           -->
  <!-- ================================================================ -->
  <target name="insert-sql-file">
    <sql
      driver="${databaseDriver}"
      url="${databaseUrl}"
      userid="${databaseUser}"
      password="${databasePassword}"
      src="${sqlFile}"
      autocommit="true"
      onerror="continue"
    >
      <classpath refid="classpath"/>
    </sql>
  </target>

  <!-- ================================================================ -->
  <!-- U P D A T E  T U R B I N E  R E S O U R C E S  P R O P S         -->
  <!-- ================================================================ -->
  
  <!-- This is a bit hacky but it makes sure that the user
       only has to edit the project properties file. So
       they don't have to edit the TR.props as well. I will
       unify this in a less hack-ass manner next round :-)
  -->
  
  <target name="update-tr-props">
    
    <filter token="DATABASE_DRIVER" value="${databaseDriver}"/>
    <filter token="DATABASE_URL" value="${databaseUrl}"/>
    <filter token="DATABASE_USER" value="${databaseUser}"/>
    <filter token="DATABASE_PASSWORD" value="${databasePassword}"/>
    
    <property name="database.descriptor" value="${master.conf.dir}/database/${database}"/>
    <property name="database.name" value="${project}"/>
    <property file="${database.descriptor}"/>
    
    <filter token="DATABASE_ADAPTOR" value="${database.adaptor}"/>
  
    <copy 
      file="${conf.dir}/TurbineResources.properties" 
      tofile="${conf.dir}/tmp"
      filtering="yes"
    />

    <move
      file="${conf.dir}/tmp"
      tofile="${conf.dir}/TurbineResources.properties" 
    />

  </target>

  <!-- =================================================================== -->
  <!-- C O M P I L E                                                       -->
  <!-- =================================================================== -->  
  
  <target name="compile" description="--> compiles the source code">
        
    <javac srcdir="${src.dir}"
      destdir="${build.dest}"
      debug="${debug}"
      deprecation="${deprecation}"
      optimize="${optimize}">
            
      <classpath refid="classpath"/>

    </javac>
  
  </target>

  <!-- ================================================================ -->
  <!-- C L E A N                                                        -->
  <!-- ================================================================ -->
  
  <target name="clean" description="--> cleans up the build directory">
    
    <delete dir="${build.dest}"/>
    <mkdir dir="${build.dest}"/>
  
  </target>

  <!-- =================================================================== -->
  <!-- S Q L  ->  X M L                                                    -->
  <!-- =================================================================== -->
  <!--  inputFile: The input sql file. This must be valid sql file but     -->
  <!--             it not not be in any specific format.                   -->
  <!-- outputFile: The file where the xml schema will be written           -->
  <!-- =================================================================== -->

  <target name="sql2xml">
    
    <sql-xml
      inputFile="${schemaDirectory}/schema.sql"
      outputFile="${schemaDirectory}/schema.xml"
    />
  
  </target>

  <!-- =================================================================== -->
  <!-- J A R                                                               -->
  <!-- =================================================================== -->  
  
  <target name="jar" depends="compile">
    
    <jar jarfile="../${final.name}.jar"
      basedir="${build.dest}"
      excludes="**/package.html"
    />
  
  </target>

  <!-- =================================================================== -->
  <!-- E X T E N S I O N  F I N D E R                                      -->
  <!-- =================================================================== -->  
  <!-- Alleviate the user from having to type in the extension of scripts  -->
  <!-- for their target platform. Ant can do it just peachy.               -->
  <!-- =================================================================== -->  

  <target name="ext" depends="set-os,windows-ext">
    <echo message="Platform = ${platform}"/>
    <echo message="Extension = ${ext}"/>
  </target>
  <target name="set-os">
    <property name="is${os.name}" value="true"/>
  </target>  
  <target name="windows-ext" depends="unix-ext" unless="ext">
    <property name="platform" value="windows"/>
    <property name="ext" value="bat"/>
  </target>
  <target name="unix-ext" depends="set-unix" if="is.Unix">
    <property name="platform" value="unix"/>
    <property name="ext" value="sh"/>
  </target>
  <target name="set-unix" depends="set-windows98" unless="is.Windows">
    <property name="is.Unix" value="true" />
  </target>
  <target name="set-windows98" depends="set-windowsNT" if="isWindows 98">
    <property name="is.Windows" value="true" />
  </target>
  <target name="set-windowsNT" depends="set-windows2000" if="isWindows NT">
    <property name="is.Windows" value="true" />
  </target>
  <target name="set-windows2000" depends="set-windowsXP" if="isWindows 2000">
    <property name="is.Windows" value="true" />
  </target>
  <target name="set-windowsXP" if="isWindows XP">
    <property name="is.Windows" value="true" />
  </target>
</project>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to