Apache Maven 1.x has reached its end of life, and is no longer supported. For more information, see the announcement. Users are encouraged to migrate to the current version of Apache Maven.

Introduction

The genapp plugin provides several general purpose templates. Companies or large sites may have their own application templates that for whatever reason they want to keep in-house.

This guide is intended to help writing and maintaining application templates outside the plugin. In this manner, the plugin can be updated and the template is not affected.

If you have some good application templates, consider contributing a general purpose version to the project, so more users can benefit from it.

Uses

Information on this guide can be used to write custom templates or to simply customize built-in templates. Since templates are currently stored in a JAR file you cannot modify that template without having to maintain a customized version of the plugin (for example, an upgrade of the plugin will not include you changes, unless they were committed to maven's cvs).

Writing the template

Setup

Go to you local maven installation and extract in a working directory the contents of plugins/maven-genapp-plugin.x.y.jar (where x.y is the version of the plugin).

Inside the plugin-resources directory you can find many directories with different templates. These directories contain the resources associated with the different templates. Start by copying one of there to a different directory. This new copy will be the one that we'll be working on. For this example, we will consider the new template directory to be on

/opt/templates/foo

Template customization

Go to /opt/templates/foo. You should find there a template.properties file and a template-resources directory. The template properties file may be customized (open and play with its properties).

Just play with files in the template until you have what you want. One of the things that you are likely to change is the project.xml file, to have you company information, your directory layout and the reports you use.

Using

Create a directory for your application and type

maven genapp -Dmaven.genapp.template.dir=/opt/templates/foo

This should generate the application template you defined.

If you are willing to write more templates, consider using the property maven.genapp.template.repository and place there all your templates. Then, you can invoke you template by the name of the directory.