Skip to content
This repository has been archived by the owner on Jun 26, 2021. It is now read-only.
Stanley Hillner edited this page Jul 22, 2016 · 10 revisions

CDI-based Dependency Injection for Maven Plugin Development

The following pages will give a detailed overview over the basic concepts and their implementations as well as some usage examples and suggestions.

Usage

Simply add the following dependency to your Maven plugin and start implementing your Mojos.

<dependency>
  <groupId>com.itemis.maven.plugins</groupId>
  <artifactId>cdi-plugin-utils</artifactId>
  <version>3.1.2</version>
</dependency>

Your Mojos must extend the abstract class com.itemis.maven.plugins.cdi.AbstractCDIMojo and must not override the method execute() since this method is implemented by the base class and which will bootstrap the dependency injection container at this point.

Implicit Mojo Parameters

There are some Mojo parameters that are implicitly available for all Mojos when extending AbstractCDIMojo. Currently the list of parameters comprises the following ones:

Parameter Name User Property Name Type Default Value Required Description
enableLogTimestamps enableLogTimestamps boolean true false Enables timestamped logging output. The logger can be retrieved by injecting either org.apache.maven.plugin.logging.Log or com.itemis.maven.plugins.cdi.logging.MavenLogWrapper.
workflowDescriptor workflowDescriptor File - false This is the parameter for overriding the default workflow of the Mojo. Set the path of your custom workflow file here.

Some Implicit Help Features

Besides the implicit Mojo parameters there are also some implicit switches available for all Mojos that extend the AbstractCDIMojo. These switches are mainly used to provide some meta-information about the Mojo such as the workflow. Those switches can only be activated using system properties (-D...) and are not part of the actual Mojo configuration.
There are currently the following switches available:

Switch Allowed Values Feature Description
printWorkflow ANY (value not considered) Prints the default workflow of the Mojo (more info).
printSteps ANY (value not considered) Prints all Processing steps that are available on classpath. These steps can be used to customize the workflow (more info).

Where Next?