Maven 2 Macker Plugin - A Simple Example

To use the Macker plugin, you'll first need to construct a Macker rules file.

Simple Macker rules file

<?xml version="1.0"?>
<macker>    
    <ruleset name="Testing rules">
        <pattern name="mypackage" class="org.codehaus.mojo.**" />
        <access-rule>
            <message>System out is bad. Use logging instead.</message>
            <deny>
                <to>
                    <include class="java.lang.System" />
                </to>
            </deny>
            <!--allow>
                <from pattern="blah" />
            </allow-->
        </access-rule>
    </ruleset>
</macker>

Save this into a file named macker-rules.xml. This file should be located in src/main/config.

 .
 |-- pom.xml
 `-- src
     |-- main
     |   |-- java
     |   |-- config
     |       `-- macker-rules.xml
     |-- site
     '-- test

Simple POM configuration

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>macker-maven-plugin</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <executions>
          <execution>
            <phase>compile</phase>
            <goals>
              <goal>macker</goal>
            </goals>
          </execution>
        </executions>      
      </plugin>
    [...]
</project>

Execution of Macker during Maven build

Assuming you're using the simple POM configuration shown above, simply call mvn compile or mvn package and Macker will automatically be executed during your build.