Integrating Maven with a Project

Now that you have Maven installed on your system, this section will show you how to integrate it with an existing project. All of the current Turbine projects have been Maven-enabled, and can be used as references. They will be used as examples in this section. There is really only one step to integration Maven with a project: the creation of the project descriptor. You may also create an ancillar maven.xml file which contains project specific goals, preGoals, and postGoals.

Creating a Project Descriptor

Everything in Maven gravitates around the definition of a project. The unit of work in Maven is the project, so before you can get started with Maven you need to create your project definition. The easiest way to do this is to create an XML representation of this definition. In Maven-terms, this is called the project descriptor.

You'll need to create a project descriptor to use Maven with your project. The project descriptor must be called project.xml and must reside in the top-level directory of your project's directory hierarchy. The contents of the descriptor are described in detail in the Project Descriptor document. A sample project descriptor is included below for reference. In addition, all of the Turbine projects have valid project descriptors that you can examine.

We are working on a tool that will help you create your project descriptor automatically, but if you want to get started right away with Maven, then you'll have to create your own project.xml file manually (probably easiest to just modify an existing one such as the one below). The following is the project descriptor used to describe the Maven project:

Using Maven with your existing build

Maven doesn't require the use of any Ant build files so you can try using Maven without affecting the way you traditionally build your project.

Extending Maven's build system

There are two main ways you can extend Maven's build system: creating new plug-ins, and adding additional processing in a project specific maven.xml file.