Fork me on GitHub

Description

This warbucks-maven-plugin makes it possible to evaluate your project’s classes to ensure they are annotated as desired.

You can specify as many rules as you like, and each one will be evaluated in order. The build will fail if any rule fails. By default, it runs at the process-test-classes phase of the Maven build lifecycle. This is to ensure it runs after all classes have been compiled, but before any tests are run.

A rule is composed of a pattern for identifying the classes to evaluate, and a pattern for the annotations one requires to be used.

Getting Started

To add this plugin to your project, configure the plugin similarly to:

  <build>
    <plugins>
      <plugin>
        <groupId>net.revelc.code</groupId>
        <artifactId>warbucks-maven-plugin</artifactId>
        <version>1.1.2</version>
        <configuration>
          <rules>
            <!-- Example rule to ensure Public integration tests have a JUnit Category -->
            <rule>
              <!-- a pattern of classes for which to check annotations -->
              <classPattern>.*IT</classPattern>
              <!-- include the classes which have Public modifier -->
              <includePublicClasses>true</includePublicClasses>
              <!-- exclude the classes which have Package-private modifier -->
              <includePackagePrivateClasses>false</includePackagePrivateClasses>
              <!-- exclude the classes which have Protected modifier -->
              <includeProtectedClasses>false</includeProtectedClasses>
              <!-- exclude the classes which have Private modifier -->
              <includePrivateClasses>false</includePrivateClasses>
              <!-- a pattern of annotations which are required for the specified classes -->
              <classAnnotationPattern>org[.]junit[.]experimental[.]categories[.]Category</classAnnotationPattern>
            </rule>
          </rules>
        </configuration>
        <executions>
          <execution>
            <id>run-warbucks</id>
            <goals>
              <goal>check</goal><!-- runs at process-test-classes phase -->
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

and build your project, similarly to (it runs at the verify phase by default):

mvn verify