Maven enforcer Plugin: Difference between revisions
Jump to navigation
Jump to search
(9 intermediate revisions by the same user not shown) | |||
Line 10: | Line 10: | ||
=Overview= | =Overview= | ||
The plugin checks rules and warns or fails the build if conditions are not met. | The plugin checks rules and warns or fails the build if conditions are not met. | ||
The list of rules the plugin can enforce is specified here: | |||
{{External|https://maven.apache.org/enforcer/enforcer-rules/index.html}} | |||
The enforcer version range syntax is specified here: | |||
{{External|https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html}} | |||
The enforcer plugin binds to the [[Maven_Concepts_-_Lifecycle#validate|validate]] phase, which is the first phase in the lifecycle. | |||
One of the places this plug in is used is the [[Maven_Profile#Other_Methods|<activation> element of a profile]]. | |||
=Examples= | |||
==Fail if Files Do Not Exist== | |||
Works with both files and directories. For directories, use the same <tt><requireFilesExist></tt>. | |||
<pre> | |||
<project> | |||
[...] | |||
<build> | |||
<plugins> | |||
<plugin> | |||
<groupId>org.apache.maven.plugins</groupId> | |||
<artifactId>maven-enforcer-plugin</artifactId> | |||
<executions> | |||
<execution> | |||
<id>enforce-file-exists</id> | |||
<goals> | |||
<goal>enforce</goal> | |||
</goals> | |||
<configuration> | |||
<rules> | |||
<requireFilesExist> | |||
<message>Custom message</message> | |||
<files> | |||
<file>${project.build.outputDirectory}/foo.txt</file> | |||
<file>${project.build.outputDirectory}/foo2.txt</file> | |||
</files> | |||
</requireFilesExist> | |||
</rules> | |||
<fail>true</fail> | |||
</configuration> | |||
</execution> | |||
</executions> | |||
</plugin> | |||
</plugins> | |||
</build> | |||
[...] | |||
</project> | |||
</pre> |
Latest revision as of 19:12, 1 March 2017
External
- https://maven.apache.org/enforcer/maven-enforcer-plugin/
- https://maven.apache.org/enforcer/index.html
Internal
Overview
The plugin checks rules and warns or fails the build if conditions are not met.
The list of rules the plugin can enforce is specified here:
The enforcer version range syntax is specified here:
The enforcer plugin binds to the validate phase, which is the first phase in the lifecycle.
One of the places this plug in is used is the <activation> element of a profile.
Examples
Fail if Files Do Not Exist
Works with both files and directories. For directories, use the same <requireFilesExist>.
<project> [...] <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-enforcer-plugin</artifactId> <executions> <execution> <id>enforce-file-exists</id> <goals> <goal>enforce</goal> </goals> <configuration> <rules> <requireFilesExist> <message>Custom message</message> <files> <file>${project.build.outputDirectory}/foo.txt</file> <file>${project.build.outputDirectory}/foo2.txt</file> </files> </requireFilesExist> </rules> <fail>true</fail> </configuration> </execution> </executions> </plugin> </plugins> </build> [...] </project>