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.
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.0.0</version> <configuration> <rules> <!-- Example rule to ensure integration tests have a JUnit Category --> <rule> <!-- a pattern of classes for which to check annotations --> <classPattern>.*IT</classPattern> <!-- 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):