Maven Torque Plugin Stephen Haberman Quinton McCombs Scott Eade Thomas Fischer Please see the News and Status Page for information about a Maven 1.0.x repository change.

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

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.

At the moment, only Maven 1 is supported by the Torque Maven plugin. The recommended version is Maven 1.0.2.

For more information on the functionality provided by this plugin see the Goals document. The various properties used to configure the plugin are documented in the Properties document.

The Torque Maven plugin is installed thus:

The Torque Maven plugin is configured via properties defined in your project.properties file. See the properties reference for details on the various properties that can be configured.

Instead of relying on the typical build.properties, the Maven plugin uses the project-wide settings in the project.properties file.

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

Here is a sample project.properties:

Internally, the Torque Maven plugin uses the Torque generator 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 project properties, you can use your own templates either by uploading your own torque-gen-templates.jar into the maven repository, or you can tell the maven plugin to use an external templates directory, see the property reference.

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.

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

If you run into problems, try the following tips: