mpoeschl 01/07/13 13:55:29
Added: src/share/sample30/build build.properties build.xml
GETTING_STARTED.txt
Log:
add updated sample-app for turbine-3.0
Revision Changes Path
1.1 jakarta-turbine-tdk/src/share/sample30/build/build.properties
Index: build.properties
===================================================================
# -------------------------------------------------------------------
#
# P R O J E C T P R O P E R T I E S
#
# -------------------------------------------------------------------
# These are the properties for your Turbine project. The properties
# in this file will override properties set anywhere else.
# -------------------------------------------------------------------
project=@PROJECT@
version=0.1
build.dest=../classes
src.dir=../src/java
conf.dir=../conf
master.conf.dir=../../../../share/conf
debug=on
optimize=off
deprecation=on
# -------------------------------------------------------------------
#
# T A R G E T D A T A B A S E
#
# -------------------------------------------------------------------
# This is the target database, only considered when generating
# the SQL for your Turbine project. Your possible choices are
#
# db2
# hypersonic
# mysql
# oracle,
# postgresql
#
# Default: none
# -------------------------------------------------------------------
database=@DATABASE@
#database.manual.creation = true
# -------------------------------------------------------------------
#
# O B J E C T M O D E L I N F O R M A T I O N
#
# -------------------------------------------------------------------
# These settings will allow you to customize the way your
# Peer-based object model is created.
# -------------------------------------------------------------------
extend=TurbineMapBuilder
mapname=TurbineMap
suffix=MapBuilder
targetPackage=@[email protected]
targetDirectory=@TARGET_DIRECTORY@/om
addSaveMethod=true
addGetByNameMethod=false
complexObjectModel=true
basePrefix=Base
# -------------------------------------------------------------------
#
# D A T A B A S E S E T T I N G S
#
# -------------------------------------------------------------------
# JDBC connection settings. This is used by the JDBCToXML task that
# will create an XML database schema from JDBC metadata. These
# settings are also used by the SQL Ant task to initialize your
# Turbine system with the generated SQL.
# -------------------------------------------------------------------
#--------------------------------------------------------------------
# HSQL use
# FULLPATH = full path to where you want the database
# Note: either torque or HSQL is really touchy about extra spaces
# or other stuff after each line below.
#--------------------------------------------------------------------
#databaseUrl=jdbc:HypersonicSQL:FULLPATH/@PROJECT@
#databaseDriver=org.hsql.jdbcDriver
#databaseUser=sa
#databasePassword=
databaseUrl = jdbc:mysql://127.0.0.1/@PROJECT@
databaseDriver = org.gjt.mm.mysql.Driver
databaseUser = user
databasePassword = password
databaseHost = 127.0.0.1
# -------------------------------------------------------------------
# You should NOT have to edit anything below here.
# -------------------------------------------------------------------
# -------------------------------------------------------------------
#
# T E M P L A T E P A T H
#
# -------------------------------------------------------------------
templatePath = @TEMPLATE_PATH@
# -------------------------------------------------------------------
#
# C O N T R O L T E M P L A T E S
#
# -------------------------------------------------------------------
SQLControlTemplate = sql/base/Control.vm
OMControlTemplate = om/Control.vm
idTableControlTemplate = sql/id-table/Control.vm
securityControlTemplate = sql/security/Control.vm
# -------------------------------------------------------------------
#
# O U T P U T D I R E C T O R Y
#
# -------------------------------------------------------------------
# The two properties are identical but they are like this for
# a reason. They are for testing the TDK, the reason they
# are duplicated is due to a bug in Ant with the <exec> task.
# -------------------------------------------------------------------
outputDirectory = @OUTPUT_DIRECTORY@
fullPathOutputDirectory = @OUTPUT_DIRECTORY@
# -------------------------------------------------------------------
#
# S C H E M A D I R E C T O R Y
#
# -------------------------------------------------------------------
schemaDirectory = @SCHEMA_DIRECTORY@
1.1 jakarta-turbine-tdk/src/share/sample30/build/build.xml
Index: build.xml
===================================================================
<?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="../../../../common/lib">
<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>
<taskdef name="format-source"
classname="jstyle.FormatTask">
<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="update-tr-props"/>
<antcall target="project"/>
</target>
<!-- ================================================================ -->
<!-- P R O J E C T -->
<!-- ================================================================ -->
<!-- This target runs all the targets required when changes -->
<!-- are made to the project XML database schema. -->
<!-- ================================================================ -->
<target name="project" description="--> run when XML schema is changed">
<antcall target="project-sql"/>
<antcall target="project-id-table-init-sql"/>
<antcall target="project-insert-sql"/>
<antcall target="project-om"/>
<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"
/>
<format-source>
<fileset dir="${src.dir}/${targetDirectory}">
<include name="**/*.java"/>
</fileset>
</format-source>
</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}"/>
<!--
Leave this set to "default" until we figure out how
to get this value as a torque property.
<filter token="DATABASE_DEFAULT" value="${project}"/>
-->
<filter token="DATABASE_DEFAULT" value="default"/>
<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-windowsME" if="isWindows 2000">
<property name="is.Windows" value="true" />
</target>
<target name="set-windowsME" if="isWindows Me">
<property name="is.Windows" value="true" />
</target>
</project>
1.1 jakarta-turbine-tdk/src/share/sample30/build/GETTING_STARTED.txt
Index: GETTING_STARTED.txt
===================================================================
--------------------------------------------------------------------------
G E T T I N G S T A R T E D G U I D E
--------------------------------------------------------------------------
Hey! You made it!
To get the sample peer application running you must edit
a few properties in your build.properties file
and run the "init" target in the provided Ant build file.
You must edit the following properties in your
build.properties file:
database
databaseUrl
databaseDriver
databaseUser
databasePassword
There is documentation inside your build.properties
file describing your options in each case.
After you have edited your properties, you should run the
initialization target of your build file:
ant init
YOU MUST RUN THE INITIALIZATION TARGET OR NOTHING
WILL WORK!!! YOU HAVE BEEN WARNED!!
You must have an installed version of Ant, if you
do not have an installed version of Ant you can
find instructions here:
http://jakarta.apache.org/ant/manual/install.html
Running the "init" target will run the following set
of targets for you automatically:
1. create-database
2. turbine-sql
3. turbine-id-table-sql
4. turbine-id-table-init-sql
5. turbine-security-sql
6. turbine-insert-sql
7. project-sql
8. project-id-table-init-sql
9. project-insert-sql
10. project-om
11. update-tr-props
12. compile
Running these targets should completely setup the sample
peer application. Everything database related should be
working at this point, and all the required Java sources
should have been generated and compiled. Now all you
have to do is:
http://localhost:8080/newapp/servlet/newapp
This process is not perfect: it works well in the
first pass running the init target but there is one
prominent defect. After you run the init target any
subsequent changes to your database properties will
not automatically be propagated to your TR.props, even
if you run the init target again. If you change your db
configuration after the init target is run you will have
to manually edit your TR.props. Sorry for the
inconvenience.
But otherwise, Enjoy!!
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]