<?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>Torque Tutorial - Step 1: Installing Maven and the Torque Maven Plugin</title>
    <author email="pete-apache-dev@kazmier.com">Pete Kazmier</author>
    <author email="seade@backstagetech.com.au">Scott Eade</author>
    <author email="fischer@seitenbau.de">Thomas Fischer</author>
  </properties>
  <body>

<section name="Step 1: Installing Maven 1 and the Torque Maven Plugin">

<p>
  First of all, note that Torque is divided into four parts.
  <ul>
    <li>
      The generator generates your persistence classes from an xml
      description of the database. It also generates and executes
      sql scripts to create all the necessary tables, constraints etc.
      in your database.
      The generator comes packaged in two jars: The templates in
      torque-gen-templates.jar, and the rest in torque-gen.jar.
      In this tutorial, you will not use the generator directly, but you
      will invoke it using the Maven 1 plugin.  This also means that you do
      not have to download the generator separately from the maven 1 plugin.
    </li>
    <li>
      The Maven 1 plugin integrates the generator into
      <a href="http://maven.apache.org/maven1">Maven 1</a>, a software
      project management tool. In other words, the maven plugin is
      a frontend for the generator.
    </li>
    <li>
      The runtime has to be included in your projects for the generated classes
      to work properly.
    </li>
    <li> 
      There is also a Maven 2 plugin available, but this is not covered
      in this tutorial.
    </li>
  </ul>
  For this tutorial, we will be using the maven 1 plugin for Torque 3.3
  (which will silently invoke the generator) to
  generate our object model classes and sql scripts. For working with the
  generated classes, we will use the Torque 3.3 runtime for our
  sample application.
</p>

<p>
  If you have not already done so, download and install
  <a href="http://maven.apache.org/maven-1.x">Maven 1</a>. 
  It is highly recommended to use version 1.0.2 of Maven. 
  You can not use the Torque Maven 1 plugin with Maven 2.
</p>

<p>
  Maven uses an online repository to download any libraries and 
  resources it need.  The default for this has been the 
  <a href="http://www.ibiblio.org/maven">ibiblio maven repository</a>.
  However, this has been moved and now Maven 1.0.x is 
  unable to find required dependencies without a minor configuration
  change. (For more information see 
  <a href="http://maven.apache.org/maven-1.x/news.html">the Maven 1.1 Site.</a>)
</p>
<p>  
  In order to find the files that Torque needs, you will need to create
  a file named project.properties in your user's home directory.
  e.g. C:\Documents and Settings\userid on Windows
  or ~userid on *nix.  This file only needs the following line in it:
  <ul>
  maven.repo.remote=http://repo1.maven.org/maven
  </ul>
</p>
<p>Once you have done this, obtain the Torque maven plugin by typing:
</p>

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

<p>
  You do not need to download the generator or the
  runtime separately. Maven will download them from
  the ibiblio distribution site automatically
  when they are needed.
</p>

</section>

<section name="Where to next">

<p>
  Next we will look at <a href="step2.html">Configuring the Torque generator</a>.
</p>

</section>

<section name="User Comments">
  <a href="http://wiki.apache.org/db-torque/TutorialUserCommentsStep1">User comments</a>
  for this step
</section>


  </body>
</document>
