Apache Maven Model Converter (RETIRED)

Note: This shared component has retired from the Apache Maven project, but has moved to the Apache Archiva project.

This shared component is used to convert Maven POMs between version 3 (used by Maven 1.x) and version 4 (used by Maven 2.0). It is used by Maven One Plugin and Archiva.

Apart from the main conversion of the different elements in the POM, there are a couple of extensions to handle plugins and their configurations. Which plugins are avaliable and how they are configured is not specified in the XML schema for version 4 POMs. The schema only has generic definitions for plugins and it allows them to have a configuration.

Plugin Configuration Converters

In Maven 1 a plugin is configured in the file project.properties. In Maven 2 on the other hand the configuration is done with XML elements within the plugin's <configuration> element. The conversion between the two is handled by Plexus components that implement the org.apache.maven.model.converter.plugins.PluginConfigurationConverter interface.

This interface has one main method convertConfiguration(...) that takes a Maven 1 model, a Maven 2 model and a Maven 1 Properties object as parameters. If you want to add a new plugin configuration converter it is recommended that you extend AbstractPluginConfigurationConverter. Have a look at some of the other implementations in our SCM in the directory /src/main/java/org/apache/maven/model/converter/plugins/ to get a feel for what is needed. You basically need to implement the method buildConfiguration(...) to build a DOM configuration object.

Plugin Relocators

Another thing that needs to be taken care of, is that the plugins in Maven 2 are not the same as they were in Maven 1. Some have changed names while others have moved to other projects completely. This relocation of plugins is handled by Plexus components that implement the org.apache.maven.model.converter.relocators.PluginRelocator interface.

If you want to implement a new relocator you can extend the class AbstractPluginRelocator to make your work easier. You simply need to specify the old and new groupId and artifactId. Read the Javadocs for some important notes. You can also save yourself some work by studying the other implementations in our SCM in the directory /src/main/java/org/apache/maven/model/converter/relocators/ and picking the best from them.