Maven 2 Macker Plugin - How to Use

This plugin executes Macker against your compiled classes.

How to Execute Macker against your Project

Configuration Parameters

The outputName parameter allows you to name the generated XML output file. The default is macker-out.xml.

The maxmsg parameter corresponds to the printMaxMessages setting in Macker.

The print parameter corresponds to the printThreshold setting in Macker. Valid values are debug, info, warning, and error.

The anger parameter corresponds to the angerThreshold setting in Macker. Valid values are debug, info, warning, and error.

The rule parameter allows the user to specify the name of the rules XML file that Macker will use. The default is macker-rules.xml. Several XML files are allowed using the rules (list) parameter.

The verbose parameter corresponds to the verbose setting in Macker.

The variables (map) parameter allows you to define additional variables that will be passed to Macker.

Please read the Macker documentation for more information.

The following definition shows the plugin with all possible configuration values and their defaults:

<build>
  [...]
  <plugin>
    <groupId>org.codehaus.mojo</groupId>
      <artifactId>macker-maven-plugin</artifactId>
      <version>1.0.0-SNAPSHOT</version>
      <configuration>
        <outputName>macker-out.xml</outputName>
        <maxmsg>0</maxmsg>
        <print>error|warning|info|debug</print>
        <anger>error|warning|info|debug</anger>
        <classesDirectory>target/classes</classesDirectory>
        <testClassesDirectory>target/test-classes</testClassesDirectory>
        <rulesDirectory>src/main/config</rulesDirectory>
        <rule>macker-rules.xml</rule>
        <verbose>false</verbose>
        <failOnError>true</failOnError>
        <skip>false</skip>
        <includeTests>false</includeTests>
        <variables>
          <key1>value1</key1>
          [...]
        </variables>
        <excludes>
          <exclude>**/*Bean.class</exclude>
          <exclude>**/generated/*.class</exclude>
        </excludes>
        <maxmem>64m</maxmem>
        <quiet>false</quiet>
      </configuration>
      <executions>
        <execution>
          <phase>compile</phase>
          <goals>
            <goal>macker</goal>
          </goals>
        </execution>
      </executions>
  </plugin>
  [...]
</build>

Using Rules

The Macker plugin supports more than one rule set. The rule sets may reside in the classpath, filesystem or at a URL. For rule sets that are bundled with the plugin, you do not need to specificy the absolute path of the file. It will be resolved by the plugin. But if the rule set is a custom rule set, you need to specify its absolute path.

<build>
  <plugin>
    <groupId>org.codehaus.mojo</groupId>
      <artifactId>macker-maven-plugin</artifactId>
      <configuration>
        [...]
        <rules>
          <!-- A rule sets that is in the classpath -->
          <rule>/rules/architecture.xml</rule>
          <!-- Custom local file system rule set -->
          <rule>d:\rules\layers.xml</rule>
          <!-- Custom remote rule set accessed via a URL -->
          <rule>http://localhost/design.xml</rule>
        </rules>
      </configuration>
      </executions>
  </plugin>
</build>

Known Issues and Limitations

As with similar plugins (Findbugs etc), when running Macker on a project, the default heap size (64m) might not be enough to complete the build. As Macker is forked, just set the maxmem parameter and run Macker with it's own memory requirements.

<maxmem>384M</maxmem>