<?xml version="1.0"?>
<!--
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
-->
<document>

 <properties>
   <title>Maven Torque Plugin</title>
   <author email="stephenh@chase3000.com">Stephen Haberman</author>
   <author email="quintonm@bellsouth.net">Quinton McCombs</author>
   <author email="seade@backstagetech.com.au">Scott Eade</author>
   <author email="fischer@seitenbau.de">Thomas Fischer</author>
 </properties>

 <body>
   <source>
     Please see the <a href="../../../status.html">News and Status Page</a> for
     information about a Maven 1.0.x repository change.</source>

   <section name="Introduction">

    <p>
      Torque projects used to be built with all of the Torque elements 
      (templates, property files, <code>build-torque.xml</code>, etc.)
      locally installed in each project's source tree.
    </p>

    <p>
      The advent of Maven allows Torque to be used in a much simpler manner.
      With the Maven plugin, absolutely no Torque-related resources
      (except the Torque jar file itself) are required to be 
      locally installed in each project.  Instead, the plugin will
      automatically download any required resources for you.
    </p>
      
    <p>
      At the moment, only Maven 1 is supported by the Torque Maven plugin.
      The recommended version is Maven 1.0.2.
    </p> 

    <p>
      For more information on the functionality provided by this plugin
      see the <a href="goals.html">Goals</a> document.  The various
      properties used to configure the plugin are documented in the
      <a href="properties.html">Properties</a> document.
    </p>

  </section>

  <section name="Installation">

    <p>
      The Torque Maven plugin is installed thus:
    </p>

<source><![CDATA[
maven plugin:download -DartifactId=maven-torque-plugin -DgroupId=torque -Dversion=3.3
]]></source>

  </section>

  <section name="Configuration">

    <p>
      The Torque Maven plugin is configured via properties defined in your
      project.properties file.  See the
      <a href="properties.html">properties reference</a> for
      details on the various properties that can be configured.
    </p>

    <subsection name="project.properties">

      <p>
        Instead of relying on the typical <code>build.properties</code>, 
        the Maven plugin uses the project-wide settings in the 
        <code>project.properties</code> file.
      </p>

      <p>
        The Torque settings in <code>project.properties</code> follow the same
        format as they would in the generator's <code>build.properties</code>
        except the default directories are different to better fit a maven-ized
        project.
      </p>

      <p>
        Here is a sample <code>project.properties</code>:
      </p>

<source><![CDATA[
... other project settings...

# -------------------------------------------------------------------
#
#  T O R Q U E   S E T T I N G S
#
# -------------------------------------------------------------------

torque.project = yourproject
torque.database = mysql

torque.database.createUrl = jdbc:mysql://localhost:3306/
torque.database.buildUrl = jdbc:mysql://localhost:3306/yourprojectdb
torque.database.url = jdbc:mysql://localhost:3306/yourprojectdb
torque.database.driver = org.gjt.mm.mysql.Driver
torque.database.user = user
torque.database.password = password
torque.database.host = localhost

]]></source>

    </subsection>

  </section>

  <section name="Cutomization of templates">

    <p>
      Internally, the Torque Maven plugin uses the 
      <a href="../generator/index.html">Torque generator</a>
      to execute its tasks.  The generator in turn uses the Torque generator
      templates to build the java classes and SQL scripts.
      If you want to customize the generated classes or SQL beyond the 
      possibilities offeret by the 
      <a href="properties.html">project properties</a>, you can use your
      own templates either by uploading your own 
      <code>torque-gen-templates.jar</code> into the maven repository, or
      you can tell the maven plugin to use an external templates directory,
      see the <a href="properties.html">property reference</a>.
    </p>

  </section>
    
  <section name="Building from Source">

    <p>
      Building the maven plugin from source is relatively easy -
      you might want to do this if there are fixes or enhancements in SVN
      that you want to make use of.  Another reason you might want
      to do this is if you wish to make your own copy of the plugin
      that includes a set of customized generator templates 
      to modify the object model class files that will be produced.
    </p>

    <p>
      The first thing to do is to check out Torque from SVN; see the 
      <a href="../../../../developer-info/subversion.html">Subversion Guide</a>
      for more information.  First build and install the generator templates,
      then build and install the generator.  Finally, run <code>maven
      plugin:install</code> in the <code>maven-plugin</code> directory.
      This will jar together the various plugin files and copy the jar
      into your <code>${maven.home}/plugins</code> directory.
    </p>

  </section>

  <section name="Other Tips">

    <p>
      If you run into problems, try the following tips:
      <ul>
        <li>
          Don't place your <code>project-schema.xml</code> file in a directory
          with other files. This can lead to various DTD errors.
        </li>
      </ul>
    </p>
    
  </section>
  
 </body>
</document>
