Maven enforcer Plugin: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 16: Line 16:
=Examples=
=Examples=


==Fail if FIles Do Not Exist==
==Fail if Files Do Not Exist==


<pre>
<pre>
Line 28: Line 28:
         <executions>
         <executions>
           <execution>
           <execution>
             <id>enforce-directory-exists</id>
             <id>enforce-file-exists</id>
             <goals>
             <goals>
               <goal>enforce</goal>
               <goal>enforce</goal>

Revision as of 20:13, 30 May 2016

External

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: https://maven.apache.org/enforcer/enforcer-rules/index.html

Examples

Fail if Files Do Not Exist

<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>
                  <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>