This tutorial introduces the verifier plugin, one of the core plugins of the Maven build tool.
For an overview of the other core plugins, refer to this overview article.
2. Plugin Goal
The verifier plugin has only one goal – verify. This goal verifies the existence or non-existence of files and directories, optionally checking file content against a regular expression.
Despite its name, the verify goal is bound to the integration-test phase by default rather than the verify phase.
The verifier plugin is triggered only if it's explicitly added to the pom.xml:
<plugin> <artifactId>maven-verifier-plugin</artifactId> <version>1.1</version> <configuration> <verificationFile>input-resources/verifications.xml</verificationFile> </configuration> <executions> <execution> <goals> <goal>verify</goal> </goals> </execution> </executions> </plugin>
This link shows the newest version of the plugin.
The default location of the verification file is src/test/verifier/verifications.xml. We must set a value for the verificationFile parameter if we want to use another file.
Here's the content of the verification file shown in the given configuration:
<verifications xmlns="http://maven.apache.org/verifications/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/verifications/1.0.0 http://maven.apache.org/xsd/verifications-1.0.0.xsd"> <files> <file> <location>input-resources/baeldung.txt</location> <contains>Welcome</contains> </file> </files> </verifications>
This verification file confirms that a file named input-resources/baeldung.txt exists and that it contains the word Welcome. We've already added such a file before, thus the goal execution succeeds.
In this article, we walk through the verifier plugin and described how to customize it.
The complete source code for this tutorial can be found over on GitHub.